Home
Help
Forum
Resources
Extensions
FAQ
NetLogo Publications
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

Hex Turtles Example

 If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web

WHAT IS IT?

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.

HOW IT WORKS

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 `hex-fd` 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 `hex-fd` procedure, and as long as you don't try to use primitives such as `distance` and `towards`.

RELATED MODELS

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.)