J
jimmyfo
Guest
Hi all, I don't know if anyone is familiar with the AI program called Netlogo, but I need some help if possible. I'm trying to write some code where patches cannot exist in 'tight spaces' i.e. - the patches cannot be created within one space of each other or the walls, but they can be within two or more spaces. Here is the code I have for creating the patches at random (the commented out part should work and would solve this, but for some reason does not).
Thanks for any help
-james
to set-block
ask patches with [ (abs(pxcor) = screen-edge-x) or (abs(pycor) = screen-edge-y) ]
[set pcolor green]
repeat num-of-block
[
ask random-one-of patches with [ pcolor != green and pcolor != brown ]
[
;; if ( pcolor-of (pxcor + 2) != green )
;; [
set pcolor brown
;; ]
]
]
end
Another slice that won't work -
repeat num-of-block
[
ask random-one-of patches with [ pcolor != green and pcolor != brown and pcolor-of (abs(pxcor) + 2) != green ]
[
set pcolor brown
]
]
Thanks for any help
-james
to set-block
ask patches with [ (abs(pxcor) = screen-edge-x) or (abs(pycor) = screen-edge-y) ]
[set pcolor green]
repeat num-of-block
[
ask random-one-of patches with [ pcolor != green and pcolor != brown ]
[
;; if ( pcolor-of (pxcor + 2) != green )
;; [
set pcolor brown
;; ]
]
]
end
Another slice that won't work -
repeat num-of-block
[
ask random-one-of patches with [ pcolor != green and pcolor != brown and pcolor-of (abs(pxcor) + 2) != green ]
[
set pcolor brown
]
]


