Langton's Ant

Simulate Langton's ant and its multi-color variants, directly in your browser.

This free online Langton's ant simulator runs one of the most famous cellular automata: an ant walks on a grid of white cells, turning right on a white cell and left on a black cell, and flipping the color of every cell it leaves. From that tiny rule comes a surprise: after about 10000 steps of chaos, the ant suddenly starts building a highway that goes on forever.

Try the multi-color ants, written as a string of turns like LLRR, LRRRRRLLR or RRLLLRLLLRRR, which grow symmetric shapes, squares and moving triangles. Add several ants, click on the grid to drop new ones, and watch them interact.

Customize the size of the grid, the speed and the colors, then download the result as a PNG image or record it as a video. Everything runs directly in your browser: nothing is uploaded to a server.

Examples
The rule
One letter for each color: "L" turns left, "R" turns right, "N" goes straight and "U" turns back.
Langton's original ant. For about 10000 steps it builds a chaotic blob, and then it suddenly starts to build a "highway": a pattern of 104 steps that repeats forever and travels diagonally.
The ants
Click on the grid to add a new ant, even while the animation is running.
The grid
Image size: 720 x 540 px
The animation
Step: 0
Visited cells: 0
The colors
The first color of the rule, the color of the cells never visited.
Download
Generate and download video
Step: 0Visited cells: 0Ants: 0Rule: RL
Click on the grid to add an ant.

How to simulate Langton's ant

  1. Choose the rule - Keep the original rule, RL, to watch the ant build its highway, or pick one of the multi-color rules. You can also type your own rule, or click "Random rule" to discover new ones.
  2. Choose the ants - Set the number of ants and where they start: all on the center cell, on a circle around the center, or at random positions. Click on the grid at any moment to drop a new ant.
  3. Set the size of the grid - Choose the number of columns and rows and the size of each cell. Turn off "Wrap the edges" if you want the ants to stop when they reach a border.
  4. Adjust the speed - Choose how many steps are computed per second, or turn on the maximum speed. Turn on "Pause after a number of steps" to stop at an exact step, like step 11000 to see the start of the highway.
  5. Customize the colors - Paint the cells with a rainbow or with a gradient between two colors, choose the background, and show or hide the ants.
  6. Download it - Save the current state as a PNG image, or open the "Generate and download video" section to record the animation as a video in WebM format.

What is Langton's ant?

Langton's ant is a two-dimensional cellular automaton invented by Chris Langton in 1986. It is a Turing machine with a two-dimensional tape: an "ant" sits on a grid of white cells, facing one of the four directions, and repeats the same three moves forever:

  1. On a white cell, the ant turns 90 degrees to the right; on a black cell, it turns 90 degrees to the left.
  2. It flips the color of the cell it is on, from white to black or from black to white.
  3. It moves forward one cell.

For the first few hundred steps, the ant draws simple, often symmetric shapes. Then it enters a long chaotic phase, and after about 10000 steps it starts to repeat a cycle of 104 steps that moves it two cells diagonally, building a "highway" that goes on forever. Every starting pattern ever tried ends up building the highway, but nobody has proven that it always happens.

Multi-color ants

The rule can be extended to more colors, as proposed by Greg Turk and Jim Propp. The rule is a string with one letter for each color: when the ant is on a cell of color n, it turns according to the letter n of the rule, and the cell changes to the next color, going back to the first color after the last one. The original ant is the rule RL. Rules made of pairs of the same letter, like LLRR, always grow symmetric patterns.

RuleDescription
RLLangton's original ant. For about 10000 steps it builds a chaotic blob, and then it suddenly starts to build a "highway": a pattern of 104 steps that repeats forever and travels diagonally.
RLRThree colors, and the ant grows a chaotic blob forever, without ever building a highway.
LLRRThe ant grows a symmetric shape that keeps growing forever, like a brain or a cauliflower.
RRLLThe mirror image of LLRR: swapping every L and R of a rule draws the mirror image of the pattern.
LRRRRRLLRThe ant fills the space around it with a square that keeps growing.
LLRRRLRLRLLRAfter a long chaotic phase, the ant builds a wide and convoluted highway.
RRLLLRLLLRRRThe ant builds a filled triangle that grows and moves across the grid.

Options

Below are all the options you can configure in this Langton's ant simulator.

FieldDescription
RuleOne letter for each color: "L" turns left, "R" turns right, "N" goes straight and "U" turns back. The number of letters is the number of colors, up to 32. Changing the rule starts the simulation again.
Number of antsHow many ants start on the grid. You can add more by clicking on the grid, up to 64 ants.
Position of the antsWhere the ants start: all on the center cell, each one turned 90 degrees from the previous one; evenly spaced on a circle around the center; or at random positions and directions.
Direction at the startThe direction the ant faces before its first step.
Initial gridAn empty grid, where every cell has the first color, or a grid of random colors.
SeedThe number used to generate the random colors and the random positions. The same seed always gives the same start.
Columns, rows and size of the cellThe size of the grid in cells, and the size of each cell in pixels. The image is the number of columns multiplied by the size of the cell, by the number of rows multiplied by the size of the cell.
Wrap the edges of the gridTurned on, an ant that leaves the grid comes back through the opposite border. Turned off, the ant stops when it reaches a border.
Steps per secondHow many steps each ant takes per second. The original ant needs about 10000 steps to start its highway.
Maximum speedComputes as many steps as possible on every frame, ignoring the steps per second.
Pause after a number of stepsPauses the animation automatically at the step you choose, which is useful to download the image of an exact step.
Colors of the cellsPaints the colors of the rule with a rainbow, or with a gradient between two colors. The first color of the rule is always the background color.
Show the antsDraws each ant as an arrow pointing in its direction, or as a small square when the cells are too small. The ants are also drawn in the downloaded image and in the video, so hide them if you want only the pattern.

Frequently Asked Questions (FAQ)

Is this Langton's ant simulator free?

Yes. The tool is completely free, there is no registration, and everything is computed by your own browser: nothing is uploaded to a server.

When does Langton's ant start building the highway?

Starting on an empty grid, the original ant (rule RL) starts its highway at around step 10000. Turn on "Pause after a number of steps" with 11000 steps to see the first part of the highway, or just watch it happen at 1000 steps per second.

Does the ant always build a highway?

Every starting pattern ever tested ends with the highway, but it has never been proven. What has been proven is that the ant never stays inside a limited area: its path is always unbounded.

What happens when the highway reaches the border?

With the edges wrapped, the highway comes back through the opposite border and eventually crashes into the old pattern, which starts a new chaotic phase, and usually a new highway later. With the edges not wrapped, the ant stops at the border.

What do the letters of the rule mean?

Each letter is the turn the ant makes on a cell of that color: "R" is a right turn, "L" a left turn, "N" no turn and "U" a U-turn. The first letter is used on the background color, the second on the next color, and so on.

Can I download the animation as a video?

Yes. Open the "Generate and download video" section, choose the framerate, click "Generate video", and click "Stop recording and download video" when you have enough. The video is recorded in the WebM format.

What is a turmite?

A turmite is a Langton's ant with an internal state, a small memory that changes on every step, so it can do different things on the same color. Langton's ant, and every multi-color ant of this tool, is a turmite with a single state. Try the Turmite tool to see what a second state adds: spirals, triangles, diamonds and many more.

Can I use the images and the videos commercially?

Yes. The images and videos you generate are yours, and you can use them in any project.

Related tools

Turmite

Simulate turmites, the two-dimensional Turing machines, and download images and videos.
Game of Life

Game of Life

Create Conway's Game of Life simulations and animations.
Elementary Cellular Automaton

Elementary Cellular Automaton

Draw the 256 elementary cellular automata, like Rule 30, Rule 90 and Rule 110.
Cyclic Cellular Automaton

Cyclic Cellular Automaton

Create the spiral waves of the cyclic cellular automaton, as images and videos.
Abelian Sandpile Generator

Abelian Sandpile Generator

Drop grains of sand on a grid and watch them topple into a fractal.

Turing Machine

Run Turing machines, like the busy beavers, and draw their whole computation as an image.
Huegene

Huegene

Create images and animations inspired by huegene cellular automata.
Turtle Graphics

Turtle Graphics

Easily create Turtle Graphics images and animations.