Background
Welcome to this simple implementation of an elegant idea. Langton's Ant was created by Chris Langton in 1986, and is an example of a cellular automaton.
Under Langton's original design, the "ant" begins its journey on a grid with squares that are colored white or black. It follows two simple rules:
- If the square is white, the ant turns 90° right, changes the square to black, and moves forward 1 unit.
- If the square is black, the ant turns 90° left, changes the square to white, and moves forward 1 unit.
Some really interesting mathematical things can be shown and observed about Langton's Ant. Read more
here.
Generalizations
This engine has incorporated two generalizations that Langton's original does not include.
- Multiple colors: the engine can use up to 8 different color states. These colors are stored as a list, and the ant loops through the list to decide which color it will change its current square to.
- Multiple ants: the engine can accommodate an arbitrarily large number of ants. If two ants end up on the same square, they make their changes and turns in the order they were created.
Using This Engine
The controls for this engine are straightforward.
- Start sets off the ant's movement. If you've added ants, the engine will use these. If you've added none, it will add one ant in the middle of the grid.
- Clicking places a new ant in that location.
- Stop pauses the ant movement.
- Step sets off one iteration of ant movement.
- Reset clears the board of all ants, and sets all squares back to their original state.