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 stopFlag;
|
||||||
private boolean pauseFlag;
|
private boolean pauseFlag;
|
||||||
private boolean loopingBorder;
|
private boolean loopingBorder;
|
||||||
private boolean clickActionFlag;
|
private int clickActionFlag;
|
||||||
private int loopDelay = 150;
|
private int loopDelay = 150;
|
||||||
private int[][] world;
|
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
|
//stopFlag=false; //not necessary since i set the state when pressing the button start
|
||||||
pauseFlag=false;
|
pauseFlag=false;
|
||||||
loopingBorder=false;
|
loopingBorder=false;
|
||||||
clickActionFlag=false;
|
clickActionFlag=0;
|
||||||
|
|
||||||
agents = new ArrayList<Agent>();
|
agents = new ArrayList<Agent>();
|
||||||
fieldBirthValues = new ArrayList<Integer>();
|
fieldBirthValues = new ArrayList<Integer>();
|
||||||
|
|
@ -387,7 +387,11 @@ public class Simulator extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleClickAction() {
|
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() {
|
public ArrayList<String> getAgentsSave() {
|
||||||
//TODO : Same idea as the other save method, but for agents
|
ArrayList<String> agentsSave = new ArrayList<>();
|
||||||
return null;
|
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) {
|
public void loadAgents(ArrayList<String> stringArray) {
|
||||||
|
|
@ -417,9 +431,16 @@ public class Simulator extends Thread {
|
||||||
* @return String representation of click action
|
* @return String representation of click action
|
||||||
*/
|
*/
|
||||||
public String clickActionName() {
|
public String clickActionName() {
|
||||||
// TODO : initially return "sheep" or "cell"
|
if (clickActionFlag==0) {
|
||||||
// depending on clickActionFlag
|
return "cell";
|
||||||
return "";
|
}else if (clickActionFlag==1) {
|
||||||
|
|
||||||
|
return "sheep";
|
||||||
|
}else if (clickActionFlag==2) {
|
||||||
|
return "wolf";
|
||||||
|
}else {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue