Run Length Encoded
The Run Length Encoded (or RLE for short) file format is commonly-used for storing large patterns. It is more cryptic than some other file formats such as plaintext and Life 1.06, but is still quite readable. Many features of the RLE file format are incorporated in the MCell file format. RLE files are saved with a .rle file extension.
Description of format
The first line is a header line, which has the form
x = m, y = n
where m and n are the width and height of the pattern, respectively. The pattern itself begins on the next line and is encoded as a sequence of items of the form <run_count><tag>, where <run_count> is the number of occurrences of <tag> and <tag> is one of the following three characters:
|$||end of line|
<run_count> can be omitted if it is equal to 1. The last <run_count><tag> item is followed by a ! character. Dead cells at the end of a pattern line do not need to be encoded, nor does the end of the last line of the pattern. Whitespace is permitted between <run_count><tag> items (and between the last <run_count><tag> item and the following !), but except for carriage returns and line feeds this is not recommended. It is not permitted to place whitespace in the middle of a <run_count><tag> item.
Lines in the RLE file must not exceed 70 characters, although it is a good idea for RLE readers to be able to cope with longer lines. DOS, Unix and Mac newline conventions are all acceptable.
Anything after the final ! is ignored. It used to be common to put comments here (starting on a new line), but the usual method for adding comments is now by means of #C lines (see below).
The header line may be preceded by any number of lines beginning with the # character. The # character is followed by a letter indicating the type of information that line provides. These letters generally follow the conventions for XLife files, which are described in the file xlife.man in the XLife distribution. Here is a list of letters likely to be encountered in practice:
|C|| Indicates that a line of comment follows. This is the only really common use of # lines.|
Example: #C 'Twas brillig and the slithy toves
|c||Same as C, but not recommended.|
|N|| The name of the pattern.|
Example: #N My awesome pattern
|O|| Says when and by whom the file was created. RLE files produced by XLife usually have this line.|
Example: #O John Smith firstname.lastname@example.org Fri Apr 30 19:38:52 1999
|P|| Essentially the same as R, below. This line is produced by Life32, which generates coordinates which should represent the top-left corner of the Life pattern.|
Example: #P 90 136
|R|| Gives the coordinates of the top-left corner of the pattern. RLE files produced by XLife usually have this line, and the coordinates are usually negative, with the intention of placing the centre of the pattern at the origin.|
Example: #R -22 -57
|r|| Gives the rules for the pattern in the form survival_counts/birth_counts (e.g. 23/3 for Life). This line is usually present in RLE files created by XLife, but the standard method of indicating the rule is described below.|
Example: #r 23/3
The rule for which the pattern is designed can be indicated in the header line, which then takes the form
x = m, y = n, rule = abc
where abc is the rule's designation, such as B3/S23 for Life or B36/S23 for HighLife. This type of extended header line is usual whenever the pattern is not intended for Conway's Life. As with ordinary header lines, RLE writers should adhere to the spacing shown, but RLE readers are best not to assume it.
Letters other than b and o may be used for the <tag>s to represent extra states. Unless the cellular automaton has more than 26 states it is a good idea to stick to lowercase letters. RLE readers that cannot handle more than two states should treat all letters other than b (and perhaps B) as equivalent to o.
The following is a glider in RLE format:
#C This is a glider. x = 3, y = 3 bo$2bo$3o!
The following is the Gosper glider gun in RLE format:
#N Gosper glider gun #C This was the first gun discovered. #C As its name suggests, it was discovered by Bill Gosper. x = 36, y = 9, rule = B3/S23 24bo$22bobo$12b2o6b2o12b2o$11bo3bo4b2o12b2o$2o8bo5bo3b2o$2o8bo3bob2o4b obo$10bo5bo7bo$11bo3bo$12b2o!
- Extended RLE format at Golly's online help
- Cellular automata file formats at Mirek Wójtowicz's Cellebration page