Conway's Game of Life, animated in ASCII

Conway's Game of Life on a wrapping board, cells coloured by age, starting a fresh random board every 45 seconds, or sooner if it stalls.

Algorithms96×3612 fps3.2 KB
Look

Use it Docs

Paste two lines into any page, use it from React, play it in a terminal, put a GIF in a README, or hand the Agent prompt to your coding agent. Every tab follows the look you pick above.

<script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script>

<ascii-art piece="game-of-life"></ascii-art>

Export

Pause on the frame you like, pick a look, then download it at an exact size.

Share

← Signup FunnelGanesh Utsav Procession →

Conway's Game of Life is a grid of cells that are born, survive and die by four simple rules, and this piece plays it nonstop in colored text characters. Mathematician John Conway devised it in 1970 as a zero-player game: you set the first generation, then simply watch. Here a random soup of cells boils, collides and cools into blocks, blinkers and gliders, and the board starts fresh before it can go stale.

It is built to be used as well as watched. Put this Game of Life animation on a web page with one tag, run it inside a React app, play it in a terminal, or export it as a GIF, a video or a 4K wallpaper. Below you will find the rules in plain language, the classic patterns to look for, and exactly how this version is drawn, so it doubles as a teaching aid.

Conway's Game of Life rules and classic patterns

The Game of Life is a cellular automaton: a grid where every cell is either alive or dead, and every cell updates at the same moment, one generation at a time. Each cell looks only at its eight neighbors, the cells touching its sides and corners. Programmers shorten the rules to B3/S23: born with three, survives with two or three.

Spelled out, the four rules are short. A live cell with fewer than two live neighbors dies, as if from loneliness. A live cell with two or three live neighbors lives on. A live cell with more than three live neighbors dies, as if from overcrowding. A dead cell with exactly three live neighbors becomes alive. Apply all four to every cell at once, and the next generation appears.

Those rules produce a zoo of shapes that turn up again and again. These are the classic Game of Life patterns, and the first five appear all the time on a random board like this one:

  • Block: a 2 by 2 square. Every cell has exactly three neighbors, so it never changes. It is the most common still life.
  • Beehive: six cells in a stretched hexagon, another still life that sits unchanged forever.
  • Blinker: three cells in a row that flip between horizontal and vertical every generation, the simplest oscillator.
  • Toad: two offset rows of three cells that pulse in and out, repeating every two generations.
  • Glider: five cells that rebuild themselves one cell further along a diagonal every four generations, the smallest spaceship.
  • Lightweight spaceship: a nine-cell ship that travels in a straight line rather than diagonally.
  • R-pentomino: just five cells that churn for 1,103 generations before they finally settle.
  • Glider gun: a machine that fires a new glider every 30 generations, which proved that a finite pattern can grow without limit.

What this ASCII Game of Life shows, and how it is drawn

The board is 96 columns by 72 rows of cells, 6,912 in all, shown in a frame of 96 by 36 characters. Each character holds two cells stacked on top of each other: a full block when both are alive, an upper or lower half block when only one is. Text characters are about twice as tall as they are wide, so this keeps the cells close to square and doubles the detail.

The edges wrap. A cell on the left edge counts the cells on the right edge as neighbors, and the top row touches the bottom row, so a glider that drifts off one side comes back on the other. The board runs at 12 generations per second, one per frame, starting from a random soup in which roughly 32 percent of the cells are alive.

Color shows age, and that makes the patterns easy to read. A block survives every generation, so it slides through blue and indigo into deep violet within about five seconds. A blinker keeps its middle cell but rebuilds its two ends each generation, so it flashes bright. No glider cell survives more than three generations, so gliders streak across the board in cream, yellow and green.

Dead cells leave a short trail: a medium shade for two generations after a cell dies, a light shade for four more, then the faint dotted grid of the empty board. Every 45 seconds the board starts over from a new random soup, and it reseeds sooner if the population count stays exactly the same for 40 generations in a row or drops below 25 live cells.

The age ladder, from newborn to oldest, runs like this:

  • Newborn: pale cream, in the generation the cell is born.
  • Survived 1 to 2 generations: yellow.
  • Survived 3 to 5: green.
  • Survived 6 to 11: teal.
  • Survived 12 to 24: blue.
  • Survived 25 to 59: indigo.
  • Survived 60 or more: deep violet, the color of settled still lifes.

How to use this Game of Life animation

Everything you need is on this page, in the code tabs and the export panel. The player can pause, run at half or double speed, change size and switch between dark and light. Copy as text grabs the current frame as plain characters.

