Afterglowscreensavers

Munching Squares Screensaver

Munching Squares is a free, in-browser recreation of one of the first display hacks ever written: on MIT’s PDP-1 in 1962, plotting every point where x XOR y is less than a counter that keeps rising makes nested squares grow, swallow one another and reset. This saver runs the original rule plus the AND, OR and scrolling-palette variants at crisp pixel scale. Nothing to download, and ESC exits at any time.

Live preview

Munching Squares screensaver — The 1962 PDP-1 display hack.

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Munching Squares screensaver works

Lay a 256 × 256 grid over the screen. For each cell compute x XOR y — the bitwise exclusive-or of its coordinates — and light the cell if the result is below a threshold t. Then raise t by one and draw again. That is the whole program, and on the PDP-1 it fit in a handful of instructions.

XOR is what makes it interesting. The value x XOR y is small along the diagonal and jumps in powers of two across it, so the lit region is a nest of squares within squares, and as t climbs through each power of two a new generation of squares appears and eats the last.

The AND mode replaces XOR with x AND y, which lights a Sierpinski triangle; OR gives its complement. The palette mode drops the threshold and instead colours every cell by (x XOR y) + t, so the entire bit-field scrolls through the spectrum.

Cells are drawn without smoothing so the squares stay hard-edged; Cell size sets how many screen pixels each grid cell covers.

Munching squares, XOR and early display hacks

Munching Squares is credited to Jackson Wright, who reportedly discovered it around 1962 on the PDP-1, the small Digital Equipment Corporation computer that also ran the game Spacewar!. It circulated among early programmers as a display hack, an elegant effect produced from a tiny amount of code, and it appears as Item 146 in the HAKMEM memo.

The core is the XOR operation, short for exclusive or. Comparing two binary numbers bit by bit, XOR gives 1 where the bits differ and 0 where they match. When x and y are used as coordinates, the pattern of x XOR y has a self-similar structure, because each bit of the coordinates contributes its own stripes at a different scale. Combining x and y with a bitwise AND instead gives a Sierpinski triangle.

The same XOR operation has other uses in computing, from simple encryption and checksums to swapping values without a temporary variable. Its role in graphics is playful, but it shows how arithmetic on bits can generate intricate order from almost nothing.

A worked example

At the defaults — Classic mode, Cell size 4, Speed 4 — a small green square blooms at the corner, splits into four, sixteen and so on, each generation sweeping through the last until the whole grid is lit and the count wraps to zero. Switch to AND and the same threshold walk fills in a Sierpinski gasket instead; switch to XOR palette scroll for a continuously flowing rainbow of the same structure.

Settings & tips

Frequently asked questions

Where does Munching Squares come from?
It was written at MIT in 1962 by Jackson Wright on the PDP-1, one of the first computers with a display, and is recorded in the Jargon File as one of the earliest display hacks. The name describes what the squares look like they are doing.
Why do the squares munch?
Because x XOR y climbs in powers of two away from the diagonal. When the threshold passes a power of two, a whole new set of cells switches on at once, which looks like a larger square consuming the previous ones.
Is the Munching Squares screensaver free?
Yes. It runs free in your browser with nothing to download or install, and it keeps working offline once the page has loaded.
How do I exit the Munching Squares screensaver?
Press the ESC key at any time to leave fullscreen and return to the page.
Will this slow my computer down?
It is tuned to run smoothly on an ordinary laptop. If it feels heavy, raise the Pixel size or lower the speed in the settings; every control takes effect immediately.
What is a PDP-1?
A minicomputer made by Digital Equipment Corporation, first delivered in 1960, and the original hardware for Spacewar!, one of the first video games.
What does XOR mean?
Exclusive or: it returns true when exactly one of two inputs is true, so matching bits give 0 and differing bits give 1.
Is it related to the Sierpinski triangle?
Yes. Combining coordinates with a bitwise AND gives a Sierpinski triangle, while XOR gives the squares seen here; both are binary patterns.

← All Generative screensavers