Module type Types.Rule


module type Rule = sig .. end
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 simple Rule.Cyclic

val name : string
type state 
type configuration = state array 
val states : state array
All the possible states
val initialize : int -> configuration
initialize 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)).


graphics


val color_of_state : state -> Graphics.color