mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
More subtle bugfixes
This commit is contained in:
66
scripts/rule110.toy
Normal file
66
scripts/rule110.toy
Normal file
@@ -0,0 +1,66 @@
|
||||
var size: int const = 100;
|
||||
|
||||
var prev = [];
|
||||
for (var i = 0; i < size; i++) {
|
||||
prev.push(false);
|
||||
}
|
||||
|
||||
prev.set(size - 1, true);
|
||||
|
||||
|
||||
fn calc(p, i) {
|
||||
if (p[i-1] && p[i] && p[i+1]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p[i-1] && p[i] && !p[i+1]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p[i-1] && !p[i] && p[i+1]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p[i-1] && !p[i] && !p[i+1]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!p[i-1] && p[i] && p[i+1]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!p[i-1] && p[i] && !p[i+1]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!p[i-1] && !p[i] && p[i+1]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!p[i-1] && !p[i] && !p[i+1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (var iteration = 0; iteration < 100; iteration++) {
|
||||
var line = [false];
|
||||
for (var i = 1; i < size-1; i++) {
|
||||
line.push(calc(prev, i));
|
||||
}
|
||||
line.push(false);
|
||||
|
||||
var output = "";
|
||||
for (var i = 0; i < line.length(); i++) {
|
||||
if (line[i]) {
|
||||
output += "*";
|
||||
}
|
||||
else {
|
||||
output += " ";
|
||||
}
|
||||
}
|
||||
|
||||
print output;
|
||||
prev = line;
|
||||
}
|
||||
Reference in New Issue
Block a user