Pick the route that fits your project:

  • Web page: load the ascii.js script once, then add an ascii-art element with piece="game-of-life". It draws on a canvas, weighs a few kilobytes, plays only while on screen and holds a still frame for visitors who prefer reduced motion. Attributes such as size, speed, bg, contrast and look adjust it.
  • React: the React tab gives a small component that runs the piece's own source and its one helper file inside your app.
  • Terminal: it plays in a terminal, in color, with npx --yes ascii-magic-art game-of-life. Add --frame for one still frame, or --seconds=3 to stop on its own.
  • README: download the GIF, commit it to your repository and paste the snippet from the README tab. For an animated SVG banner instead, try the README banner maker.
  • GIF and video: export a GIF, or an MP4 or WebM video at 1920 by 1080 with a 4K option.
  • Wallpapers and social images: PNGs for desktop 4K, desktop 1080p and phone, plus sizes for headers, banners, thumbnails, square posts and stories.
  • Looks: redraw the board as Halftone dots, Binary, Blocks, Letters or another look, or type your own characters. Binary turns the cells into ones and zeros, and Halftone dots turns them into round dots with sliders for dot size and density.

Where an animated Game of Life fits

The board is abstract and always busy without demanding attention, so it suits more places than most animations:

  • Hero backgrounds: place it behind a headline on a developer site, a science blog or the title slide of a talk. Match bg to your page and lower the contrast so text stays readable on top. It is also one of the ready picks in this builder: ASCII art for a developer portfolio.
  • Loading screens: show the board while a page waits for data, then hide it when the content arrives. The same pattern is covered in ASCII loading spinners and progress bars for websites, and the piece stops drawing whenever it is off screen.
  • Terminal welcome screens: it is tagged for terminals, so a few seconds of Life when a shell opens makes a calm greeting, and a still frame works as a server's message of the day. The setup is here: A terminal welcome screen with animated ASCII art.
  • Wallpapers: pause on a crowded moment and export a 4K PNG. Steps and sizes are in ASCII art wallpapers for desktop and phone.
  • Teaching: run it at half speed, ask a class to predict which cells will be born next, then pause to check. Point out a block turning violet, a blinker flipping and a glider crossing a wrapped edge. To compare other automata, open Brian's Brain, where a cell must recover after it fires, Langton's Ant and Rule 30, or browse the Algorithms category. Physics simulations live in the Motion Lab category, and every piece is in the ASCII library.

/FAQS

Conway's Game of Life: frequently asked questions

Q. What is Conway's Game of Life?
Conway's Game of Life is a cellular automaton devised by mathematician John Conway in 1970, in which a grid of cells evolves by four simple rules. It is called a zero-player game because nothing is decided after the first generation. Despite those tiny rules, it produces still shapes, blinking oscillators, moving spaceships and even working computers.
Q. What are the rules of the Game of Life?
There are four rules, applied to every cell at once each generation. A live cell with fewer than two live neighbors dies, a live cell with two or three lives on, and a live cell with more than three dies. A dead cell with exactly three live neighbors becomes alive. Each cell counts its eight neighbors, including the diagonals.
Q. What is a glider, and how does it move?
A glider is a five-cell pattern that moves one cell diagonally every four generations, rebuilding its own shape as it goes. It is the smallest spaceship, and gliders are the most common moving pattern on a random board. In this animation they show up in cream, yellow and green, because none of their cells survives more than three generations.
Q. Which patterns show up most often on a random board?
Blocks, blinkers and beehives are the most common shapes left behind as a random board settles, and gliders are the most common moving pattern. Loaves, boats and toads turn up often too. In this animation the age colors help you spot them: still lifes fade to deep violet, while blinkers flash bright and gliders streak past in yellow and green.
Q. Is Conway's Game of Life Turing complete?
Yes, patterns in the Game of Life can simulate any computer, given a large enough board and enough time. Streams of gliders act as signals, and guns, reflectors and eaters combine into logic gates and memory. People have built working counters, calculators and even a pattern that runs the Game of Life inside itself.
Q. What do the colors mean in this animation?
The colors show how long each cell has been alive. Newborn cells are pale cream, then turn yellow, green, teal, blue and indigo as they keep surviving, and cells alive for 60 generations or more turn deep violet. The faint shades left behind moving shapes are dead cells fading out over the next six generations.
Q. Why does the board keep resetting itself?
It resets so the screen never goes stale. A random board slowly settles into still lifes and blinkers, so this piece scatters a new random soup every 45 seconds. It reseeds sooner if the population count stays exactly the same for 40 generations in a row, or if fewer than 25 live cells remain.
Q. How do I add this animation to my website?
Load the ascii.js script once, then place an ascii-art element with piece="game-of-life" where you want the board. It draws on a canvas, weighs a few kilobytes, plays only while on screen and shows a still frame to visitors who prefer reduced motion. The HTML tab on this page has the exact tags to copy.
Q. Can I watch it play in my terminal?
Yes, the Terminal tab on this page holds a one-line command that plays it in color in your terminal. Add --frame to print one still frame and exit, --seconds=3 to stop on its own, or --look=dots to redraw it in halftone dots. A few seconds of Life makes a calm greeting when a new shell opens.
Q. Can I download it as a GIF, a video or a wallpaper?
Yes, the export panel saves a GIF, an MP4 or WebM video at 1920 by 1080 with a 4K option, and PNG wallpapers for desktop and phone. Pause first if you want a wallpaper of one particular moment. Every piece in the library is MIT licensed, so you can use it in personal and commercial work.
Q. Can I redraw the board with my own characters?
Yes, choose a look such as Halftone dots, Binary or Letters, or type your own set of characters, and the board is redrawn with them. Characters are sorted from light to dark by how much ink they cover, so almost any set works. On the embed tag, use the look or chars attribute to do the same.
Q. What other cellular automata are in the library?
The Algorithms category also has Brian's Brain, Langton's Ant and Rule 30, each with its own page. Brian's Brain makes each cell recover for a generation after it fires, so waves keep sweeping the grid instead of settling. Rule 30 grows a chaotic triangle from a single cell, one row at a time, and Langton's Ant sets four ants painting one wrapping board until order emerges.

