cellular_automata 1.0.2

  • README.md
  • Example
  • Installing
  • Versions
  • 49

Cellular Automata #

Build Status Pub Package Version Latest Dartdocs

A cellular automata library / playground written in Dart. Happily accepting pull requests! ^_^

Features #

  • Simple system for writing optimised rules
  • MCell rules compatible, current systems supported:
    • MCell Generations
  • Generators to seed the simulation
  • Map states to colours/characters for rendering
  • Controls: pause, resume, stepBack, stepForward
  • Stale simulation detection (repeating generations or patterns in activity)
  • Utilises the package:logging for debug & info (view on pub)
  • Decoupled renderers:
    • Canvas: (Web), fullscreen support
    • StageXL: (Web), WebGL, fullscreen support, (performance issues with big scenes)

Implemented rules/simulations #

  • Conway's Game of Life (source)
  • Conway's Game of Life Simple (binary states) (source)
  • Brian's Brain (source)
  • Majority Vote (source)
  • MCell Generations rule parser. See the demos including:
    • Star Wars
    • Rake
    • Star Wars
    • Sedi Mental
    • Frozen Sprials

Examples #

See the examples/ folder for some simple code examples.

Web demos #

See the demos/ folder for demos. You can try the hosted demos here.

Roadmap #

  • En route: Multiple simulations/rule-sets running in a single scene
  • En route: Flutter renderer
  • Add more MCell rule parsers
  • Add MCell rule database
  • Add multiple states to 'Majority Vote'
  • Add visual feedback to show processing of simulations - useful whilst building and debugging
  • Support for entities to exist which would allow for simulations such as Langton's Ant
  • Add a multiple states generator
  • Add more tests
  • Transitions for switching between two simulations
  • Generated color palettes
  • Interactive mode (edit mode)
  • Analysis tools (histograms for state counts)
  • Add an LED Matrix renderer for raspberry pi using GPIO pins
  • Hexagonal grids
  • Infinite world size support

Credits #

Please see the credits file for a list of the authors that discovered the rules that have been implemented in this project.

Licence #

Please see the cellular_automata license.

Changelog #

1.0 #

  • Web renderers have been moved into a new package: cellular_automata_web. This core package can now be loaded into none web enviroments such as flutter etc.
  • example/ folder now contains numerous ascii based examples that can be run from command-line
  • Player renamed Scene
  • Simulator renamed Automaton
  • onRender renamed onPaint
  • SimulationCompleteReason renamed SceneCompleteReason
  • onPaintFull now available which will paint a full scene every generation. Note: This is a not as performant as onPaint which will only paints the changes in a scene
  • AsciiRenderer added. This is a very simple text based renderer, used in the examples.
  • onPrepare fired before scene starts running. This is when a generator could be used to seed the automaton.
  • Now supports multiple automata running in a single scene. used addAutomaton() to add automata.
  • Recased all enums to camel case.

0.9 #

0.8 #

  • MCellGenerations rule parser added. This can parse all MCell Generations configs.
  • Credits
  • onStable renamed onComplete, now passes SimulatorCompleteReason enum value. Current states are: duration and stable
  • Demos updated to include MCell
  • Credits file created to credit those that wrote/discovered the rules
  • Decent Refactor, reorganised stuff!
    • Simulator renamed Player
    • Array2D replaced with CellGrid which combines Array2D with CA specific functionality which simplifies CellWorld.
    • CARules interface updated
    • CellWorld renamed Simulator

0.7 #

  • Optimised MajorityVote Rules, utilises edge detection to determine activity
  • Added paintFullSize option to CanvasRenderer: This allows the scene to be painted at actual size rather than small and then resized via CSS.
  • Added maxAge as a Simulator constructor parameter, if this is set then onStable is called when the generation count surpasses maxAge
  • Added package:logging so debug information can be enabled / disabled
  • Updated demos

0.6 #

  • Stable simulation detection. This broadcast to the onStable stream after detecting repeating identical generations or repeating generation activeCellCount patterns spanning up to 8 generations.
  • Demos updated to auto reset on stable scene (excluding rendering examples)

0.5 #

  • Added new default renderer for web: CanvasRenderer. This is a simple native Canvas renderer. This has been added as StageXLRenderer has performance issues with large scenes.
  • Added demos for both StageXLRenderer and CanvasRenderer
  • Demos moved over to use CanvasRenderer

0.4 #

  • Added MajorityVote Rules
  • Optimised BriansBrain processing
  • Updated demos

0.3 #

  • Added GameOfLifeSimple Rules. This simulation is a simpler version of GameOfLife, it only has binary states and implemented with minimal code
  • Added BriansBrain Rules
  • Updated demos

