浏览代码

Cool gun is cool.

Is it a gun?
master
Lee 12 年前
父节点
当前提交
03b94d7862
共有 1 个文件被更改,包括 29 次插入20 次删除
  1. +29
    -20
      src/Goldfish.java

+ 29
- 20
src/Goldfish.java 查看文件

@@ -24,7 +24,7 @@ public class Goldfish {
if (_render.reset) {
setup(_render.rule);
_render.reset = false;
}
}
if (!_render.paused) {
String rule = _render.rule;
if (rule.equals("Conway"))
@@ -55,24 +55,24 @@ public class Goldfish {
}
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 = {
{1,1,1,1,0,1},
{1,0,1,1,1,1}
@@ -83,7 +83,16 @@ public class Goldfish {
}
}
} 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]);
}
}
}
}


正在加载...
取消
保存