zasim.cagen - Programmatically generating CAsΒΆ

Zasim offers a package for generating all the code needed to create and run a step function without having to re-write boilerplate code. This is achieved by offering a lot of re-usable components.

See also

The tutorial section describes all classes involved in more detail and gives an example for how to make new Computation classes.

You can start with Assembling a custom StepFunc.

This package also contains pre-built simulators for commonly used cellular automata.

When creating a new computation, you only need to write the core computation once in C and once in python, the rest will be done for you by the components offered in this module.

The parts the step function is decomposed into are all subclasses of StepFuncVisitor. The base classes available are:

defines the order in which to loop over the configuration cells.
is responsible for writing to and reading from the configuration as well as knowing what shape and size the configuration has.
is responsible for getting the relevant fields for each local step.
handles the borders of the configuration by copying over parts or writing data. Maybe, in the future, it could also resize configurations on demand.
handles the computation that turns the data from the neighbourhood into the result that goes into the value for the next step.
compiles extra statistics, such as a histogram of the different cell states

All of those classes are used to initialise a StepFunc object, which can then target a configuration object with the method StepFunc.set_target().

This package is split into multiple modules:


The cagen package imports all classes from all submodules, so rather than writing

>>> from zasim.cagen.loops import OneDimCellLoop

you can also write

>>> from zasim.cagen import OneDimCellLoop

Previous topic

zasim.display.console - Painting ascii art

Next topic

zasim.cagen.stepfunc - The StepFunc class

This Page