test for the makestep
This commit is contained in:
parent
75e9fad8d6
commit
e07311f7bf
|
|
@ -178,7 +178,8 @@ public class Simulator extends Thread {
|
||||||
for (int y = 0; y < getHeight(); y++) {
|
for (int y = 0; y < getHeight(); y++) {
|
||||||
int aliveNeighbors = countAliveNeighbors(x, y);
|
int aliveNeighbors = countAliveNeighbors(x, y);
|
||||||
if (world.getCell(x, y) == 1) {
|
if (world.getCell(x, y) == 1) {
|
||||||
nextWorld[x][y] = survives(aliveNeighbors) ? 1 : 0;
|
nextWorld[x][y] = 1;
|
||||||
|
//survives(aliveNeighbors) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
nextWorld[x][y] = bornes(aliveNeighbors) ? 1 : 0;
|
nextWorld[x][y] = bornes(aliveNeighbors) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,26 @@ public class World {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setWorld(int[][] actualworld, int width, int height) {
|
public void setWorld(int[][] world, int width, int height) {
|
||||||
this.world = actualworld;
|
this.world = world;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
printArray (world);
|
||||||
}
|
}
|
||||||
//initializes the world
|
//initializes the world
|
||||||
|
|
||||||
|
public void printArray(int[][] array) {
|
||||||
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
System.out.print("[");
|
||||||
|
for (int j = 0; j < array[i].length; j++) {
|
||||||
|
System.out.print(array[i][j]);
|
||||||
|
if (j < array[i].length - 1) {
|
||||||
|
System.out.print(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue