Beginners Interactive NetLogo Dictionary (BIND)
Farsi / Persian
NetLogo Models Library:
This example shows how to make turtles climb hills -- or descend into valleys -- using the
downhill4 commands. The same technique is useful for modeling any kind of creature that follows a gradient in its environment.
These commands always make the turtle move to the center of a patch.
downhill make the turtle look at all eight neighboring patches (including diagonal neighbors).
downhill4 only look at the four neighboring patches (to the north, south, east, and west).
downhill commands, diagonal moves are longer (1.414...) than vertical or horizontal moves (1.0). If you use the
downhill4 commands, all moves are the same length (1.0).
If there is a tie between neighboring patches, NetLogo breaks the tie randomly.
go procedure in the Code tab, change
downhill4 and observe the results.
If you look at the entry for
uphill in the NetLogo Dictionary, it shows some code that does the exact same thing as the primitive does. If you need to do something that is similar to the primitive, but different in so way, you could use that code as a starting point.