Implementation of general cellular automata

With k colors and r neighbors on each side, a single step in the evolution of a general cellular automaton is given by

CAStep[CARule[rule_List, k_, r_], a_List] := rule〚-1 - ListConvolve[k^Range[0, 2r], a, r + 1]〛

where rule is obtained from a rule number num by IntegerDigits[num, k, k^{2r + 1}]. (See also page 927.)