module type Rule =A rule is a cellular automaton rule: given my state and the states of my neighbours, what's my next state; they are implemented in folder rule, like the simplesig
..end
Rule.Cyclic
val name : string
type
state
typeconfiguration =
state array
val states : state array
val initialize : int -> configuration
nb_cells
,
whatever the dimension. Small price to pay to get a lot of unifications in the code.val transition_rule : int array array -> configuration -> int -> state
transition_rule neighbourhoods
Do some computation on the neigbourhoods if needed, then returns a function
tr
such that
tr configuration index
returns the new state of the cell number index
in configuration
.
For optimization purposes (less memory allocation), this function receives
neighbourhoods and the index of the cell in the given configuration.
So the neighbours states are accessed by varying i
in
configuration.(neighbourhoods.(index).(i))
.
val color_of_state : state -> Graphics.color