NetLogo banner

Home
Download
Help
Forum
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

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

  Donate

NetLogo Models Library:
Code Examples

(back to the library)

Lattice-Walking Turtles Example

[screen shot]

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

WHAT IS IT?

This example demonstrates how to create a hexagonal grid for turtles to walk around on using links.

HOW IT WORKS

In order for the hexagons along the edges of the world to connect up with the hexagons on the opposite edges in the expected way, the size of the grid must be even in both dimensions. Therefore we use a world where the origin patch (0,0) is located in the corner rather in the center, since even-dimensioned worlds have no center patch.

THINGS TO TRY

If you do:

  ask walkers [ pen-down ]

Notice that the lines the walkers draw appear behind the hexagons, because the hexagons are turtles. If you want the lines to be drawn on top of the hexagons, you need to transfer the hexagons to the drawing layer and hide the hexagon turtles, like this:

  ask nodes [ stamp  hide-turtle ]

On the computers we tested, this also makes the model run faster since the hexagons don't need to be redrawn individually every time the view is updated. Later, if you want to clear the drawing and redraw the hexagons, do:

  clear-drawing  ask nodes [ stamp ]

RELATED MODELS

Link-Walking Turtles Example

(back to the NetLogo Models Library)