Infer a ‘Gödel numbering’ from the used Neighbourhood and create a computation that corresponds to the rule’th possible combination of values for the neighbourhood cells.
This works with any number of dimensions.
Create the computation.
Supply None as the rule to get a random one.
This list stores a list of dictionaries that for each combination of values for the neighbourhood cells stores the ‘result_value’, too.
Get the rule’th cellular automaton for the given neighbourhood.
First, find out, how many possible combinations there are. That’s simply the nuber of cells in the neighbourhood as the exponent of the number of possible_values. Then, normalise the neighbourhood cells by sorting their positions first by X, then by Y axis. Finally, create code, that sums up all the values and looks up the target value from the rule lookup array.
Generate the rule lookup array and a pretty printer.
This method is generated upon init_once and pretty-prints the rules that this elementary cellular automaton uses for local steps.
This base class counts the amount of nonzero neighbours excluding the center cell and offers the result as a local variable called nonzerocount of type int.
The name of the central neighbour will be provided as self.central_name.
Generate code that calculates nonzerocount from all neighbourhood values.
This computation base is useful for any game-of-life-like step function in which the number of ones in the neighbourhood of a cell are counted to decide wether to change a 0 into a 1 or the other way around.
Generates the code that turns a 0 into a 1 if nonzerocount exceeds reproduce_min and doesn’t exceed reproduce_max and turns a 1 into a 0 if nonzerocount is lower than stay_alive_min or higher than stay_alive_max.