Created
March 7, 2010 22:11
-
-
Save gidili/324676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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