Jason Cawley
Wolfram Science Group
Phoenix, AZ USA
Registered: Aug 2003
Posts: 712 |
They are outer totalistic rules, but sure code and rule refer to the same thing.
There are 10 cases in the rule table, you only give 9. (454 has a leading 0 case).
Rule 454 means with the input sides -
Tuples[{{4, 3, 2, 1, 0}, {1, 0}}]
and the output sides -
IntegerDigits[454, 2, 10]
The full mapping is then -
Rule @@@ Transpose[{Tuples[{{4, 3, 2, 1, 0}, {1, 0}}], IntegerDigits[454, 2, 10]}]
which evaluates to this rule list -
{{4, 1} -> 0, {4, 0} -> 1, {3, 1} -> 1, {3, 0} -> 1, {2, 1} -> 0, {2, 0} -> 0, {1, 1} -> 0, {1, 0} -> 1, {0, 1} -> 1, {0, 0} -> 0}
The built in function version of this rule can be run as e.g. -
data1 = CellularAutomaton[{454, {2, {{0, 2, 0}, {2, 1, 2}, {0, 2, 0}}}, {1, 1}}, {{{1}}, 0}, 20];
ArrayPlot[Last[data1]]
To use the rule table above, instead, you must construct the outer totals in a function e.g.
myCARule[neighborhood_] := With[{rulelist = Rule @@@ Transpose[{Tuples[{{4, 3, 2, 1, 0}, {1, 0}}], IntegerDigits[454, 2, 10]}]}, {neighborhood[[1, 2]] + neighborhood[[2, 1]] + neighborhood[[2, 3]] + neighborhood[[3, 2]], neighborhood[[2, 2]]} /. rulelist ]
then you'd evaluate that in the functional form of the CA function as -
ArrayPlot[Last[#]] &@ CellularAutomaton[{myCARule[#] &, {}, {1, 1}}, {{{1}}, 0}, 20]
Output checks. That is the scheme being used.
Report this post to a moderator | IP: Logged
|