2016-05-14 64 views
0

在的NetLogo我有3個方面減少不同:設置龜能在不同的領域

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] 

但這不起作用。

回答

1

嘗試:

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] 

]