% This is not setup like Wolfram's! I don't know how he represents the
% concept of a cell staying the same in binary. I tried different ideas
% w/o success. My system uses a value one higher than your cell value
% choices to represent staying the same. But my code numbers will be
% different from his. GOL is 45
clear neighbors 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-1)*8)+1;
rulenumberbinaryfirst=dec2base(rulenumber,rulecolors+1,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.