mirror of https://github.com/jlizier/jidt
Patched incorrect length measurement of hex string rule specifications for CA rules
This commit is contained in:
parent
bb969f7d2c
commit
a75b1ebf07
|
|
@ -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).
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue