What is it

This model demonstrates how to implement a hexagonal grid using Xholon. The game begins with a number of creatures in the upper left corner. At each time step they can move to any adjacent blue hexagon.

How to use it

Run it:

  1. Run the Java application through the Xhn GUI (org.primordion.xholon.app.Xhn.java), and select File --> Open --> GridSamples --> Hex_xhn.xml.
  2. A grid viewer and tree viewer will appear. The grid viewer will display a random initial pattern.
  3. Expand the Controller node in the tree viewer.
  4. Press the Start node.

Pause and Step the model:

  1. Press Pause to pause and resume the executing model. Press Step to advance the paused model by one time step. Press Start to resume the paused model.

Things to notice

The grid is a toroidal structure so the creatures are free to go out one side and come back in the opposite side.

Things to try

Create a grid of square cells by editing Hex_ClassDetails. In (config instruction="Ght"/> change the 'h' to a 'v'. The 'h' signifies 'haxagonal' where each cell has 6 neighbors, while 'v' stands for 'Von Neumann' neighborhood where each cell has 4 neighbors.

Change the number of creatures in the game by editing Hex_CompositeStructureHierarchy (Creature multiplicity="200"/>).

Change any of the colours presented by editing GridPanelHex.java in src/org.primordion.xholon.samples.

There are two things you can do to make the model run dramatically faster. (1) In the Hex_xhn.xml file, change TimeStepInterval from "10" to "0". This will prevent the model from sleeping for 10 milliseconds at the end of each time step. (2) In the Xholon GUI, press View --> gridViewer. This will temporarily display the graphics. Press this node again to re-enable the graphics.

You can also change the size of the grid in Hex_CompositeStructureHierarchy.

  1. In line 8: edit HexGridCell multiplicity="49" roleName="gridcell"> to, for example, 100.
  2. In line 12: set HexRow multiplicity="49" roleName="row"> to the same number
  3. In line 13: set HexGridCell multiplicity="50" roleName="gridcell"> to that same number PLUS ONE.