Learning Rust by implementing different Cellular Automata
- Clone the repository
- Run
cargo build --release --examples
- Go into the target/release/examples folder
- Run the exe you want
The project consists of a library, cell_engine_rs
, implementing visualization, controls and other stuff common to cellular automata.
This library is then used in multiple different cellular automata examples, which only have to implement game specific stuff such as update rules and cell varieties.
To build a new cellular automata with the library, only one function has to be called with a structure implementing some traits exposed by the library.
- P: Toggle pause
- PageUp: Increase game speed
- PageDown: Decrease game speed
- Space: One game step forward
- Shift + PageUp: Increase visual decay rate
- Shift + PageDown: Decrease visual decay rate
- Clicking or dragging with the mouse toggles the cells under the cursor
- Wireworld
- Cell types: Wire, Electron Head, Electron Tail
- Update rule:
- A inert cell stays inert
- A wire becomes a electron head if one or two neighboring cells are electron heads
- A electron head becomes a electron tail
- A electron tail becomes a wire
- Game of life
- Cell types: Dead, Alive
- Update rule:
- A dead cell becomes alive if 3 neighboring cells are alive
- A alive cell stays alive if 2 neighboring cells are alive
- Langton's Ant
- Cell types: Black, White
- Both cell types can contain the unique "ant"
- The ant can face in all four directions
- The number of different states per cell is therefore 2*4 + 2 = 10
- Update rule:
- The ant always flips the color of the square it is on
- The ant turns left and then moves forward if it's on a black square
- The ant turns right and then moves forward if it's on a black square
- Cell types: Black, White