Home Download Help Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo Models Library: 
If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web 
This demonstrates how to have turtles move on a hexagonal lattice instead of NetLogo's usual square lattice.
Note that this technique only works as long as the turtles always stay on the vertices of the lattice.
We treat the square lattice of patches as if it were a hex lattice, as follows:
A turtle's heading must always be a multiple of 60.
Turtles on even patch columns are offset down by half a patch. (Since the south boundary of a patch is part of the patch, this does not move the turtle to a different patch.)
The world must be an even size grid otherwise a bit of extra math in the hexfd
procedure is needed to deal with two even or two odd columns in a row around the edges (if wrapping is turned on).
The resulting lattice has the correct structure, but distances and angles are distorted. So the hexagons aren't actually regular, but it doesn't matter as long as the turtles move not using the built in fd
command but using the hexfd
procedure, and as long as you don't try to use primitives such as distance
and towards
.
This example is for moving turtles. Hex Cells Example shows how to make stationary hexagonal cells, such as for a cellular automaton. (It would also be possible to combine both techniques in a single model.)
(back to the NetLogo Models Library)