Source GitHub

MIT licensed and open source on GitHub. It imports one small helper file, kit.js. This is the animation itself: what gets drawn in every frame. The look you pick is applied on top by the player, like a filter, so this file stays the same in every look while the snippets above change with it. Edit it to change the animation; see the docs to make your own.

/* game-of-life: Conway's Life on a wrapping board, coloured by cell age, reseeding when it settles. */
import { Grid, palette, rng } from "../lib/kit.js";

const pal = palette([
  "#fff6c8", "#ffd23f", "#9aff6a", "#3fe0c0", "#3fa0ff", "#5a5aff", "#8a4ad8", // 0-6 young to old
  "#1a1440", "#100c2a", "#2a2050", // 7 trail, 8 board dot, 9 trail bright
]);

export const meta = {
  slug: "game-of-life",
  name: "Game of Life",
  category: "algorithms",
  note: "Conway's Game of Life on a wrapping board, cells coloured by age, starting a fresh random board every 45 seconds, or sooner if it stalls.",
  tags: ["cellular", "automaton", "conway", "terminal", "wallpaper"],
  cols: 96, rows: 36, fps: 12,
  palette: pal,
};

const RATE = 12;          // generations per second
const EPOCH = 540;        // hard reseed every 45 s so time maps to a bounded computation

export default function create() {
  const { cols, rows } = meta;
  const g = new Grid(cols, rows);
  const W = cols, H = rows * 2, N = W * H;
  let cur = new Uint8Array(N), nxt = new Uint8Array(N);
  const age = new Uint16Array(N), dead = new Uint8Array(N);
  let epoch = -1, gen = -1, seeds = 0, history = [];
  const seed = (s) => {
    const r = rng(s * 7919 + 13);
    for (let i = 0; i < N; i++) { cur[i] = r() < 0.32 ? 1 : 0; age[i] = 0; dead[i] = 9; }
    history = [];
  };
  const step = () => {
    let pop = 0;
    for (let y = 0; y < H; y++) {
      const ym = ((y + H - 1) % H) * W, y0 = y * W, yp = ((y + 1) % H) * W;
      for (let x = 0; x < W; x++) {
        const xm = (x + W - 1) % W, xp = (x + 1) % W;
        const n = cur[ym + xm] + cur[ym + x] + cur[ym + xp] + cur[y0 + xm] + cur[y0 + xp] + cur[yp + xm] + cur[yp + x] + cur[yp + xp];
        const i = y0 + x;
        const alive = n === 3 || (n === 2 && cur[i]);
        nxt[i] = alive ? 1 : 0;
        if (alive) { age[i] = cur[i] ? Math.min(age[i] + 1, 999) : 0; dead[i] = 0; pop++; }
        else if (dead[i] < 9) dead[i]++;
      }
    }
    [cur, nxt] = [nxt, cur];
    history.push(pop);
    if (history.length > 40) history.shift();
    // settled: the population has not changed for 40 generations, or nearly everything died
    if ((history.length === 40 && history.every((p) => p === history[0])) || pop < 25) { seeds++; seed(epoch * 1000 + seeds); }
  };
  return (t) => {
    const total = Math.floor(t * RATE);
    const e = Math.floor(total / EPOCH), target = total % EPOCH;
    if (e !== epoch || target < gen) { epoch = e; gen = 0; seeds = 0; seed(e * 1000); }
    while (gen < target) { step(); gen++; }
    for (let y = 0; y < rows; y++) for (let x = 0; x < cols; x++) {
      const a = x + y * 2 * W, b = a + W;
      const ta = cur[a], tb = cur[b];
      if (ta || tb) {
        const ag = Math.min(ta ? age[a] : 999, tb ? age[b] : 999);
        const k = ag < 1 ? 0 : ag < 3 ? 1 : ag < 6 ? 2 : ag < 12 ? 3 : ag < 25 ? 4 : ag < 60 ? 5 : 6;
        g.set(x, y, ta && tb ? "█" : ta ? "▀" : "▄", String(k));
      } else {
        const d = Math.min(dead[a], dead[b]);
        if (d < 3) g.set(x, y, "▒", "9");
        else if (d < 7) g.set(x, y, "░", "7");
        else g.set(x, y, (x + y) % 2 ? "·" : " ", "8");
      }
    }
    return g.frame();
  };
}

More algorithms

Maths and code that draw: fractals, automata, attractors.

/YOUR OWN

Turn your own image or video into ASCII

The pieces here are hand-built animations. To turn your own photo, logo or video into animated ASCII, use the ASCII Magic editor.