# WARNING: head commit changed in the meantime
Merge branch 'master' of https://gitarero.ecam.fr/laure.bel/OOP_F3_Project.git
This commit is contained in:
parent
4d7f223e9d
commit
c0f524a814
|
|
@ -133,21 +133,21 @@ public class Simulator extends Thread {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private boolean survives(int aliveNeighbors) {
|
private boolean survives (int aliveNeighbors) {
|
||||||
// for (int value : rules.getSuvivalRulesArray()) {
|
for (int value : rules.getSurvivalRulesArray()) {
|
||||||
// if ( value == aliveNeighbors) {
|
if ( value == aliveNeighbors) {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// }
|
}return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// private boolean bornes(int aliveNeighbors) {
|
private boolean bornes(int aliveNeighbors) {
|
||||||
// for(int value : rules.getBirthRulesArray()) {
|
for(int value : rules.getBirthRulesArray()) {
|
||||||
// if (value == aliveNeighbors) {
|
if (value == aliveNeighbors) {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// }
|
}return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,8 +158,6 @@ public class Simulator extends Thread {
|
||||||
// in agent classes
|
// in agent classes
|
||||||
|
|
||||||
|
|
||||||
int[][] newWorld = new int[getWidth()][getHeight()];
|
|
||||||
|
|
||||||
/*ArrayList<Agent> newAgents = new ArrayList<>();
|
/*ArrayList<Agent> newAgents = new ArrayList<>();
|
||||||
for(Agent agent : agents) {
|
for(Agent agent : agents) {
|
||||||
ArrayList<Agent> neighbors =
|
ArrayList<Agent> neighbors =
|
||||||
|
|
@ -174,23 +172,21 @@ public class Simulator extends Thread {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
// Apply Game of Life rules
|
int[][] nextWorld = new int[getWidth()][getHeight()];
|
||||||
//for (int x = 0; x < getWidth(); x++) {
|
|
||||||
// for (int y = 0; y < getHeight(); y++) {
|
|
||||||
// int aliveNeighbors = countAliveNeighbors(x, y);
|
|
||||||
// if (world[x][y] == 1) {
|
|
||||||
// newWorld[x][y] = (aliveNeighbors < 2 || aliveNeighbors > 3) ? 0 : 1;
|
|
||||||
// } else {
|
|
||||||
// newWorld[x][y] = (aliveNeighbors == 3) ? 1 : 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (int x = 0; x < getWidth(); x++) {
|
||||||
|
for (int y = 0; y < getHeight(); y++) {
|
||||||
|
int aliveNeighbors = countAliveNeighbors(x, y);
|
||||||
|
if (world.getCell(x, y) == 1) {
|
||||||
|
nextWorld[x][y] = survives(aliveNeighbors) ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
nextWorld[x][y] = bornes(aliveNeighbors) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//world = newWorld;
|
world.setWorld(nextWorld, getWidth(), getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -212,7 +208,7 @@ public class Simulator extends Thread {
|
||||||
* then the cell becomes alive
|
* then the cell becomes alive
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue