#pattern #conway #life #interface #web #parser #cell

bin+lib lexicon

A convenient interface to get patterns from Conway’s Game of Life’s Lexicon

3 releases

0.1.2 Nov 13, 2021
0.1.1 Nov 13, 2021
0.1.0 Nov 13, 2021

#17 in #conway

48 downloads per month

MIT license

455KB
240 lines

Lexicon

Crates.io Rust

A convenient interface to get patterns from the Lexicon and use them in your implementation of Conway’s Game of Life.

Used by Lifeee, my web app implementation of Conway’s Game of Life, check it out!

Usage

let lexicon = lexicon::Lexicon::get();
assert_eq!(lexicon.terms.len() > 0, true);

let glider = lexicon.get_term("glider".to_string()).unwrap();
assert_eq!(glider.width, 3);
assert_eq!(glider.height, 3);
assert_eq!(glider.cells, vec![
  lexicon::Cell { x: 0, y: 0 },
  lexicon::Cell { x: 1, y: 0 },
  lexicon::Cell { x: 2, y: 0 },
  lexicon::Cell { x: 0, y: 1 },
  lexicon::Cell { x: 1, y: 2 }
]);

Regenerate a bin file after an update of the text version

cargo run will read the file res/lexicon.txt, parse it and serialize the result into res/lexicon.bin, which will be used by the library then.

Dependencies

~2.8–4.5MB
~82K SLoC