HexaBugs

By Liviu Panait

HexaBugs is a variation of HeatBugs on a hexagonal grid, an idea largely inspired by Hexabugs on the Repast toolkit. By default the grid cells are drawn as elongated rectangles; if you want to draw them as true hexagons (slower), there's an option for that under the Model tab. Like HeatBugs, HexaBugs has a hand-optimized diffuser (HexaDiffuser.java) and a multithreaded version (ThreadedHexaDiffuser.java), plus a tutorial about different levels of optimization.

You might compare to plain HeatBugs. Or try 3D HeatBugs: HeatBugs in 2D but cast in 3D space.


From the HeatBugs console documentation: HeatBugs is a model originally developed on the Swarm toolkit. The environment is a toroidal 100x100 grid of "heat", populated with 100 "bugs" with built-in heaters which heat up their environment. The bugs prefer it to be not too warm and not too cold (the range differs from bug to bug), and will follow the gradient towards regions more to their liking. The heat diffuses and evaporates at the provided rate. We have set up various model parameters you might like to play with.

HeatBugs spends the large majority of its computer time in the diffusion of heat. Our version of HeatBugs optimizes this in two ways:

  1. We've hand-optimized it carefully. In the body of the Diffuser.java we have a step-by-step tutorial showing optimization after optimization.
  2. We have a special version of Diffuser.java, called ThreadedDiffuser.java, which takes advantage of dual-processor machines to break the diffusion work up among two processors. If you have more than two processors, ThreadedDiffuser.java can be modified with some elbow grease to take advantage of them as well.