0.2 #

  • Optimised cell processing, now only processes cells that neighbor active states
  • Added tests (more to add)
  • Improved StageXL bitmap colours crispness by adding frame margin

0.1 #

  • Refactored so Rule's cell-states are now passed as generic types in to the Cell World for better analyzer & tooling support
  • Added a CAGenerators for generating/seeding worlds
  • Renderers are now further decoupled from the Simulation. They now just require an CellGrid containing states expressed in a palette.
  • Added a very simple demo (simple_example.dart) to show minimum setup code
  • CellWorld now stores full cell-states and Rules also deal with full cell-states which makes code more readable
  • Fixed mathematical generators

0.0 #

  • Initial version, includes basic implementation of GameOfLife with StageXLRenderer
  • Hosted demos


import 'package:cellular_automata/cellular_automata.dart';
import 'package:cellular_automata/rules.dart';
import 'package:cellular_automata/renderer_ascii.dart';

// Simple example showing the 'Brian Brain' automaton.
// For prettier outputs see the platform specific renderers
// Run in terminal with command: pub run example/example.dart
void main() {
  final width = 48;
  final height = 22;

  final palette = new Map<BriansBrainStates, String>.from({
    BriansBrainStates.dead: '_',
    BriansBrainStates.dying: 'x',
    BriansBrainStates.living: 'O'

  final AsciiRenderer renderer = new AsciiRenderer();
  final scene = new Scene<String>(
    width: width,
    height: height,
    fpsTarget: 10,
    ..onPrepare.listen((int count) {
            automaton: new Automaton<BriansBrainStates, String>(
          width: width,
          height: height,
          defaultState: BriansBrainStates.dead,
          palette: palette,
          wrap: true,
          rules: new BriansBrain(),
        )..applyGenerator(new MathematicalGenerator<BriansBrainStates>(
                type: MathematicalGenerators.random,
                valueTrue: BriansBrainStates.living,
                valueFalse: BriansBrainStates.dead)));
    ..onFullPaint.listen((CellGrid<String> snapshot) {
    ..onComplete.listen((SceneCompleteReason s) {
      print('All done! (Generation ${scene.generationCounter})');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  cellular_automata: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:cellular_automata/cellular_automata.dart';
Version Uploaded Documentation Archive
1.0.2 Jul 27, 2018 Go to the documentation of cellular_automata 1.0.2 Download cellular_automata 1.0.2 archive
1.0.1 Jul 9, 2018 Go to the documentation of cellular_automata 1.0.1 Download cellular_automata 1.0.1 archive
1.0.0 Jul 5, 2018 Go to the documentation of cellular_automata 1.0.0 Download cellular_automata 1.0.0 archive
0.8.0 Jul 9, 2017 Go to the documentation of cellular_automata 0.8.0 Download cellular_automata 0.8.0 archive
0.7.0 Jul 7, 2017 Go to the documentation of cellular_automata 0.7.0 Download cellular_automata 0.7.0 archive
0.6.0 Jul 5, 2017 Go to the documentation of cellular_automata 0.6.0 Download cellular_automata 0.6.0 archive
0.5.0 Jul 4, 2017 Go to the documentation of cellular_automata 0.5.0 Download cellular_automata 0.5.0 archive
0.4.0 Jul 4, 2017 Go to the documentation of cellular_automata 0.4.0 Download cellular_automata 0.4.0 archive
0.3.0 Jul 3, 2017 Go to the documentation of cellular_automata 0.3.0 Download cellular_automata 0.3.0 archive
0.2.0 Jul 2, 2017 Go to the documentation of cellular_automata 0.2.0 Download cellular_automata 0.2.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:cellular_automata/cellular_automata.dart.

Health suggestions

Fix lib/src/automaton.dart. (-1 points)

Analysis of lib/src/automaton.dart reported 2 hints:

line 33 col 11: Use = to separate a named parameter from its default value.

line 73 col 21: Use = to separate a named parameter from its default value.

Fix lib/src/scene.dart. (-1 points)

Analysis of lib/src/scene.dart reported 2 hints:

line 126 col 37: Use = to separate a named parameter from its default value.

line 137 col 49: Use = to separate a named parameter from its default value.

Fix lib/src/rules/_ca_rules.dart. (-0.50 points)

Analysis of lib/src/rules/_ca_rules.dart reported 1 hint:

line 14 col 24: Use = to separate a named parameter from its default value.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.61.0 <3.0.0
logging ^0.11.3+2 0.11.3+2
Dev dependencies
test ^1.3.0