Langton's ant is a mathematical simulation which follows a very simple set of rules but which demonstrates complex emergent behavior.
It consists of a 2D grid of squares which can be colored either black or white. An ant travels over this grid of squares, and on each move, it moves one step, either up, down, left or right. Each time it lands on a new square, the ant rotates the direction it is facing, either 90 degrees to the right, if the square is white, or 90 degrees to the left, if the square is black. On the next move, the ant will take one step forwards in whichever direction it is facing. Additionally, the ant inverts the color of each square it lands on.
Using the controls above, click the play button to start the ant on its journey. You can use the speed control to adjust how quickly it moves. At any time, you can click on a square to flip its color. Alternatively, use the scrollwheel, or a pinch gesture on a touchscreen device, to zoom the simulation in or out.
Despite the simple rules of the game, the ant will soon show quite complicated behavior patterns. Typically it behaves in three different ways in turn.
For the first few hundred steps, the ant will typically follow quite simple movements, creating geometric patterns around its starting point.
Then, for around 10,000 steps, the ant's behavior will typically become more disordered, becoming seemingly random.
Then, typically after around 11,000 steps, starts building a recurrent "highway" pattern of 104 steps that repeats indefinitely.