#life #cellular-automata #conway #hashlife

smeagol

使用HashLife和SIMD实现的康威生命游戏

3个版本

0.1.2 2019年2月27日
0.1.1 2019年2月22日
0.1.0 2019年2月22日

#1309算法

每月 29 次下载
用于 goliard

MPL-2.0 许可证

1MB
2.5K SLoC

smeagol

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

简介

smeagol 是一个Rust库,用于高效模拟康威生命游戏(Conway's Game of Life)中的大模式。它使用Bill Gosper开发的HashLife算法,以实现对重复模式的巨大加速。关于HashLife的详细解释可以在这里找到这里。它还使用SIMD指令来加速将16x16单元格的基网格演进到未来的过程。

用法

smeagol 添加到你的 Cargo.toml

[dependencies]
smeagol = "0.1"

然后,开始模拟康威生命游戏!

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(())
}

这将产生以下图像

Breeder

更多请参阅文档

限制

目前没有垃圾回收。如果长时间运行,大模式最终会导致程序崩溃。这将在未来得到修复。

仅支持生命规则B3/S23。

许可证

smeagol 在Mozilla Public License版本2.0下授权。有关详细信息,请参阅许可证文件MPL 2.0 FAQ

依赖关系

~3.5MB
~66K SLoC