Index of /utilities/pascal/langton
Name Last modified Size Description
Parent Directory -
output/ 2007-10-09 19:04 -
COPYING 2002-10-05 13:47 18K
text.pas 2002-09-13 23:10 2.1K
scenarios.pas 2002-09-13 23:10 1.6K
langtonant.pas 2002-09-13 23:10 3.8K
graphical.pas 2002-09-13 23:09 2.9K
Langton's Ant
=============
This is a device independent pascal implementation of Langton's Ant, a
deterministic chaotic system with distinctive emergent behaviour.
The algorithm is simple. Start at an arbitrary origin on a infinite
grid of boolean tiles. Pick an arbitrary direction parallel one of the
two axes (up, right, down, left). Go one step in that direction. If
the new position is true, turn clockwise, else turn anticlockwise.
Move forward again and repeat.
This version makes one change to the original algorithm: instead of an
infinite grid, the plane has a defined boundary, beyond which the
tiles are all false and cannot be changed. (The boundary is
effectively reflective.)
There are two versions: text.pas and graphical.pas, which are text
mode and graphical mode implementations respectively. The graphical
one defines the boundary to be a circle with a radius one sixth of the
height of the viewport. The text version just uses the console's
dimensions as the boundary.
The Langton Ant code is actually implemented as a couple of classes in
langtonant.pas. The scenarios.pas file contains the loop which runs
the simulation. There is an example in that file showing how to run
two ants at once. (The results are unspectacular.)
To compile this code, the Free Pascal Compiler is recommended.
http://www.freepascal.org/
Some sample outputs are in the output/ directory.
Results
-------
Adding boundaries shows interesting additional effects arising from
the collision of the freeways with the immutable zone. The first
noticable effect occurs on the first interaction of the ant and the
boundary: the edge is highlighted. (Why this occurs is obvious if you
consider how the rules behave in the presence of an unchanging
region.) When the ant returns to the freeway which collided with the
boundary, a chaotic region forms (superficially similar to the which
occurs at the origin).
Freeways reliably form shortly after a chaotic knot forms, exiting in
an apparently arbitrary direction always at a pi/4 angle to the axes
(i.e. diagonally). When two freeways colide, the result is often a
very small chaotic region followed by the freeway being continued on
the opposite side, as if a bridge had been formed.
If a chaotic region forms near the boundary, the ant will often
progress in the same direction as the formation of the original edge
highlighting. The result is that with a circular boundary the
following features are seen to form:
1. A chaotic region.
2. A freeway.
3. An edge highlight after the freeway collides with the boundary.
4. Another chaotic region.
5. Freeways crossing the plane, with chaotic regions where they
meet.
6. A chaotic area around the edge of the plane, growing inwards
over time.
Eventually, the entire region is one chaotic region.