bevy_life 0.1.0

Generic and dynamic cellular automaton lib for bevy
Documentation

Bevy Cellular Automaton

workflow

MIT licensed Crates.io aragog dependency status

bevy_life is a generic plugin for cellular automaton. From the classic 2D Conway's game of life to WireWorld and 3D rules, the plugin is completely generic and dynamic.

See:

Bevy versions

The main branch follows the released version of bevy (0.5) but I provide 3 useful branches to follow the new engine features:

How to use

You may add as many generic CellularAutomatonPlugin as wished, the lib provides some implementations like:

  • GameOfLife2dPlugin
  • GameOfLife3dPlugin
  • WireWorld2dPlugin
  • WireWorld3dPlugin
  • CyclicAutomaton2dPlugin
  • CyclicAutomaton3dPlugin

Then you may use bevy as usual and add impl Cell and impl CellState components to the entities. The lib provides some implementations like Cell2d or Cell3d for cells and ClassCellState, WireWorldCellState or CyclicCellState for states.

You may implement your own cells (coordinate system) and states (rules) as you want, the cellular automaton system is completely dynamic and generic.

For more information yo may look at some examples.

Cargo Features

No feature is required for the plugin to work and the main traits Cell and CellState are always available. But you may enable the following features

  • 2D (enabled by default): Enables 2D types like:
    • Cell2d (square cell with 8 neighbors)
    • plugin presets: GameOfLife2dPlugin, WireWorld2dPlugin, CyclicAutomaton2dPlugin
  • 3D (enabled by default): Enables 3D types like:
    • Cell3d (cube cell with 26 neighbors)
    • plugin presets: GameOfLife3dPlugin, WireWorld3dPlugin, CyclicAutomaton3dPlugin
  • auto-coloring:
    • Enables CellStateMaterials2d (if 2D) and CellStateMaterials3d (if 3D) types to contain material handles
    • The CellState type now requires to build either of the previous type (according to 2D/3D feature gates)
    • All CellState components with materials will be colored according to their type.

Examples

For every example pressing space reloads the board

Classic 2D

Run cargo run --example 2d_classic --features auto-coloring --release

Alt

Cyclic 2D

Run cargo run --example 2d_cyclic --features auto-coloring --release

Alt

Wire World 2D

Run cargo run --example 2d_wireworld --features auto-coloring --release

The example is dynamic, use the left mouse click to create a conductor cell on an empty space or to create an electron head

Alt