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 ] ]
精彩评论