now it up to date !!!!!
This commit is contained in:
parent
102bae29bb
commit
2d7b199765
|
|
@ -26,7 +26,7 @@ public class Simulator extends Thread {
|
|||
private boolean stopFlag;
|
||||
private boolean pauseFlag;
|
||||
private boolean loopingBorder;
|
||||
private boolean clickActionFlag;
|
||||
private int clickActionFlag;
|
||||
private int loopDelay = 150;
|
||||
private int[][] world;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ public class Simulator extends Thread {
|
|||
//stopFlag=false; //not necessary since i set the state when pressing the button start
|
||||
pauseFlag=false;
|
||||
loopingBorder=false;
|
||||
clickActionFlag=false;
|
||||
clickActionFlag=0;
|
||||
|
||||
agents = new ArrayList<Agent>();
|
||||
fieldBirthValues = new ArrayList<Integer>();
|
||||
|
|
@ -387,7 +387,11 @@ public class Simulator extends Thread {
|
|||
}
|
||||
|
||||
public void toggleClickAction() {
|
||||
//TODO : complete method
|
||||
if (clickActionFlag < 2) {
|
||||
clickActionFlag ++ ;
|
||||
}else if (clickActionFlag == 2) {
|
||||
clickActionFlag=0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -403,8 +407,18 @@ public class Simulator extends Thread {
|
|||
|
||||
|
||||
public ArrayList<String> getAgentsSave() {
|
||||
//TODO : Same idea as the other save method, but for agents
|
||||
return null;
|
||||
ArrayList<String> agentsSave = new ArrayList<>();
|
||||
for (int j = 0; j < getHeight(); j++) {
|
||||
StringBuilder lineState = new StringBuilder();
|
||||
for (int i = 0 ; i < getWidth() ; i++) {
|
||||
lineState.append(getCell(i, j));
|
||||
if (j < getHeight() -1) {
|
||||
lineState.append(",");
|
||||
}
|
||||
}
|
||||
agentsSave.add(lineState.toString());
|
||||
}
|
||||
return agentsSave;
|
||||
}
|
||||
|
||||
public void loadAgents(ArrayList<String> stringArray) {
|
||||
|
|
@ -417,9 +431,16 @@ public class Simulator extends Thread {
|
|||
* @return String representation of click action
|
||||
*/
|
||||
public String clickActionName() {
|
||||
// TODO : initially return "sheep" or "cell"
|
||||
// depending on clickActionFlag
|
||||
return "";
|
||||
if (clickActionFlag==0) {
|
||||
return "cell";
|
||||
}else if (clickActionFlag==1) {
|
||||
|
||||
return "sheep";
|
||||
}else if (clickActionFlag==2) {
|
||||
return "wolf";
|
||||
}else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue