Langton’s Ant

Run Langton’s ant and print what it builds: on a white cell the ant turns right, on a black cell it turns left, then it flips the cell and moves forward one cell. After a few hundred steps of simple shapes and about ten thousand of disorder, the ant starts building a highway; the tool finds it by itself: from step 9,978 the moves repeat every 104 steps, 2 cells across and 2 down each time. Type any rule of 2 to 12 letters L and R for ants with more colours (RLR, LLRR, LRRRRRLLR …), choose an open plane or a wrap-around grid, the start direction and the colours, and mark where the ant ends. Download a PDF, a 300 DPI PNG or an SVG with every cell as an exact rectangle. Nothing is uploaded.

100% private — everything runs in your browser. Everything runs in your browser; nothing is uploaded.

100% private — runs in your browser

Print at 100% (Actual size). Real size prints on one sheet when the drawing fits; the check bar in the footer lets you confirm the scale. The SVG holds the drawing at the printed size.

Ant

Page

Runs in your browser with our own code: nothing you type is uploaded or saved. Every step of the ant and the highway check are worked out by our own code. You may use what you make here, including commercially, with no credit needed.

How to run and print Langton’s ant

  1. Pick a preset, or type a rule such as RL (Langton’s ant) or RLR.
  2. Set the number of steps and choose an open plane or a wrap-around grid.
  3. Choose the start direction, the colours and whether to mark the ant.
  4. Check the highway line under the preview, choose Fitted to one page or Real size and the paper.
  5. Download the PDF and print at 100% (Actual size), or the PNG or SVG.

What you can use it for

  • Maths and computing lessons on simple rules with complex results
  • Step-by-step worksheets of the first moves
  • Posters of the highway and multi-colour ants
  • Plotter, laser and vinyl art from the SVG
  • Pixel and cross-stitch charts
  • Trying your own rule strings

The 14 presets

PresetRuleStepsGridColoured cellsHighway found by the tool
Langton’s ant (RL), 11,000 steps: the highway has startedRL11,000open plane834from step 9,978, every 104 steps, 2 cells left and 2 cells down
RL, first 500 stepsRL500open plane62none found
RL, 9,000 steps (before the highway)RL9,000open plane632none found
RL, 20,000 steps: a long highwayRL20,000open plane1,872from step 9,978, every 104 steps, 2 cells left and 2 cells down
Worksheet: RL, first 12 steps on a 6 × 6 grid, real size 12 mm cellsRL126 × 6 wrap8not checked on a wrap-around grid
RL on an 80 × 80 wrap-around grid, 30,000 stepsRL30,00080 × 80 wrap2,012not checked on a wrap-around grid
RLR (3 colours), 20,000 stepsRLR20,000open plane1,285none found
LLRR (4 colours), 20,000 stepsLLRR20,000open plane433none found
RLLR (4 colours), 20,000 stepsRLLR20,000open plane1,572none found
LRRRRRLLR (9 colours), 30,000 stepsLRRRRRLLR30,000open plane2,201none found
LLRRRLRLRLLR (12 colours), 30,000 stepsLLRRRLRLRLLR30,000open plane1,533none found
RRLLLRLLLRRR (12 colours), 30,000 stepsRRLLLRLLLRRR30,000open plane2,042none found
LR (the mirror image of RL), 11,000 stepsLR11,000open plane834from step 9,978, every 104 steps, 2 cells right and 2 cells down
RLR on a 200 × 200 wrap-around grid, 200,000 stepsRLR200,000200 × 200 wrap5,932not checked on a wrap-around grid

Every count is worked out by the tool from the cells it draws.

The first 10 steps of RL

StepCell the ant is onTurnMovesEnds at (x right, y down)
1whiterightright(1, 0)
2whiterightdown(1, 1)
3whiterightleft(0, 1)
4whiterightup(0, 0)
5blackleftleft(−1, 0)
6whiterightup(−1, −1)
7whiterightright(0, −1)
8whiterightdown(0, 0)
9whiterightleft(−1, 0)
10blackleftdown(−1, 1)

The ant starts at (0, 0) facing up on an all-white grid.

When the highway starts

Steps run (RL)Highway from stepRepeats everyEach repeat movesFull repeats in the run
9,000not yet–––
9,977not yet–––
10,500not yet–––
11,0009,9781042 cells left and 2 cells down9
15,0009,9781042 cells left and 2 cells down48
20,0009,9781042 cells left and 2 cells down96
30,0009,9781042 cells left and 2 cells down192

