Antics - Definable cellular automata

by Richard Taylor


Antics imagines an ant living on a plane of coloured square cells. The ant does nothing but move from square to square, painting certain cells according to the rules it has been given, yet it may leave the most extraordinary patterns behind it. This process, an example of a 'cellular automaton', is implemented by the application, allowing you to define the rules.

A good demonstration is given by the program default - Langton's ant. Starting on an all grey background, it has been given some very simple rules indeed. If it finds itself on a grey square it paints it blue and turns right; if it is on a blue square, it paints it grey and turns left. The result is remarkable. At first, it creates patterns which are somewhat symmetrical. It then begins to move in a more chaotic fashion, leaving behind a mess of grey and blue cells for some 10,000 steps, before it suddenly 'decides' to move off diagonally building a complex 'highway' as it goes.

The application is loaded in the usual manner. Double-click on Antics in the filer window and it will install itself on the icon bar. Pressing the Menu button on this icon produces the standard Info and Quit options while clicking Select displays the main window as well as the tools window.
This main window, which is not opened at full size, contains the grid of cells and the T-shaped 'ant' in the centre. When expanded the window shows the full 64x64 grid. Note that a wrap-around principle is in operation - for example, if the ant disappears off the top, it will reappear at the bottom. So in fact, highways moving off to 'infinity' will, after a while, crash into their own beginnings.

The tools window is divided into three sections. At the top, the current rules are displayed. An interpretation of these rules and an explanation of how you may define some new ones will be given in a moment.

Beneath this is the Control section of the window. It contains a step counter which may be turned off using the adjacent option icon in order to speed things up. The icon to the right of the counter shows the current action which is set by the 'video' style icons in the next row. The '<<' and '>>' icons move the ant backward and forward at the maximum possible speed while the '<' and '>' icons move it at around four steps per second. The '[' and ']' icons may be used to move the ant backward and forward by one step at a time, and the '-' icon is used to stop it. The Store and Restore icons can be used to keep a copy of the rules and the grid in memory. Clicking on Store will result in a beep to indicate that the store has successfully taken place. It is often useful to click on Store before you start the ant off, in case it doesn't do what you expected.

The last section of the window allows squares to be coloured before the ant starts. Click on the colour you require and your selection will be reflected in the long rectangular icon in the next row. Then simply fill in the squares on the grid as you would in Paint. The black coloured icon allows the ant to be placed, keep clicking in the square in which you have put it to turn it around. The Clear icon clears all the squares in the grid to the current colour, while clicking on the Random icon produces a random grid using all the colours up to and including the selected one.

Clicking Menu anywhere over the two windows brings up the main menu. The last entry allows the current situation to be saved to a file for later reloading, while the first two entries of the menu permit new rules to be entered. The Direction rule determines how the ant turns when it is on cells of a certain colour while the Colour rule determines the new colour that the ant should paint the square. Each rule can be up to (but does not have to be) eight digits long, one digit for each of the eight available colours. The first digit determines the action when the ant is on colour 0 (grey), the second digit is for colour 1 (blue) and so on. The digits in the Direction rule have the following meaning :
		0 - Turn left,
		1 - Turn right,
		2 - Turn around,
		3 - Go straight on,
		4 - Go West,
		5 - Go East,
		6 - Go South,
		7 - Go North.
(A dash ('-') may also be used for 'Go straight on'.)

In the Colour rule the digits unsurprisingly refer to the new colour that the
square should be painted as the ant leaves it. (This time a dash can be used to indicate that the colour should remain unchanged.) An example should make all this clear. A Direction rule of '0213' tells the ant to turn left when it is colour 0, to turn around when on colour 1, to turn right when on colour 2 and to carry straight on when on colour 3. A Colour rule of '1230' means that colour 0 squares will be painted colour 1, colour 1 squares changed to colour 2 and so on, so that the first four colours are cycled round. Incidentally, the above rules give rise to what appears to be completely chaotic behaviour.

The rules you have entered will be interpreted by the computer and it will decide if they are reversible - in other words, whether under these rules, the current pattern of squares and the direction of the ant always determines the past as well as the future. The result is displayed in the Rules section of the tools window. If you have used an absolute direction change such as 'Go North' rather than relative ones such as 'Turn left' then it is impossible to know where the ant has come from and so it cannot retrace its steps.  Similarly if two or more colours are defined to change to the same colour then there is no way of knowing which one to change it back to if the ant were to attempt to move backwards. Thus the 'rewind' icons become unusable if non-reversible rules are entered.

With a little bit of experiment, numerous different and intriguing ants can be created. When the application is run, it will automatically open the examples directory, these can be dragged onto the Antics icon on the icon bar. Brief descriptions of these examples are given below - if you look at their rules it should be easy to see how they work.

Base3
A counter in base 3. (The only valid digits in base 3 are 0, 1 and 2 instead of 0 to 9 in the decimal system. Thus  0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 become 0, 1, 2, 10, 11, 12, 20, 21, 22 and 100 respectively.) Here, the digit 0 is  represented by the colour grey, the digit 1 by blue and the digit 2 by cyan.

Binary
A binary (base 2) counter displayed in a different manner to the base 3 counter.

Chaos2Col
This ant leaves behind chaotic patterns in two colours.

Chaos5Col
Five colour chaotic behaviour using 'Go straight on' and 'Turn around' direction changes as well as 'Turn left' and 'Turn right'.

ChaosNoRev
A chaotic example of non-reversible rules. For this ant, time only goes forwards and not backwards.

Highway
A simple set of rules that produces a smaller highway than Langton's Ant and moreover, does so almost immediately. Try scattering a few (blue and cyan) coloured sqaures about its starting position.  After a while, it appears always to create a similar highway.

Highway2
Seven colour chaos, followed by a different style highway.

Langtons
The rules for the default Langton's ant.

Langtons2
This non-reversible version of Langton's ant shows which squares have and have not been visited making it easier to follow.

Message
Starting at step -1000 (minus one thousand) this seemingly random configuration gradually takes on a recognisable shape.   Stop it when it reaches step 0. This ant is also using Langton's rules and soon builds a highway if allowed to continue past step 0.

Repeat276
This ant produces small-scale patterns which repeat every 276 steps.

SixToTwo
A random grid of six colours is slowly converted to a random grid of two colours.

StartLine
This is Langton's ant but this time it starts with a line of blue squares already in place.   At first it runs up and down this line, before moving off.   It too soon builds a highway.

Step10000
The configuration at the 10,000th step (see above) of the original Langton's ant just before it starts to build its highway.

Stripe
A non-reversible set of rules which generate differently patterned stripes as the ant goes over the same ground.

SymmBinary
Very simple rules creating a vertical binary counter (see above) and its mirror image beneath it.

Symmetry
This ant creates ever expanding symmetrically coloured patterns.

Track
A demonstration of the program's flexibility.   The ant follows a track around the screen turning left and right, reversing and passing through sets of 'railway points' which send it alternately left and then right when they are entered.

TurnsToRed
Starting from a random configuration this ant creates an attractive 'contoured' rainbow effect around larger and larger patches of red.

Some of the ideas for this program came from an article in the July 1994 issue of the Scientific American.   It discusses the seemingly inevitable highways and the reversibility of Langton's ant as well as its philisophical overtones - that simple rules can lead to unpredictable behaviour in the long-term. The rules define everything about the system yet in some sense they tell us almost nothing.

To run the program click on the icon in the RISC User menu system.


 Copyright RISC User 1995