NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary

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

  Donate

NetLogo Models Library:
Code Examples

(back to the library)

Hex Cells 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 demonstrates how to make a model that uses a hexagonal grid of cells.

The cellular automaton rules used produce a snowflake-like pattern.

HOW IT WORKS

Since patches are square, we must represent the cells as turtles instead.

Each patch sprouts a "cell" turtle. 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 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 you don't try to use primitives such as distance and towards.

Also, you must use the hex-neighbors variable instead of the built-in neighbors and neighbors4 reporters.

RELATED MODELS

This example is for stationary cells. Hex Turtles Example shows how to make turtles that move along a hexagonal lattice. (It would also be possible to combine both techniques in a single model.)

Link Lattice Example and Lattice-Walking Turtles Example demonstrate another approach to making a hexagonal lattice, using links instead of just patches.

(back to the NetLogo Models Library)