Skip to content

Instantly share code, notes, and snippets.

@gidili
Created March 7, 2010 22:11
Show Gist options
  • Save gidili/324676 to your computer and use it in GitHub Desktop.
Save gidili/324676 to your computer and use it in GitHub Desktop.
% patterns
ruleSet.patterns = flipud(combn([0 1],ruleSize));
% declare transformation rules array - 148 bits (2^7) initialized to zero
gkl = zeros(1,2^ruleSize);
% GKL rule:
% If ci(t) = 0, then ci(t + 1) = majority [ci(t), ci-1(t) ci-3(t)];
% If ci(t) = 1, then ci(t + 1) = majority [ci(t), ci+1(t) ci+3(t)];
for j=1:2^ruleSize,
pattern = ruleSet.patterns(j,:);
if pattern(4) == 0,
if (pattern(4-1) && pattern(4-3)),
gkl(j) = 1;
end
else
if (pattern(4+1) || pattern(4+3)),
gkl(j) = 1;
end
end
end
% assign resulting transformations
ruleSet.transformations = gkl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment