module Totalizing: sig
.. end
Totalizing rules, ie rules that depends only on the sum of the states of theirs neighbours
(includes the famous Conway's game of life, majority).
A transition rule is respresented as a "transition matrix" map:
mat.(current_state).(sum_of_neighbours) is the next state.
For instance,
[[0;0;0;1;0;0;0;0;0];[0;0;1;1;0;0;0;0;0]]
is the game of life,
[[0;0;0;0;0;1;1;1;1];[0;0;0;0;1;1;1;1;1]]
is 2D box neighborhood majority
[[0;0;0;1;1];[0;0;1;1;1]]
is 2D diamond neighborhood majority
[[1;1;1;1;1;0;0;0;0];[1;1;1;1;0;0;0;0;0]]
is 2D box neighborhood antimajority
[[1;1;1;0;0];[1;1;0;0;0]]
is 2D diamond neighborhood antimajority
Beware that no check on bounds are done,
except those done while applying the rule and supressed by the -unsafe to the compiler.
val transition_rule : int list list -> int array array -> bool array -> int -> bool
module type Parameters = sig
.. end
module Automaton: