您好我需要NetLogo变量设置方面的帮助。
我的海龟拥有值范围的属性,即最小值和最大值。
turtles-own [weight history state-turtles run-duration ek tt cu sp]
to setup-turtles
create- NMAs 2 [
set ek 8 ; range 8 to 9
set tt 5 ;range 5 to 7
set cu 3 ; range 3 to 5
set sp 4 ; range 4 to 7
]
create- NBSs 2 [
set ek 3 ; range 3 to 5
set tt 4 ; range 4 to 7
set cu 3 ; range 3 to 4
set sp 3 ; range 3 to 6
]
to setup-patches
ask patches [ let projects random 4
;setup colours
]
End
to go
tick
ask turtles [
......
]
search-patch
if .....
]
End
to search-patch
if ( [ pcolor ] of patch-here = brown ) [
ifelse (;statement) [
update-turtles
] [
action-turtles
]
]
end
to update-turtles
if pcolor = yellow [
set ek ek + 0.1
set tt tt + 0.5
set cu cu + 0.1
set sp sp + 1 ]
if pcolor = green [
set ek ......
数字不断增加,我想设置每个属性的设置海龟所示的限制(范围)谢谢
答案 0 :(得分:0)
turtles-own [... ek-max tt-max cu-max sp-max ...]
to setup
...
create-NMAs 2 [
set ek 8
set ek-max 9
...
]
...
end
to update-turtles
...
if ek + 0.1 <= ek-max [ set ek ek + 0.1 ]
if tt + 0.5 <= tt-max [ set tt tt + 0.5 ]
if cu + 0.1 <= cu-max [ set cu cu + 0.1 ]
if sp + 1 <= sp-max [ set sp sp + 1 ]
...
end
作为旁注,tick
应该在go
程序的最后,而不是在开头(reference)。