CA formats parsers
Parsing pattern files for Conway's Game of Life.
The parsers read a string and return an iterator of coordinates of living cells.
Supported formats
Example
Reading from a string:
use Rle;
const GLIDER: &str = r"#N Glider
#O Richard K. Guy
#C The smallest, most common, and first discovered spaceship. Diagonal, has period 4 and speed c/4.
#C www.conwaylife.com/wiki/index.php?title=Glider
x = 3, y = 3, rule = B3/S23
bob$2bo$3o!";
let glider = new.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
let cells = glider.map.;
assert_eq!;
Reading from a file:
use File;
use Rle;
let file = open.unwrap;
let sirrobin = new_from_file.unwrap;
assert_eq!;
Unknown cells
When the unknown feature is enabled. the Rle type will provide an extra method with_unknown, which turns the RLE into a special variant of RLE format. In this variant there is another symbol, ?, which represents unknown cells. Now unknown cells are the background. Dead cells at the end of each line must not be omitted. The iterator will also explicitly output the dead cells.
This is only supported for RLE.
See also
- ca-rules - A parser for rule strings.
- game-of-life-parsers by René Perschon - Parsers for Life 1.05 and Life 1.06 format.