Also update places where it isn't needed.master
@@ -9,15 +9,21 @@ public class Grid { | |||||
_grid[0][0] = new Patch(this, 0, 0, 0); | _grid[0][0] = new Patch(this, 0, 0, 0); | ||||
} | } | ||||
public Grid(int x, int y) { | |||||
public Grid(int x, int y, boolean fill) { | |||||
_grid = new Patch[y][x]; | _grid = new Patch[y][x]; | ||||
for (int i = 0; i < x; i++) { | |||||
for (int j = 0; j < y; j++) { | |||||
_grid[j][i] = new Patch(this, i, j, 0); | |||||
if (fill) { | |||||
for (int i = 0; i < x; i++) { | |||||
for (int j = 0; j < y; j++) { | |||||
_grid[j][i] = new Patch(this, i, j, 0); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public Grid (int x, int y) { | |||||
this(x,y,true); | |||||
} | |||||
private int normalizeX(int x) { | private int normalizeX(int x) { | ||||
while (x >= getWidth()) | while (x >= getWidth()) | ||||
x -= getWidth(); | x -= getWidth(); | ||||
@@ -7,7 +7,7 @@ public class BriansBrain extends RuleSet { | |||||
public static int states = 3; | public static int states = 3; | ||||
public static Grid run(Grid g) { | public static Grid run(Grid g) { | ||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight()); | |||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight(), false); | |||||
for (int i = 0; i < g.getWidth(); i++) { | for (int i = 0; i < g.getWidth(); i++) { | ||||
for (int j = 0; j < g.getHeight(); j++) { | for (int j = 0; j < g.getHeight(); j++) { | ||||
Patch[] neighbors = g.getPatch(i, j).get8Neighbors(); | Patch[] neighbors = g.getPatch(i, j).get8Neighbors(); | ||||
@@ -7,7 +7,7 @@ public class Conway extends RuleSet { | |||||
public static int states = 2; | public static int states = 2; | ||||
public static Grid run (Grid g) { | public static Grid run (Grid g) { | ||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight()); | |||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight(), false); | |||||
for (int i = 0; i < g.getWidth(); i++) { | for (int i = 0; i < g.getWidth(); i++) { | ||||
for (int j = 0; j < g.getHeight(); j++) { | for (int j = 0; j < g.getHeight(); j++) { | ||||
Patch[] neighbors = g.getPatch(i, j).get8Neighbors(); | Patch[] neighbors = g.getPatch(i, j).get8Neighbors(); | ||||
@@ -8,7 +8,7 @@ public class Conway4 extends RuleSet { | |||||
public static int states = 2; | public static int states = 2; | ||||
public static Grid run (Grid g) { | public static Grid run (Grid g) { | ||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight()); | |||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight(), false); | |||||
for (int i = 0; i < g.getWidth(); i++) { | for (int i = 0; i < g.getWidth(); i++) { | ||||
for (int j = 0; j < g.getHeight(); j++) { | for (int j = 0; j < g.getHeight(); j++) { | ||||
Patch[] neighbors = g.getPatch(i, j).get4Neighbors(); | Patch[] neighbors = g.getPatch(i, j).get4Neighbors(); | ||||
@@ -8,7 +8,7 @@ public class LifeWithoutDeath extends RuleSet { | |||||
public static int states = 2; | public static int states = 2; | ||||
public static Grid run (Grid g) { | public static Grid run (Grid g) { | ||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight()); | |||||
Grid newGrid = new Grid(g.getWidth(), g.getHeight(), false); | |||||
for (int i = 0; i < g.getWidth(); i++) { | for (int i = 0; i < g.getWidth(); i++) { | ||||
for (int j = 0; j < g.getHeight(); j++) { | for (int j = 0; j < g.getHeight(); j++) { | ||||
Patch[] neighbors = g.getPatch(i, j).get8Neighbors(); | Patch[] neighbors = g.getPatch(i, j).get8Neighbors(); | ||||