Run Length Encoded: Difference between revisions
m →Downloading LifeWiki patterns: AutoWikiBrowser - per Nathaniel, and requested by GUYTU6J, replaced: www.conwaylife.com → conwaylife.com |
|||
| (7 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
The '''Run Length Encoded''' (or '''RLE''' for short) [[File formats|file format]] is commonly-used for storing [[pattern]]s. 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)|MCell]] file format. RLE files are saved with a .rle file extension. | The '''Run Length Encoded''' (or '''RLE''' for short) [[File formats|file format]] is commonly-used for storing [[pattern]]s. 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)|MCell]] file format. RLE files are saved with a {{filename|.rle}} file extension. | ||
==Description of format== | == Description of format == | ||
The first line is a header line, which has the form | The first line is a header line, which has the form | ||
| Line 9: | Line 9: | ||
{| class="wikitable" style="margin-left:auto;margin-right:auto;text-align:center;" | {| class="wikitable" style="margin-left:auto;margin-right:auto;text-align:center;" | ||
! <tag> | ! <tag> | ||
! description | ! description | ||
| Line 21: | Line 20: | ||
| $ | | $ | ||
| end of line | | end of line | ||
|- | |||
| x | |||
| marked alive cell 1<ref name="niemiec" group="note">used primarily by [[Mark Niemiec]]; interpreted identically to "o" by [[Golly]] and converted to [R]Super states by [[LifeViewer]]</ref> | |||
|- | |||
| y | |||
| marked alive cell 2<ref name="niemiec" group="note"/> | |||
|- | |||
| z | |||
| marked alive cell 3<ref name="niemiec" group="note"/> | |||
|} | |} | ||
| Line 29: | Line 37: | ||
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). | 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). | ||
===# lines=== | === # lines === | ||
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 {{filename|xlife.man}} in the XLife distribution. Here is a list of letters likely to be encountered in practice: | |||
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: | |||
{| class="wikitable" style="margin-left:auto;margin-right:auto;text-align:left;" | {| class="wikitable" style="margin-left:auto;margin-right:auto;text-align:left;" | ||
! letter | ! letter | ||
! description | ! description | ||
|- | |- | ||
| C | | C | ||
| Indicates that a line of comment follows. This is the only | | Indicates that a line of comment follows. This is the only particularly common use of # lines.{{br}}Example: #C 'Twas brillig and the slithy toves | ||
|- | |- | ||
| c | | c | ||
| Line 45: | Line 51: | ||
|- | |- | ||
| N | | N | ||
| The name of the pattern. | | The name of the pattern.{{br}}Example: #N My awesome pattern | ||
|- | |- | ||
| O | | O | ||
| Says when and by whom the file was created. RLE files produced by XLife usually have this line. | | Says when and by whom the file was created. RLE files produced by XLife usually have this line.{{br}}Example: #O John Smith [email protected] Fri Apr 30 19:38:52 1999 | ||
|- | |- | ||
| P | | 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. | | 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.{{br}}Example: #P 90 136 | ||
|- | |- | ||
| R | | 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. | | 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.{{br}}Example: #R -22 -57 | ||
|- | |- | ||
| r | | r | ||
| Gives the [[ | | Gives the [[rule]]s 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.{{br}}Example: #r 23/3 | ||
|} | |} | ||
[[Catagolue]] uses some custom lines for synthesis RLEs. | |||
=== Other features === | |||
The rule for which the pattern is designed can be indicated in the header line, which then takes the form | 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 | x = m, y = n, rule = abc | ||
where abc is the rule's designation, such as B3/S23 for Life or B36/S23 for | where abc is the rule's designation, such as B3/S23 for Life or B36/S23 for {{rl|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. | 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. | ||
==Examples== | == Examples == | ||
The following is a [[glider]] in RLE format: | The following is a [[glider]] in RLE format: | ||
| Line 89: | Line 96: | ||
</pre> | </pre> | ||
==Downloading LifeWiki patterns== | == Downloading LifeWiki patterns == | ||
There are four ways to obtain pattern RLEs from LifeWiki: | |||
*Click the "show" link in the "Pattern file" section of a pattern's infobox | * Click the "show" link in the "Pattern file" section of a pattern's infobox | ||
*For a pattern that is open in the LifeViewer: advance it a tick; rewind it; click anywhere on the grid; press Ctrl-C to copy the pattern to the clipboard | * For a pattern that is open in the LifeViewer: advance it a tick; rewind it; click anywhere on the grid; press <tt>Ctrl-C</tt> to copy the pattern to the clipboard | ||
*Use a "Download RLE: click here" link under a pattern image or "RLE: here" link under an embedded LifeViewer display | * Use a "Download RLE: click here" link under a pattern image or "RLE: here" link under an embedded LifeViewer display | ||
*To download the entire LifeWiki pattern collection: [https://conwaylife.com/patterns/all.zip Pattern collection zip file] | * To download the entire LifeWiki pattern collection: [https://conwaylife.com/patterns/all.zip Pattern collection zip file] | ||
==See also== | == Extensions == | ||
=== Multisitate rules === | |||
Golly, LifeViewer and other programs use a common extension to support patterns with three or more states. | |||
=== Three-dimensional patterns === | |||
3D.lua, packaged with Golly, saves patterns in RLE format in a way that supports 3D objects. These are saved as the .rle3 format. | |||
== See also == | |||
* [[Macrocell]] | * [[Macrocell]] | ||
* [[apgcode]] | * [[apgcode]] | ||
* [[File formats]] | |||
== Notes == | |||
<references group="note"/> | |||
==External links== | == External links == | ||
{{LinkGollyHelp|formats.html#rle|title=Extended RLE format}} | * {{LinkGollyHelp|formats.html#rle|title=Extended RLE format}} | ||
{{LinkMirek|ca_files_formats.html|title=Cellular automata file formats}} | * {{LinkMirek|ca_files_formats.html|title=Cellular automata file formats}} | ||
{{LinkLexicon|lex_r.htm#rle}} | * {{LinkLexicon|lex_r.htm#rle}} | ||
[[Category:Everything else]][[Category:File formats]] | [[Category:Everything else]] | ||
[[Category:File formats]] | |||
Latest revision as of 10:24, 26 September 2025
The Run Length Encoded (or RLE for short) file format is commonly-used for storing 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:
| <tag> | description |
|---|---|
| b | dead cell |
| o | alive cell |
| $ | end of line |
| x | marked alive cell 1[note 1] |
| y | marked alive cell 2[note 1] |
| z | marked alive cell 3[note 1] |
<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).
# lines
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:
| letter | description |
|---|---|
| C | Indicates that a line of comment follows. This is the only particularly 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 [email protected] 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 |
Catagolue uses some custom lines for synthesis RLEs.
Other features
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.
Examples
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!
Downloading LifeWiki patterns
There are four ways to obtain pattern RLEs from LifeWiki:
- Click the "show" link in the "Pattern file" section of a pattern's infobox
- For a pattern that is open in the LifeViewer: advance it a tick; rewind it; click anywhere on the grid; press Ctrl-C to copy the pattern to the clipboard
- Use a "Download RLE: click here" link under a pattern image or "RLE: here" link under an embedded LifeViewer display
- To download the entire LifeWiki pattern collection: Pattern collection zip file
Extensions
Multisitate rules
Golly, LifeViewer and other programs use a common extension to support patterns with three or more states.
Three-dimensional patterns
3D.lua, packaged with Golly, saves patterns in RLE format in a way that supports 3D objects. These are saved as the .rle3 format.
See also
Notes
- ↑ 1.0 1.1 1.2 used primarily by Mark Niemiec; interpreted identically to "o" by Golly and converted to [R]Super states by LifeViewer
External links
- Extended RLE format at Golly's online help
- Cellular automata file formats at Mirek Wójtowicz's Cellebration page
- Run Length Encoded at the Life Lexicon