2013-03-28 2 views
1

내 netlogo 프로그램에 문제가 있습니다. 코드는 다음과 같습니다.NetLogo 권한이 이상 함

globals[ 
growth-param 
money-size-ratio 

] 

turtles-own[ 
    location 
    tsize 
    bbalance 
] 

to setup 
    ca 
    reset-ticks 
    ask patches[set pcolor blue] 

    create-turtles initial-telemarketers [ 
    set size 1 
    set bbalance 0.0 
    setxy random-xcor random-ycor 
    set shape "circle" 
    ] 
    set growth-param 1000 
    set money-size-ratio 0.001 
end 

to go 
    ask patches[set pcolor blue] 
    sell 
    accounting 
    observer-updates 
    tick 
end 

to sell 

    let territory 10 * sqrt size 
    let maxcalls 100 * size 
    ask n-of maxcalls patches in-radius territory[ 
    if pcolor = blue [set pcolor black] 
    set bbalance bbalance + 2 
    ] 

end 

to accounting 
    let cost size * 50 
    ask turtles[ 
    set bbalance bbalance - cost 

    ifelse bbalance < 1 
    [die] 
    [set size bbalance * growth-param] 
    ] 

end 

to observer-updates 

end 

텔레 마케팅 회사가 얼마나 많은 사람이 상호 작용하는지 간단하게 모델링 한 모델입니다. 그것은 Railsback에서입니다 & 그림의 모델링 책.

실행할 때마다 볼 수있는 두 가지 문제점이 있습니다. 프로 시저를 판매 할 때 거북이 전용이므로 관찰자 컨텍스트에서만 새 값으로 설정하고 싶지 않습니다. .

도움 주셔서 감사합니다.

답변

0

sell은 거북이 프리미엄 (예 : sizein-radius을 사용하기 때문에)입니다. 그러나 go은 옵서버 절차입니다. 관찰자 절차에서 거북이 절차를 직접 호출 할 수는 없습니다. 당신은 그것을 실행할 거북을 지정해야합니다. go 안에는 sell 대신에 ask turtles [ sell ]을 써야 할 수도 있습니다.

+0

그래, 누구든지 이걸 시도하면 다른 것을 찾을 수 없으니 여기 내 전체 (일하는!) 코드입니다 : – user2221135

1
globals[ 

    money-size-ratio 

] 

turtles-own[ 
    location 
    tsize 
    bbalance 
    maxsize 
] 

to setup 
    ca 
    reset-ticks 
    ask patches[set pcolor blue] 

    create-turtles initial-telemarketers [ 
    set size 1 
    set bbalance 0.0 
    setxy random-xcor random-ycor 
    set shape "circle" 
    set maxsize 0 
    ] 

    set money-size-ratio 0.001 
end 

to go 

    ask patches[set pcolor blue] 
    ask turtles [sell] 
    ask turtles [accounting] ;; let's ask the turtles to do this 
    observer-updates 
    tick 

end 

to sell 
    let territory 10 * sqrt size 
    let maxcalls 100 * size 
    if maxcalls > 40401[ 
    set maxcalls 40401;keeps maxcalls within acceptable bounds 
    ] 
    let coun 0 
    ask n-of maxcalls patches in-radius territory[ 
    if pcolor = blue[ 
     set pcolor black 
     set coun coun + 2 
    ] 
    ] 
    set bbalance bbalance + coun 


end 

to accounting 
    let cost size * 50 ;; size is a turtle variable so if you want to access it this way, let's make the whole thing 
        ;; a turtle procedure. That's what was confusing Netlogo about the tick command 

    set bbalance bbalance - cost 

    if bbalance > growth-param 
    [set size size + (bbalance - growth-param) * money-size-ratio 
     set bbalance growth-param 
     ] 
    if size > maxsize[ 
     set maxsize size 
    ] 


    if bbalance <= 0 
    [show (word "dead. Maximum size: " maxsize) 
     die 

     ] 

    if size = 0 
    [show (word "dead. Maximum size: " maxsize) 
     die 

     ] 



end 

to observer-updates 

end