Introduction
An RLE file holds a pattern for the Game of Life or another cellular automaton as a few lines of text. A header line gives the size of the pattern and its rule, and the cells follow as run-length encoded text: 3o is three live cells, 2b two dead ones, $ the end of a row and ! the end of the pattern. A glider is bob$2bo$3o!. The format is the one Golly prefers (it calls it Extended RLE), and it is the one patterns are shared in, on forums, in email and on the LifeWiki.
Because the data is run-length encoded the size of a file grows with the number of runs and not with the number of cells, which suits sparse patterns. A pattern with many millions of cells in a few long lines is still a short file. The format has no limit on the number of states: rules with more than two states use letters for the states, up to 255.
The extension is also used by two image formats, the Utah Raster Toolkit RLE image and Windows RLE-compressed bitmaps (see BMP). A Life file is told from them by its text: after blank lines and # lines the first line starts x = . The viewer on this site makes that test before it reads the file as a pattern.
Lines
A file is lines of text ending in CR, LF or CR LF. A line may start with spaces or tabs, which are ignored.
| Line | Meaning |
|---|---|
| blank, or only spaces and tabs | Ignored. |
#CXRLE Pos=x,y Gen=n | Extended RLE. Only read when it comes first in the file (any number of them, one after another). Pos is the position of the upper left cell of the pattern; Gen is the generation count of the pattern. Each key is optional. |
#C text or #c text | A comment. |
#N name | The name of the pattern. |
#O text | The owner or author, often with the date of discovery. |
#r rule | The rule, read only if no rule has been given yet. Golly looks only at the second character, so #rule x gives the rule ule. A #r line is meant for pattern files that have no header: once a rule has been read, Golly no longer takes an x = line for the header, and reads it as cells (the letters o to y in it are live cells). |
other # lines | Comments. Golly does not read #P or #R lines in an RLE file. |
x = w, y = h, rule = r | The header. A line is the header when it starts with x followed by a space or =. |
| any other line | Cell data. |
lines after the ! | Comments, or an @RULE section. |
#Comments#C,#N,#O,#CXRLE,#rany number of linesxHeaderx = w, y = h, rule = r1 line3oCell data tokens, ended by!any number of lines@Trailer comments or an@RULEsectionoptional
The header line
x = width, y = height, rule = rule. Spaces may be put anywhere except at the start of the line and inside a name or number. width and height are whole numbers: the size of the box round the pattern. Golly ignores them when it opens a file, so they need not be exact; when it pastes a pattern it uses them as the area to paste. rule is optional: without it Golly reads the pattern with Conway’s rule, B3/S23. The rule runs up to the next space; a comma straight after it is dropped, so a header may end rule = B3/S23,.
Rules
| Written | Meaning |
|---|---|
B3/S23 | Birth and survival: a dead cell with a number of live neighbours (of the eight round it) from the B digits comes alive, a live cell with one from the S digits stays alive. Two states. The digits 0 to 8. |
23/3 | The same, written survival then birth. S23/B3 is also read. |
23/3/4, B3/S23/4 | Generations: survival, birth and a number of states (two slashes, the number last). A cell that would die goes through the higher states first. Golly’s library does not read the C form some programs write, B3/S23/C4. |
W110 | A Wolfram one-dimensional rule, by number. |
R5,C2,S33-57,B34-45 | Larger than Life: a range, a number of states, and ranges of neighbours for survival and birth. |
B2-a/S12, B3/S23V, B3/S23H | Non-totalistic, von Neumann and hexagonal rules: letters after a digit pick neighbour patterns; V and H change the neighbourhood. |
a name such as WireWorld, Codd, LifeHistory | A rule Golly knows by name: built in, or a .rule file (found in Golly’s folders, or in an @RULE section after the pattern). |
…:T30,20 | A suffix after a colon makes the grid bounded: P plane, T torus, K Klein bottle, C cross-surface, S sphere, then width and height (one number means both; 0 means unlimited), with +n after a size shifting the edges and * twisting them. |
A bounded grid of width w and height h has its top left cell at -int(w/2), -int(h/2). A pattern with no Pos goes in the middle of it.
Cell data
The cells are listed a row at a time from the top, each row from the left, starting at the upper left of the pattern. Everything is a token: an optional count (a whole number with no leading zero) and a symbol, with no space between them.
| Symbol | Meaning |
|---|---|
b or . | Cells in state 0 (dead). Count times. |
o | Live cells, state 1. |
A to X | States 1 to 24. A is the same as o. |
pA to pX | States 25 to 48. q adds 24 more (49 to 72), and so on to y: yA to yO are states 241 to 255. |
$ | The end of a row. With a count, that many row ends: 5$ finishes the row and leaves four blank rows. The next row starts at the left. |
! | The end of the pattern. Nothing after it on the line, or on any line after it, is cells. |
Lines of cell data can be any length; Golly writes them about 70 characters long. A count may not be split from its symbol by a space or a line end, and a count may not start with 0: Golly refuses the file for either. Golly skips any other character in the data without comment. A letter from p to y that is not followed by A to X is read as state 1.
The pattern’s upper left cell is at the position given by #CXRLE Pos, or at 0, 0 when there is none, or in the middle of a bounded grid.
An example
A glider with a header and a name, line endings 0A. The header is one line, shown over two rows here.
23 4E 20 47 6C 69 64 65 72 0A #N Glider
78 20 3D 20 33 2C 20 79 20 3D 20 33 2C 20 x = 3, y = 3,
72 75 6C 65 20 3D 20 42 33 2F 53 32 33 0A rule = B3/S23
62 6F 62 24 32 62 6F 24 33 6F 21 0A bob$2bo$3o!
The rows are .o., ..o and ooo: five live cells in a box of 3 × 3.
An @RULE section
After the !, a line that starts @RULE name begins a .rule file kept inside the pattern: a rule table or tree, state names, colours and icons for a rule that Golly does not know. When Golly opens the pattern it copies the section into a temporary .rule file named after the rule. The section ends at the end of the file.
In the explorer
Drop a pattern on the explorer and it shows the cells as a picture with the pattern’s facts: name, owner, rule and what it means, the size in the header against the size of the live cells, the position and generation from #CXRLE, the population and the states used. Every byte is in the tree: each line, each part of the header, and each token of a line of cells. The pattern can be run for a number of generations with the Generation option, for the rules listed under Not described, on the plane or a bounded grid, in the colours of the viewer (a rule file’s own colours are shown on its page). A pattern too big for one picture is shown a window at a time: Cell size, Window left and Window top move it by cells.
Not described
What this reference leaves out and what the viewer does not do.
Known, not yet covered
- Reference: the format is described here from Golly’s documentation (its file formats help), the source of its reader (
readrleingollybase/readpattern.cpp) and the LifeWiki’s page on the format. From the LifeWiki:#Pand#Rlines give the top-left corner of the pattern (Life32 writes#P, XLife#R), and a line of cells should not pass 70 characters. Golly reads neither; what other programs (LifeViewer and others) do with them is not described. The lettersx,yandzas marked live cells (used by Mark Niemiec’s files) are read by Golly as state 1; what LifeViewer does with them is not described here. - Reference: RLE data with no header line, which Golly also reads, is not described. The viewer shows it with the problem “no header line”.
- Reference: the rule languages are described on the rule file page (tables and trees) and in the table above (Life-like, Generations, Wolfram, Larger than Life, non-totalistic letters, V and H, MAP). Not described: the alternating form Golly uses for B0 rules, the other Larger than Life neighbourhoods (custom, weighted, hexagonal, triangular, checkerboard, hash, tripod, asterisk and Gaussian), Margolus rules (Golly gets those through rule files), and the built-in algorithms JvN, Nobili32, Hutton32, LifeHistory and Super.
- Viewer: the explorer runs the cells for the Generation option with the rules it has an algorithm for: Life-like, von Neumann and hexagonal totalistic, non-totalistic letters, Generations, Wolfram (W), MAP, Larger than Life with the Moore, von Neumann, circular, L2, cross, saltire and star neighbourhoods, and the table or tree of an
@RULEsection after the pattern. Bounded grids of every kind (:P, :T with shifts, :K, :C, :S) are run; an infinite tube (:T0,40) only with the 2-state Life-like rules. A rule given by name that is not in the file (Codd,WireWorld,LifeHistory) is not run: Golly would find its.rulefile in its Rules folder, which the explorer has no access to. The rules above were run against a Python port of Golly’s own code and agree (see the tests), but Golly itself was not run, and the port was written from the same reading of the source.
Also used for
- Windows bitmap (BM) – Windows 3.0 and later bitmaps: a 40- to 124-byte header, palette and pixel rows.
Other Game of Life pattern formats
- Game of Life pattern (.lif) – Life 1.05, Life 1.06 and plain grids
- Plaintext pattern (.cells) – cells drawn as text, a dot for dead and O for alive
- Golly rule (.rule) – transition tables and trees, with colours and icons, that the pattern’s rule names
- Golly macrocell (.mc) – a universe as a quadtree, for patterns of astronomical size
- MCell pattern (.mcl) – the format of the MCell program
Links
Software
- Golly – free Game of Life and cellular automata program that opens and saves RLE (Windows, macOS, Linux)
Reference
- Golly file formats – Golly’s description of Extended RLE, macrocell and rule files
- Run Length Encoded – the LifeWiki page on the format