3 releases

0.1.2 Feb 27, 2019
0.1.1 Feb 22, 2019
0.1.0 Feb 22, 2019

#1350 in Algorithms


Used in goliard

MPL-2.0 license

1MB
2.5K SLoC

smeagol

Build status Coverage Lines of code Version Documentation License Dependency status Rust version

Introduction

smeagol is a Rust library built to efficiently simulate large patterns in the cellular automaton Conway's Game of Life. It uses the HashLife algorithm developed by Bill Gosper to achieve tremendous speedups for repetitive patterns. A good explanation of HashLife can be found here. It also uses SIMD instructions to speed up the base case of evolving a 16 by 16 square grid of cells into the future.

Usage

Add smeagol to your Cargo.toml:

[dependencies]
smeagol = "0.1"

Then, start simulating Conway's Game of Life!

fn main() -> Result<(), failure::Error> {
    // load a pattern
    let mut life = smeagol::Life::from_rle_file("breeder1.rle")?;

    // step 1024 generations into the future
    life.set_step_log_2(10);
    life.step();

    // save the result
    let bbox = life.bounding_box().unwrap().pad(10);
    life.save_png("breeder1.png", bbox, 0)?;

    Ok(())
}

This produces the following image:

Breeder

See the documentation for more.

Limitations

Currently there is no garbage collection. Large patterns will eventually crash the program if left running. This will be fixed in the future.

Only the Life rule B3/S23 is supported.

License

smeagol is licensed under the Mozilla Public License version 2.0. See the license file and the MPL 2.0 FAQ for more details.

Dependencies

~3.5MB
~69K SLoC