Package: cellpylib3d
CellPyLib 3DCellPyLib is a library for working with 1- and 2-dimensionalk-color Cellular Automata in Python. CellPyLib-3d is an extension of this library, bringing support for 3-dimensional and 2-dimensional layered automata.Example usage:importcellpylib3d# empty 3d gridgrid=cellpylib3d.init_simple3d(10,10,10,val=0)# init empty 3d grid# oscilating shape from donutgrid[:,[3,3,3,4,4,5,5,6,6,7,7,7],4,[4,5,6,3,7,3,7,3,7,4,5,6]]=1# run using GOL ruleset for N timestepscellular_automaton=cellpylib3d.evolve3d(grid,timesteps=50,neighbourhood='Moore',apply_rule=cellpylib3d.game_of_life_rule_3d)# animatecellpylib3d.plot3d_animate(cellular_automaton,title='3D Game of Life')importcellpylib3d# empty 3d gridgrid=cellpylib3d.init_simple3d(10,10,7,val=0)# init empty 3d grid# oscilating shape from donutgrid[:,[3,3,3,4,4,5,5,6,6,7,7,7],4,[4,5,6,3,7,3,7,3,7,4,5,6]]=1# each layer requires a separate rulerules=[cellpylib3d.game_of_life_rule_parallel,]*7# run using GOL ruleset for N timestepscellular_automaton=cellpylib3d.evolveParallel(grid,timesteps=50,neighbourhood='Moore',apply_rules=rules)# animatecellpylib3d.plotParallel_animate(cellular_automaton,title='Parallel Game of Life')Getting StartedCellPyLib can be installed via pip:pip install cellpylib3dRequirements for using this library are Python 3.7, NumPy, and Matplotlib. This extension library largely followsHave a look at the documentation, located atcellpylib.org, for more information.3D extensionsInitialising 3d automataArguments for tabled functions mirror 2d equivalent CellPyLibinit_simple2dandinit_random2dfunctions, unless noted.FuncSpecial ArgsDocsinit_simple3dRequires additionallayersarg.Returns a matrix initialized with zeroes, with its center value set to the specified value, or 1 by default.init_random3dRequires additionallayersarg.Returns a randomly initialized matrix with values consisting of numbers in {0,...,k - 1}, where k = 2 by default.EvolvingArguments for tabled functions mirror 2d equivalent CellPyLibevolve2dfunction.FuncDocsevolve3dEvolve cellular automata in 3-dimensional space using 3d-aware ruleset.PlottingArguments for tabled functions mirror 2d equivalent CellPyLibplot2dandplot2d_animatefunctions, unless notedFuncSpecial ArgsDocsplot3dReplacescmapargument with options for voxel cube face color and edge color (defaultsface_color='#1f77b4',edge_color='gray')Plot 3d CA at given timestep using voxels.plot3d_animateReplacescmapargument with options for voxel cube face color and edge color (defaultsface_color='#1f77b4',edge_color='gray')Animate 3d CA using voxels.Parallel extensionsParallel CA are a more customisable form of 3d CA. Instead of applying a single 3d-aware ruleset to an entire CA, each layer of a parallel CA can have a seperate ruleset. This can be helpful for simulations with weak interaction between layers.Initialising parallel automataInitialise your CA using the 3d functions described above. Parallel CA are treated at regular 3d shapes at a base level.EvolvingArguments for tabled functions mirror 2d equivalent CellPyLibevolve2dfunction.FuncDocsevolveParallelEvolve a layers of a 3d cellular automata using seperate 2D/3d-aware rulesets.PlottingArguments for tabled functions mirror 2d equivalent CellPyLibplot2dandplot2d_animatefunctions.FuncDocsplotParallelSlice the 3D CA and subplot each layer for a given timestep.plotParallel_animateSlice the 3D CA and animate each subplot of each layer.DevelopmentCreate a Conda environment from the provided environment YAML file:$ conda env create -f environment.ymlDocumentationTo build the Sphinx documentation locally, from thedocdirectory:$ make clean htmlThe generated files will be in_build/html.To build the documentation for publication, from thedocdirectory:$ make githubThe generated files will be in_build/htmland in thesite/docsfolder.TestingThere are a number of unit tests for this project. To run the tests:$ python3 -m pytest testsIf thepytest-covpackage is installed, a coverage report can be generated by running the tests with:$ python3 -m pytest tests/ --cov=cellpylib3dLicenseApache License 2.0