Find Valid Patch

How do we get an agent to be spread out but avoid a certain area in Spaceland?


find-valid-patch This procedure uses a trick called recursion. It tries to set a turtle down on a random patch but if this patch is not green, it calls itself to try again. A procedure that calls itself is called a recursive procedure.
The same idea can be used in other ways. You could change the if statement to check for other agents on the same patch, for example. This procedure then gets put on the Setup block.

Submitted by joshua on 27. December 2007 - 17:21