Generic cellular automaton plugin for bevy.

Overview

Bevy Cellular Automaton

workflow

MIT licensed unsafe forbidden Crates.io Docs.rs 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
  • ImmigrationGame2dPlugin
  • ImmigrationGame3dPlugin
  • RainbowGame2dPlugin
  • RainbowGame3dPlugin
  • WireWorld2dPlugin
  • WireWorld3dPlugin
  • CyclicColors2dPlugin
  • CyclicColors3dPlugin

Then you may use bevy as usual and add impl Cell and impl CellState components to the entities. The lib provides some implementations like MooreCell2d or MooreCell3d for cells and ConwayCellState, WireWorldCellState, etc 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.

Pausing

Inserting a SimulationPause resource will pause the simulation, removing it wil resume the it.

Parallel execution and batching

Inserting a SimulationBatch resource will allow parallel computation of cells with custom batch sizes.

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:
    • MooreCell2d (square cell with 8 neighbors)
    • NeumannCell2d (square cell with 4 neighbors)
    • HexagonCell2d (hexagon cell with 6 neighbors)
    • plugin presets: GameOfLife2dPlugin, ImmigrationGame2dPlugin, RainbowGame2dPlugin, WireWorld2dPlugin, CyclicAutomaton2dPlugin
  • 3D: Enables 3D types like:
    • MooreCell3d (cube cell with 26 neighbors)
    • NeumannCell3d (cube cell with 6 neighbors)
    • plugin presets: GameOfLife3dPlugin, ImmigrationGame3dPlugin, RainbowGame3dPlugin, WireWorld3dPlugin, CyclicAutomaton3dPlugin
  • auto-coloring (Example or debug purpose):
    • Enables CellStateMaterials resource to contain material handles
    • The CellState type now requires to build a CellStateMaterials
    • All CellState components with materials will be colored according to their type.

Disclaimer

This is probably not the fastest rust implementation of a cellular automaton in rust. For example, using Gosper's HashLife a classic game of life could be much faster.

This library aim is to be generic and dynamic, so that you can integrate cellular automata to any project in bevy, with any rules, in 2D or 3D.

Example projects

Wire World

The wireworld-rs project uses bevy_life and wireworld rules to simulate electrical systems.

Alt

Alt

Internal Examples

For every example pressing space reloads the board.

Note: adding the release flag increases performance for examples

2D Game of life

Run cargo run --example 2d_game_of_life --features auto-coloring

Alt

2D Immigration game

Run cargo run --example 2d_immigration_game --features auto-coloring

Alt

2D Rainbow game

Run cargo run --example 2d_rainbow_game --features auto-coloring

Alt

2D Cyclic colors

Run cargo run --example 2d_cyclic_colors --features auto-coloring

Alt

3D Game of life (4555 rule)

Run cargo run --example 3d_game_of_life --features "3D auto-coloring" --no-default-features

Alt

You might also like...
A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves
A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves

bevy_pen_tool A Bevy Engine plugin for making 2D paths and smooth animations with Bezier curves TODO: Mesh-making functionality for building 2D shapes

A procedural sky plugin for bevy

