2 releases
0.0.2 | Jan 23, 2025 |
---|---|
0.0.1 | Jan 21, 2025 |
#140 in Games
242 downloads per month
16KB
306 lines
Game of Life
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"
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