在NetLogo中,我有三个区域:
to setup-patches
ask patches [ if pxcor > 6
[set pcolor yellow
]
]
ask patches [ if pxcor <= 6
[set pcolor green
]
]
ask patches [ if pxcor < -6
[set pcolor blue
]
]
end
我希望我的3种不同种类的海龟中有2种在其中一个区域(例如ycor > 6
)活动时更快地失去能量。
set energy energy - 1 [ -6 if xcor <= 6]
但这并不奏效。
尝试:
ask patches with [pxcor > 6] [set pcolor yellow]
ask patches with [pxcor <= 6] [set pcolor green]
ask patches with [pxcolor < -6] [set pcolor blue]
那么,如果能量是乌龟的变量。
ask turtles
[
if yellow = pcolor [set energy energy - 1]
if green = pcolor [set energy energy - 2]
if blue = pcolor [set energy energy - 3]
]