The tool looks for the shortest repeat in the colours the ant reads at the end of the run, then walks back to the first step where it holds. A repeat is only counted once it has lasted at least six times its length and at least 500 steps, which is why 10,500 steps is still “not yet”.

Multi-colour rules, 20,000 steps

RuleColoursColoured cellsArea visited (cells)Highway found
RL21,872241 × 211yes, from step 9,978 (every 104)
LR21,872241 × 211yes, from step 9,978 (every 104)
RLR31,28574 × 40no
LLRR443325 × 32no
RLLR41,57242 × 46no
LRRRRRLLR91,32838 × 38no
LLRRRLRLRLLR121,24552 × 42no
RRLLLRLLLRRR121,44154 × 64no

“No” means no repeat was found within these 20,000 steps; it says nothing about later steps.

What prints

DownloadWhat is in it
PDFThe cells fitted to one page or at real size, vector, with the step count, the highway line and a check bar
PNG 300 DPIThe same sheet as a picture
SVGThe cells at the printed size as exact rectangles, one path per colour, with the ant ring and grid lines if shown

For a cutter that needs DXF, use SVG to DXF.

Which tool to use

You wantUse
An ant that turns on coloured cells, the highway, rule stringsLangton’s Ant (this page)
Cells that live and die by their neighboursConway’s Game of Life
Pixels you place by handPixel Art Maker
Mandelbrot, Julia and line fractalsFractal Generator
Square grids to draw onGraph Paper

Other tools: the Pixel Art Maker lets you draw cells by hand, the Fractal Generator renders fractals and Graph Paper prints grids.

More free tools

Grids, patterns and printables?

Drawing and print tools that run privately in your browser, with no sign-up and no watermark.

See all free tools →

Frequently asked questions

What is Langton’s ant?

A very simple machine on a grid of black and white cells, invented by Chris Langton in 1986 (Physica D, volume 22). An ant sits on one cell and moves by two rules, and those rules alone build a surprisingly complex picture.

What are the rules?

On a white cell the ant turns 90° right (clockwise), on a black cell it turns 90° left, then it flips the colour of the cell it is on and moves forward one cell. Every cell starts white and the ant starts facing up. Our tests check the first 10 moves against a list worked out by hand, and every step against a separate walker of our own.

What is the highway?

Starting on an all-white grid, the ant makes simple, often symmetric shapes for a few hundred steps, then an irregular blob, and then it starts a highway: the same 104 moves over and over, each time 2 cells further along a diagonal. The Langton’s ant article on Wikipedia gives the disorder as lasting until step 9,977. The tool does not assume this: it checks the colours the ant reads and finds that they repeat every 104 steps from step 9,978 to the end of the run.

Does every start end in a highway?

Not known. The source notes that every finite start tried so far ends in the same highway, but that nobody has proved it for every start. This tool only reports what it finds in the steps you ask for.

What do the letters in RLR or LLRR mean?

They are the multi-colour extension studied by Greg Turk and Jim Propp: one letter per colour, R to turn right and L to turn left on that colour, and the cell moves on to the next colour each visit. Langton’s ant is RL in this naming. The tool accepts any rule of 2 to 12 letters and checks every turn against the letter of the colour the ant reads.

Why does LR look like RL in a mirror?

LR turns left where RL turns right, so it draws the mirror image of RL, cell for cell, as our tests confirm.

What is the wrap-around grid?

A grid whose left edge joins the right edge and top joins the bottom, so the ant never leaves it. The highway cannot run forever there: it comes back round and crashes into its own track. On the open plane the ant can go up to 30,000 steps; on a wrap-around grid of up to 200 × 200 cells, up to 200,000 steps.

How big can it go?

30,000 steps on the open plane and 200,000 on a wrap-around grid; every preset draws in under 2 seconds in our tests. The open plane is 2,048 cells across, and the run stops with a message if the ant reaches its edge.

Can it print at real size?

Yes, when the drawing fits on one sheet: choose Real size and set the cell size. Every printed cell is within 0.2 mm of its true place and size in our tests, on US Letter and A4, as long as you print at 100% (Actual size); the check bar in the footer lets you confirm the scale. Bigger drawings print fitted to the page.

Is it free?

Yes. There is no sign-up, no watermark and no limit.

Is anything uploaded?

No. Every generation, step and cell is worked out by JavaScript in your browser. Nothing you type or paste is sent anywhere or saved when you close the page.