5 个版本
0.1.4 | 2022 年 12 月 31 日 |
---|---|
0.1.3 | 2022 年 12 月 31 日 |
0.1.2 | 2022 年 12 月 30 日 |
0.1.1 | 2022 年 12 月 30 日 |
0.1.0 | 2022 年 12 月 30 日 |
#222 在 模拟
每月 40 次下载
在 open-oak-game-of-life 中使用
17KB
305 行
conlife
用 Rust 实现的仅后端(无前端)的 Game of Life,依赖最少。
lib.rs
:
实现 Conway's Game of Life 后端的库包(见 https://en.wikipedia.org/wiki/Conway's_Game_of_Life)。后端简单,提供预定义的宽/高网格,即不扩展。此包不实现显示网格的前端,您将必须使用其他包或自己编写。
使用示例
use conlife::{Grid, Object};
let mut grid = Grid::new(16, 16);
let glider = Object::from_string("(0,2) (1,2) (2,2) (1,0) (2,1)").unwrap();
// Load glider at (0,0)
grid.load_object(&glider, (0,0));
// advance by 10 generations
for _ in 0..10 {
grid.advance();
}
/* More code here to e.g. display the grid using a frontend */