|
@@ -24,7 +24,7 @@ public class Goldfish { |
|
|
if (_render.reset) {
|
|
|
if (_render.reset) {
|
|
|
setup(_render.rule);
|
|
|
setup(_render.rule);
|
|
|
_render.reset = false;
|
|
|
_render.reset = false;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
if (!_render.paused) {
|
|
|
if (!_render.paused) {
|
|
|
String rule = _render.rule;
|
|
|
String rule = _render.rule;
|
|
|
if (rule.equals("Conway"))
|
|
|
if (rule.equals("Conway"))
|
|
@@ -55,24 +55,24 @@ public class Goldfish { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
private void setup(String rule) {
|
|
|
private void setup(String rule) {
|
|
|
if(rule.equals("Conway")) {
|
|
|
|
|
|
int[][] glidergun = {
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
|
|
|
|
|
|
{1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
|
|
|
|
|
};
|
|
|
|
|
|
for(int i = 0; i < 36; i++) {
|
|
|
|
|
|
for(int j = 0; j < 9; j++) {
|
|
|
|
|
|
_grid.getPatch(i+2,j+2).setState(glidergun[j][i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (rule.equals("Life Without Death")) {
|
|
|
|
|
|
|
|
|
if(rule.equals("Conway")) {
|
|
|
|
|
|
int[][] glidergun = {
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
|
|
|
|
|
|
{1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
|
|
|
|
|
|
{0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
|
|
|
|
|
|
};
|
|
|
|
|
|
for(int i = 0; i < 36; i++) {
|
|
|
|
|
|
for(int j = 0; j < 9; j++) {
|
|
|
|
|
|
_grid.getPatch(i+2,j+2).setState(glidergun[j][i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (rule.equals("Life Without Death")) {
|
|
|
int[][] pattern = {
|
|
|
int[][] pattern = {
|
|
|
{1,1,1,1,0,1},
|
|
|
{1,1,1,1,0,1},
|
|
|
{1,0,1,1,1,1}
|
|
|
{1,0,1,1,1,1}
|
|
@@ -83,7 +83,16 @@ public class Goldfish { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if (rule.equals("Brian's Brain")) {
|
|
|
} else if (rule.equals("Brian's Brain")) {
|
|
|
_render.randomize();
|
|
|
|
|
|
|
|
|
int[][] pattern = {
|
|
|
|
|
|
{2,0,2,0,2},
|
|
|
|
|
|
{2,0,2,0,2},
|
|
|
|
|
|
{0,1,0,1,0}
|
|
|
|
|
|
};
|
|
|
|
|
|
for(int i = 0; i < 5; i++) {
|
|
|
|
|
|
for(int j = 0; j < 3; j++) {
|
|
|
|
|
|
_grid.getPatch(i+((_grid.getHeight()-5)/2),j+((_grid.getWidth()-3)/2)).setState(pattern[j][i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|