#game-of-life #conway #celluarautomaton

gridlife

An library to generate and simulate Conways Game of Life cellular automatons

2 releases

0.0.2 Jan 23, 2025
0.0.1 Jan 21, 2025

#140 in Games

Download history 33/week @ 2025-01-15 179/week @ 2025-01-22 12/week @ 2025-01-29 18/week @ 2025-02-05

242 downloads per month

MIT license

16KB
306 lines

Game of Life

codecov

Implementation of Conway's Game of Life.

Generate 2d Grid of given size that are empty or contain a random distribution of dead or alive populations.

update_states is then called on the Grid to generate the next grid state based on the rules of Conway's Game of Life.

Package also contains an example Text User Interface (TUI) leveraging gridlife with ratatui, which can be used to run random simulations.

Run TUI

cargo run --features="build-binary"

image

lib.rs:

Game of Life

Library to manage the grid state for Conways game of life.

See: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

use gridlife::Grid;
let mut grid = Grid::new_random(3, 3);
let mut population = grid.population;
// Run the rules of Game of Life until the population count stabalizes
loop {
    grid.update_states();
    let next_pop = grid.population;
    if next_pop == population {
        break;
    }
    population = next_pop;
}

Dependencies

~23–385KB