开发者

How to write a basic NetLogo `if` statement for patch colors

I am trying to apply the following condition:

if ( the color of patch -2 -1 is red ) [ some commands ]

Could someone pl开发者_JAVA技巧ease tell me how to write this in NetLogo?


If you mean the patch at coordinates (-2 1) then its:

ask (patch -2 1) with [pcolor = red] [commands]

or

ask (patch -2 1) [ if (pcolor = red) [commands]]


You could do it with a with to get the agentset like Jose M Vidal has suggested.

1) Using AgentSet

ask patches with [pcolor = black]  [ commands here ]

2) If you want to use an if condition specifically, write it as such:

ask patches [ if [pcolor] of self = black  [ commands here ] ]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