The Computational Beauty of Nature
Source code

termites

simulate a population of termites

Full screen →

termite -help
  or
termite
       [-width  integer]  [-height integer] [-num integer]
       [-dense double] [-steps  integer]  [-seed  integer]
       [-inv] [-mag integer] [-term string]

Simulates a population of termites which do a random walk while possibly carrying a wood chip. Under normal circumstances, the termites will self-organize and move the wood chips into piles without a global leader. The termites' behavior is dictated by the following set of rules: If a termite is not carrying anything and it bumps into a chip, then it picks it up, reverses direction, and continues with the random walk. If it is carrying a chip and bumps into another, it drops the chip, turns around, and starts walking again. Otherwise, it just does a random walk whether it is carrying a chip or not.

Simulate a population of termites which do a random walk while possibly carrying a wood chip. Under normal circumstances, the termites will self-organize and move the wood chips into piles without a global leader. The termites' behavior is dictated by the following set of rules: If a termite is not carrying anything and she bumps into a chip, then she picks it up, reverses direction, and continues with the random walk. If she is carrying a chip and bumps into another, she drops her chip, turns around, and starts walking again. Otherwise, she just does a random walk whether she is carrying a chip or not.

Miscellany

The walking pattern of the termites is not actually a strict random walk. Instead, at each time step they

randomly turn -45, 0, or 45 degrees with equal probability.

Bugs

No sanity checks are performed to make sure that any of the options make sense.

Options

-widthWidth of the plot in pixels.100
-heightHeight of the plot in pixels.100
-numNumber of termites in population.20
-denseDensity of chips at start.0.3
-stepsNumber of simulated steps.10000000
-seedRandom seed for initial state.0
-invInvert all colors?False
-magMagnification factor.2
-termHow to plot points.None

termites.c on GitHub