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

rulenumber=rulenumberencoder(rulenumberbinary,rulecolors, rule)
function rulenumber=rulenumberencoder(rulenumberbinary,rulecolors, rule)
% rulenumberbinary must be an array!

if strcmp(rule, 'rules_twod_totalistic') || strcmp(rule, 'rules_twod_totalistic_wrap')
    rulecolors=rulecolors+1; end; % these 2 rules adjust rule colors in their computation

[rulenumberbinaryrows,rulenumberbinarycols]=size(rulenumberbinary);
rulenumber=0;
for checking=0:rulenumberbinarycols-1;
    rulenumber=(rulenumberbinary(end-checking) * rulecolors^checking) + rulenumber;
end;

if strcmp(rule, 'rules_twod_totalistic') || strcmp(rule, 'rules_twod_totalistic_wrap')
    rulecolors=rulecolors-1; end; % these 2 rules adjust rule colors in their computation

Contact us at files@mathworks.com