@@ -15,20 +15,28 @@ public class Goldfish { | |||||
public void run () { | public void run () { | ||||
//TODO: make it run. | //TODO: make it run. | ||||
_grid.getPatch(0,1).setState(1); | |||||
_grid.getPatch(1,2).setState(1); | |||||
_grid.getPatch(2,2).setState(1); | |||||
_grid.getPatch(1,0).setState(1); | |||||
_grid.getPatch(2,1).setState(1); | _grid.getPatch(2,1).setState(1); | ||||
_grid.getPatch(2,0).setState(1); | |||||
_grid.getPatch(2,2).setState(1); | |||||
_grid.getPatch(1,2).setState(1); | |||||
_grid.getPatch(0,2).setState(1); | |||||
System.out.println(_grid); | System.out.println(_grid); | ||||
_grid = Conway.run(_grid); | _grid = Conway.run(_grid); | ||||
System.out.println("------------"); | |||||
System.out.println(_grid); | |||||
_grid = Conway.run(_grid); | _grid = Conway.run(_grid); | ||||
System.out.println("------------"); | |||||
System.out.println(_grid); | |||||
_grid = Conway.run(_grid); | _grid = Conway.run(_grid); | ||||
System.out.println("------------"); | |||||
System.out.println(_grid); | |||||
_grid = Conway.run(_grid); | _grid = Conway.run(_grid); | ||||
System.out.println("------------"); | |||||
System.out.println(_grid); | |||||
} | } | ||||
public static void main (String[] args) { | public static void main (String[] args) { | ||||
@@ -20,14 +20,11 @@ public class Conway extends RuleSet { | |||||
int numAlive = 0; | int numAlive = 0; | ||||
for (Patch neighbor : neighbors) | for (Patch neighbor : neighbors) | ||||
if (neighbor.getState() == 1) numAlive++; | if (neighbor.getState() == 1) numAlive++; | ||||
//System.out.println(numAlive); | |||||
Patch p = g.getPatch(i,j).clone(newGrid); | Patch p = g.getPatch(i,j).clone(newGrid); | ||||
if (numAlive < 2) { | if (numAlive < 2) { | ||||
p.setState(0); //Dies by underpopulation | p.setState(0); //Dies by underpopulation | ||||
//System.out.println("ded by under"); | |||||
} | } | ||||
if (numAlive > 3) { | if (numAlive > 3) { | ||||
//System.out.println("ded by over"); | |||||
p.setState(0); //Dies by overpopulation | p.setState(0); //Dies by overpopulation | ||||
} | } | ||||
if (numAlive == 3) | if (numAlive == 3) | ||||
@@ -36,9 +33,6 @@ public class Conway extends RuleSet { | |||||
} | } | ||||
} | } | ||||
System.out.println(g); | |||||
System.out.println("-----"); | |||||
System.out.println(newGrid); | |||||
//boolean running = true; | //boolean running = true; | ||||
//while (running) { | //while (running) { | ||||
//running = false; | //running = false; | ||||