Small object format

From LifeWiki
Jump to navigation Jump to search

The small object format (or SOF for short) is a file format designed by Heinrich Koenig that is primarily used for storing multiple patterns in a single file, with one object per line in the file. It is about as human-readable as an RLE file, but it has the added benefit of increased compression.

Description of format

Each object takes up one line in an ASCII file. The format itself specifies each line as an alternating list of ON and OFF cells, starting with an ON cell.

Using the minimal bounding box, a single object is specified as follows:

  1. If the line starts with off cells, write "0". Otherwise, skip this step.
  2. If the count of consecutive cell of the same type (ON or OFF) is no more than 78, write the count of consecutive cells as ASCII(x + 0x30). For counts of 0-9, this results in the characters "0" through "9" (ASCII at Wikipedia). Otherwise, skip this step.
  3. If the count of consecutive cell of the same type (ON or OFF) is larger than 78, write the 78 using the encoding given in Step 2 (which gives "~"), then a "0" to signify a zero length run, followed by the value for (count-78), as described in Step 2. Repeat as necessary. For example, a count of 80 would be encoded as "~02".
  4. At the end of a row of a pattern, write "-". For patterns containing multiple blank lines, write "+" followed by the count of consecutive line feeds as ASCII(x + 0x30). Thus "3+43." is equivalent to "3----3." (two horizontal blinkers separated by three blank rows).
  5. At the end of the pattern, write "."
  6. Comments can be included; everything following an exclamation mark ("!") is assumed to be a comment and is ignored.
  7. Text entered within parentheses "(name right here)" is assumed to be the name of the pattern. This should be entered after the "." but before the comment exclamation mark, if one is included.
  8. Text before "!" and outside "( ... )" is not ignored.


The following is a glider in SOF format:

3-12-0111. (Glider) !This is a glider

External links