Skip to content

A simple implementation of Bill Gosper's HashLife algorithm.

Notifications You must be signed in to change notification settings

AlephAlpha/hashlife

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

用 Rust 写个 HashLife 玩玩。

玩过才知道,HashLife 算法中最费时间的部分在 HashMap。所以不要用 Rust 自带的 Hash 算法,可以用 rustc-hash 这个 crate 里的 FxHashMap

已实现垃圾回收,但每次到了需要垃圾回收的时候就会卡上一段时间。因此垃圾回收的阈值调得比较高,模拟较大的图样时通常会占用 2G 左右的内存。

src 中仅为算法的实现。生命游戏模拟器见 hashlife-sdl 文件夹。编译前请确保电脑上装上了 sdl(参见 Rust SDL2 的说明)。

参考了以下项目:

  • golly 最好的生命游戏模拟器,其中 HashLife 的实现在hlifealgo.cpp
  • life 最好的网页版生命游戏模拟器,用 JavaScript 实现了 HashLife 算法
  • smeagol 另一个用 Rust 实现的 HashLife
  • lifeash 又一个用 Rust 实现的 HashLife

About

A simple implementation of Bill Gosper's HashLife algorithm.

Topics

Resources

Stars

Watchers

Forks

Languages