Specify rules for 2D cellular automaton?
The example where $A = C$ and $B = D$ can be achieved using GrowthSurvivalCases
option of CellularAutomata
(as of Mathematica 11.1, I believe):
init = CenterArray[{30, 30}];
res = CellularAutomaton[<|
"Dimension" -> 2,
"GrowthSurvivalCases" -> {
{1, 3, 5, 7},
{1, 3, 5, 7}
}|>, init, 15];
Partition[ArrayPlot /@ res, 3] // Grid
The following code worked for me:
a = {0, 2, 4, 6, 8};
b = {1, 3, 5, 7};
c = {0, 2, 4, 6, 8};
d = {1, 3, 5, 7};
Manipulate[
Row[{cell3 = CellularAutomaton[{
Which[
MemberQ[a,
Mod[Total[# - #[[2, 2]], \[Infinity]], 2]] \[And] #[[2,
2]] == 0, 0,
MemberQ[b,
Mod[Total[# - #[[2, 2]], \[Infinity]], 2]] \[And] #[[2,
2]] == 0, 1,
MemberQ[c,
Mod[Total[# - #[[2, 2]], \[Infinity]], 2]] \[And] #[[2,
2]] == 1, 0,
MemberQ[d,
Mod[Total[# - #[[2, 2]], \[Infinity]], 2]] \[And] #[[2,
2]] == 1, 1
] &,
{}, {1, 1}}, {{{1}}, 0}, {{{i}}}],
ArrayPlot[cell3, ImageSize -> 300, Mesh -> True,
MeshStyle -> Red]}],
{i, 0, 10, 1}]
It's a bit clumsy as this is my first time working with cellular automata but I think it works. I may not be understanding the math behind the automata correctly, but I'm not sure if the "GrowthSurvivalCases" option will get you exactly what you want if we have $A \neq C$ and $B \neq D$.
The documentation states:
With "GrowthSurvivalCases"->{{Subscript[g, 1],[Ellipsis]},{Subscript[s, 1],[Ellipsis]}}, a cell goes from value 0 to value 1 if it has Subscript[g, i] neighbors that are 1, maintains value 1 if it has Subscript[s, i] neighbors that are 1, and otherwise gets value 0.
In this case, the $g_i$ correspond to $B$ and the $s_i$ correspond to $D$, but regardless of whether a cell was previously dead or alive, it will be switched to dead if the number is not listed in $B$ or $D$, which is why I used the Which
to test all 4 cases instead.