Cellular Automata, CA, in Python.
- easy to add new rules, check Rule30
- you can even witch rules during compute
- multiple dimensions universes (1d and 2d) support
- support multiply cell types in one universe
- support customized neighbour search
- unit tests (more is coming)
pip install pycax
- Clone the code
- Install libraries:
pip install -r requirements.txt
- Pick a script form
example/
folder - Magic...
from pyca.universe1d import Universe1D
from pyca.rules.Rules import Rule30
from pyca.observer import plot1d_universe
universe = Universe1D(300)
universe.register_cell_type(Rule30, 'random', prob=0.5)
universe.initialize()
universe.compute(300)
plot1d_universe(universe)
Or for classic rulexxx system, you can just pus a str represent rule for ClassicRule!
from pyca.universe1d import Universe1D
from pyca.rules.BaseRule import ClassicRule
from pyca.observer import plot1d_universe
size = 600
universe = Universe1D(size)
universe.register_cell_type(ClassicRule, 'single', pos=size-1, rule='01101110') # Rule110 here
universe.initialize()
universe.compute(size)
plot1d_universe(universe)
- Universe, contains all the cells, and function to trigger computation
- CellType, rule of the cell is defined here
- observer, way to observe universe, well it can be visual, but it can also be something else, like sounds!
Currently, 2 2D universe is supported, you can define a CA by injecting a new type of CellType.
- 3D universe
- HyperGraph Universe
- Interactive Observers
- Musical Observers
http://psoup.math.wisc.edu/mcell/rullex_cycl.html
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
https://en.wikipedia.org/wiki/Rule_30