bevy_atmosphere A procedural sky plugin for bevy Example use bevy::prelude::*; use bevy_atmosphere::*; fn main() { App::build() .insert_re

Verlet physics plugin for bevy.
Verlet physics plugin for bevy.

bevy_verlet Simple Verlet points and sticks implementation for bevy. Features You can simply add a VerletPoint component on any entity with a Transfor

Bevy plugin for an AssetServer that can load embedded resources, or use other AssetServers based on the path.

Bevy-Embasset Embed your asset folder inside your binary. bevy-embasset adds support for loading assets embedded into the binary. Furthermore, it can

Hanabi — a particle system plugin for the Bevy game engine.

Hanabi — a particle system plugin for the Bevy game engine

A plugin to use the kajiya renderer with bevy

🕊️ 💡 bevy-kajiya A plugin that enables use of the kajiya renderer in bevy WARNING: This plugin is barebones and supports a limited set of features.

Tweening animation plugin for the Bevy game engine.
Tweening animation plugin for the Bevy game engine.

🍃 Bevy Tweening Tweening animation plugin for the Bevy game engine. Features Animate any field of any component or asset, including custom ones. Run

Bevy engine + miniquad render plugin

Bevy engine + miniquad renderer This is a plugin for Bevy engine that replaces default windowing and rendering plugins with miniquad based one. Usage

A plugin to enable random number generation for the Bevy game engine.

bevy_turborand A plugin to enable random number generation for the Bevy game engine, built upon turborand. Implements ideas from Bevy's Deterministic

Comments
  • Handle pausing

    Handle pausing

    Is your feature request related to a problem? Please describe.

    Apps using this lib can't pause or control the simulation state

    Describe the solution you'd like

    • We can add a resource which enables or not the systems Describe alternatives you've considered

    • There is a costly option to remove the components

    • To have generic control over the systems running, the plugin should be able to take a generic running_state as a field to control wether the systems are running or not. This is probably the best solution but we can't have additional run criterias

    enhancement 
    opened by ManevilleF 0
  • Performance and diagnostics

    Performance and diagnostics

    • [X] Using bevy hashmap instead of the cryptographically secure one
    • [X] Improve examples to allow complete diagnostics
    • [X] Batch the auto-coloring systems
    • [x] Benchmark costs and compare with other bevy versions
    opened by ManevilleF 0
  • Feat/new cells

    Feat/new cells

    • [X] Cell query batching
    • [X] New cells:
      • [X] Renamed classic cells to Moore cells
      • [X] Von Neumann cells
    • [X] New cell states:
      • [X] Immigration game cell state
      • [X] Rainbow game cell state
      • [X] 4555 Conway game of life cell state (for 3d)
    • [X] Code cleanup for auto-coloring
    • [X] New examples:
      • [X] Immigration game example
      • [X] Rainbow game example
      • [X] 3D game of life example
    • [X] Changelog
    • [X] README demo gifs
    opened by ManevilleF 0
Owner
Félix Lescaudey de Maneville
French
Félix Lescaudey de Maneville
3d Cellular Automata using WGPU in Rust (for the web and using compute shaders)

3D-Cellular-Automata-WGPU 3d Cellular Automata using WGPU in Rust (for the web and using compute shaders) The branches are very messy... I recommend y

null 18 Dec 18, 2022
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sélène Amanita 11 May 28, 2023
A Bevy plugin for loading the LDtk 2D tile map format.

bevy_ldtk ( Tileset from "Cavernas" by Adam Saltsman ) A Bevy plugin for loading LDtk tile maps. Usage use bevy::prelude::*; use bevy_ldtk::*; fn mai

Katharos Technology 23 Jul 4, 2022
Inspector plugin for the bevy game engine

bevy-inspector-egui This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where

Jakob Hellermann 517 Dec 31, 2022
A plugin for Egui integration into Bevy

bevy_egui This crate provides a Egui integration for the Bevy game engine. Features: Desktop and web (bevy_webgl2) platforms support Clipboard (web su

Vladyslav Batyrenko 453 Jan 3, 2023
Crossterm plugin for the bevy game engine

What is bevy_crossterm? bevy_crossterm is a Bevy plugin that uses crossterm as a renderer. It provides custom components and events which allow users

null 79 Nov 2, 2022
A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

Niklas Eicker 172 Jan 5, 2023
A prototype plugin providing a simple line drawing api for bevy.

bevy_debug_lines A prototype plugin providing a simple line drawing api for bevy. See docs.rs for documentation. Expect breakage on master. Click on t

Michael Palmos 92 Dec 31, 2022
Bevy plugin helping with asset loading and organisation

Bevy asset loader This Bevy plugin reduces boilerplate when loading game assets. The crate offers the AssetCollection trait and can automatically load

Niklas Eicker 205 Jan 2, 2023
A sprite-sheet animation plugin for bevy

Benimator A sprite sheet animation plugin for bevy Features A SpriteSheetAnimation component to automatically update the indices of the TextureAtlasSp

Jonathan Cornaz 140 Dec 27, 2022