Langton's ant

Tik-76.402 Datateknik B
Janne Blomqvist

1. Introduction

This is an applet for the cellular automata "Langton's Ant". The original Langton ant moves about a two-dimensional grid where the fields are either white or black. If the ant arrives at a black grid square it changes the color of the square to white and turns to the right. respectively, if the ant arrives at a white grid square it changes the color of the square to black and turns to the left.
However, this version of Langton's ant is a tad more complicated than that. It allows for colors (16 at the moment, but it can easily be modified) and multiple ants. Each ant is programmable, in the beginning each ant has got a randomized program, and it is possible to reprogram the ant at runtime. The program of the ant consists of two instructions for each color. One tells the ant which color to change to, and the other one tells the ant in which direction it should continue.

2. User's guide

The applet is almost quite self-explanatory. It has got three parts, the top panel, the central canvas where the ants move about and the bottom panel.

2.1 The top panel

The top panel contains three buttons, Resume, Pause and Randomize. Of theese three Randomize is clearly the most important, since the entire simulation is started by clicking on it. As you probably can guess, the other two buttons are for pausing and resuming the simulation, respectively.

2.2 The central canvas

This is the place where all the action takes place. You can't really do anything here, except admire the ants move around. Frenetic mouseclicking in the canvas will do you no good, except maybe crash your browser, or the entire computer if you're running Windows(tm).

2.3 The bottom panel

This is the most cryptic part of the user interface, so read carefully! The bottom panel consists of two rows of gizmos. Let's start the description by beginning from the upper left gizmo called "New Ant". This gizmo is in fact a Choice, or a pulldown menu. It allows you to choose an ant and also to add a new ant. Note that if the simulation hasn't been started, the only choice available is "New Ant". If the simulation has been started, the additional choices are "Ant i", where i is an integer. Also note that if you start the simulation by choosing "New Ant" you can no longer get additional ants by pressing the randomize button. Let's call the selected item in this menu the currently selected ant. To the right of the ant choice there is another pulldown menu, before you touch it titlet "Color 0". This choice contains all the colors, numbered from 0 to 15 at the moment. With this pulldown menu you choose what part of the program of the selected ant you want to look at. Let's call it the currently selected color. To the right of this choice the are two labels, one contains the text "Change to color" and the other one "Heading". Theese two show you the currently selected ants instructions for the selected color. To the right of these there is an additional pulldown menu, titled "Color0". This is used for changing the color the current ant changes the currently selected color to. To the left on the lower row there is a pulldown menu titled "FORWARD". It is used for changing the heading the current ant changes to when encountering the currently selected color. To the right of this menu there are two textfields. They are used if you wish to manually edit the color of the canvas. Type in the x-coordinate in the left textfield and the y-coordinate in the right textfield, choose the new color from the pulldown menu labeled "GridColor 0". Remember that the grid is 150*150 squares, so you must input values between 0 and 149.