Code covered by the BSD License  

Highlights from
Digital Karma: State Graphing

image thumbnail
from Digital Karma: State Graphing by Aman Siddiqi
Evolutionary Simulation, Interaction Graph

rules_oned_nearest_neighbor_setup.m
clear rulenumber* changetoo*
ruletotalvalue=inputdlg({'Rule Number','Number of Possible Colors(Cell Values)'},'',1);
rulenumber=ruletotalvalue{1};
rulecolors=ruletotalvalue{2};
rulenumber=eval(rulenumber);
rulecolors=eval(rulecolors);
possiblestates=rulecolors^3;
rulenumberbinaryfirst=dec2base(rulenumber,rulecolors,possiblestates);
rulenumberbinary=num2matrix(rulenumberbinaryfirst);



% Rulenumberbinary is a number with as many digits as states.
% The rule number converted to base "rulecolors" equals the results for each
% possible state in that rule.
% Rulenumber equals base2dec('rulebinary',rulecolors)
% You can generate rulebinary then solve for the rule number.


% colors^states=possible states  (2^3=8)
% colors^possible states=possiblerules  (2^8=256)
% Each state has a result. Those results are converted to a rule number in
% base 10 from base "colors." 00010010=18
% Each state is converted to a state number from base "colors."
% 111=8.  The "state number"(8th) place of the rule number's base "colors"
% form(00010010) is the result for that state.  111 produces 0.

% Ex. 10 colors nearest neighbors has 1,000 states(10^3
% & 10^1,000 possible rules(1followed by 1,000 zeros).
% The state 692 equals 692 in base "colors."
% The 692nd place in the one-thousand digit long number equaling the
% particular rule is the result for 692.

Contact us at files@mathworks.com