toggleClickAction
This commit is contained in:
commit
8c1014bda6
|
|
@ -141,7 +141,7 @@ public class Simulator extends Thread {
|
|||
// in agent classes
|
||||
|
||||
|
||||
// int[][] newWorld = new int[getWidth()][getHeight()];
|
||||
int[][] newWorld = new int[getWidth()][getHeight()];
|
||||
|
||||
/*ArrayList<Agent> newAgents = new ArrayList<>();
|
||||
for(Agent agent : agents) {
|
||||
|
|
@ -149,29 +149,32 @@ public class Simulator extends Thread {
|
|||
this.getNeighboringAnimals(
|
||||
agent.getX(),
|
||||
agent.getY(),
|
||||
ANIMAL_AREA_RADIUS);
|
||||
ANIMAL_AREA_RADIUS);}
|
||||
if(!agent.liveTurn(
|
||||
neighbors,
|
||||
this)) {
|
||||
agents.remove(agent);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// Apply Game of Life rules
|
||||
/*for (int x = 0; x < getWidth(); x++) {
|
||||
for (int y = 0; y < getHeight(); y++) {
|
||||
int aliveNeighbors = countAliveNeighbors(x, y);
|
||||
if (getCell(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[x][y] == 1) {
|
||||
// newWorld[x][y] = (aliveNeighbors < 2 || aliveNeighbors > 3) ? 0 : 1;
|
||||
// } else {
|
||||
// newWorld[x][y] = (aliveNeighbors == 3) ? 1 : 0;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//world = newWorld;
|
||||
|
||||
this.world = setWorld(newWorld,getWidth(),getHeight()) ;
|
||||
*/
|
||||
|
||||
|
||||
//then evolution of the field
|
||||
|
|
@ -317,7 +320,7 @@ public class Simulator extends Thread {
|
|||
ArrayList<String> rule = new ArrayList<>();
|
||||
for (int i = 0; i < getHeight(); i++) {
|
||||
StringBuilder lineState = new StringBuilder();
|
||||
for (int j = 0 ; j < getHeight() ; j++) {
|
||||
for (int j = 0 ; j < getHeight() ; j++) { // je crois qu'il y a un probleme, il fau+t mettre getWidth je crois
|
||||
lineState.append(getCell(i, j));
|
||||
if (j < getWidth() - 1) {
|
||||
lineState.append(";");
|
||||
|
|
@ -355,7 +358,11 @@ public class Simulator extends Thread {
|
|||
}
|
||||
|
||||
public void toggleClickAction() {
|
||||
//TODO : complete method
|
||||
if (clickActionFlag < 2) {
|
||||
clickActionFlag ++ ;
|
||||
}else if (clickActionFlag == 2) {
|
||||
clickActionFlag=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -379,6 +386,7 @@ public class Simulator extends Thread {
|
|||
public String clickActionName() {
|
||||
// TODO : initially return "sheep" or "cell"
|
||||
// depending on clickActionFlag
|
||||
|
||||
if (clickActionFlag==0) {
|
||||
return "cell";
|
||||
}else if (clickActionFlag==1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue