Patched incorrect length measurement of hex string rule specifications for CA rules

This commit is contained in:
joseph.lizier 2012-10-26 08:20:48 +00:00
parent bb969f7d2c
commit a75b1ebf07
2 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,6 @@
%
% function plotLocalInfoMeasureForCA(neighbourhood, base, rule, cells, timeSteps, measureId, measureParams, options)
%
% Plot one run of the given CA and compute and plot a local information dynamics profile for it
%
% Inputs:
% - neighbourhood - neighbourhood size for the rule (ECA has neighbourhood 3).

View File

@ -58,6 +58,9 @@ function [caStates, ruleTable, executedRules] = runCA(neighbourhood, base, rule,
ruleTable = zeros(base .^ neighbourhood, 1);
if (ischar(rule))
% First remove the "0x" from the front of the rule name:
rule = strrep(rule, "0x", "");
% The rule is specified as a hex string - necessary for larger rule values
% Check that the rule length is not larger than it should be:
if (length(rule)*4 > length(ruleTable))
@ -70,6 +73,7 @@ function [caStates, ruleTable, executedRules] = runCA(neighbourhood, base, rule,
% starting from the least significant hex digit:
hexDigit = rule(x);
if (strcmp("x", hexDigit))
% (Can't happen since we removed the 0x already ...)
% We've reached the end of the hex string
break;
end