Global

Type Definitions

initializerFunction(row, col)

A function that initializes a cell on the grid based on its row and column value. This could be used for a typical random initialization, or something more exotic (e.g. stripes or a checkerboard pattern).
Parameters:
Name Type Description
row number The row of the cell to be initialized.
col number The column of the cell to be initialized.
Source:
Returns:
The intended initial value for the cell. The type can be whatever you want.

ruleset

A ruleset for a cellular automaton. If a single updateFunction is given, that function will be applied as a rule. If a list of updateFunctions are given, the overall rule will be the composition of functions, with the first function in the list being applied first, and so on.
Type:
Source:

updateFunction(neighbourhood, row, col)

A function that determines the state of a cell based on the state of its neighbours. The Moore neighbourhood (8 surrounding cells) is used, but obviously you could ignore some cells if you only care about the Von Neumann neighbourhood. Neighbourhoods of a greater radius are not currently supported. The additional "row" and "column" params can be used to make your rule's behaviour vary by location, or allow you to, for example, call some sort of draw function based on the location and value of each cell as you update it. IMPORTANT NOTE: If the contents of the cells in your automaton are objects or arrays, you should try not to modify them in your function, as they will also be modified in the array currently being used to create the new generation. This is done due to performance constraints. If you don't modify the state of any objects, and always return an either unchanged or brand new object from this update function, you should be fine. Anything else could result in unpredictable behaviour.
Parameters:
Name Type Description
neighbourhood The neighbourhood of the cell, expressed as a 3x3 array. Note that the centre cell, the cell whose value is to be determined, is equal to neighbourhood[1][1]. Elements can be of any type, but if using objects or arrays do not modify their state.
row number The cell's row index. Feel free to ignore this.
col number The cell's column index. Feel free to ignore this.
Source:
Returns:
The new value for the cell in question. This probably should have the same type as the contents of neighbourhood.