loadAgents
This commit is contained in:
commit
123b4f6adf
|
|
@ -29,7 +29,8 @@ public class Simulator extends Thread {
|
|||
private boolean loopingBorder;
|
||||
private boolean clickActionFlag;
|
||||
private int loopDelay = 150;
|
||||
private ArrayList<Integer> ruleSurviveCriteria= new ArrayList<Integer>() ;
|
||||
private ArrayList<Integer> ruleSurviveCriteria= new ArrayList<Integer>();
|
||||
|
||||
private ArrayList<Integer> ruleBirthCriteria=new ArrayList<Integer>() ;
|
||||
//Rules rule = new Rules();
|
||||
//TODO : add missing attribute(s)
|
||||
|
|
@ -42,16 +43,16 @@ public class Simulator extends Thread {
|
|||
clickActionFlag=false;
|
||||
cells = new ArrayList<ArrayList<Cell>>();
|
||||
newCells = new ArrayList<ArrayList<Cell>>();
|
||||
|
||||
|
||||
agents = new ArrayList<Agent>();
|
||||
fieldBirthValues = new ArrayList<Integer>();
|
||||
fieldSurviveValues = new ArrayList<Integer>();
|
||||
|
||||
//TODO : add missing attribute initialization
|
||||
|
||||
|
||||
|
||||
|
||||
ruleSurviveCriteria.add(2);//initializing system with conway rule
|
||||
ruleSurviveCriteria.add(3);
|
||||
ruleBirthCriteria.add(3);
|
||||
//initialize grid with dead cells
|
||||
for(int x=0; x < getWidth();x++) {
|
||||
ArrayList<Cell> arrayCell = new ArrayList<Cell>(); //initialize first dimension with ArrayLists
|
||||
|
|
@ -485,6 +486,25 @@ public class Simulator extends Thread {
|
|||
|
||||
public void loadAgents(ArrayList<String> stringArray) {
|
||||
//TODO : Same idea as other load methods, but for agent list
|
||||
if(stringArray.size()<=0) {
|
||||
System.out.println("empty agents file");
|
||||
return;
|
||||
}
|
||||
//TODO : remove previous rule (=emptying lists)
|
||||
|
||||
|
||||
|
||||
for(int x=0; x<stringArray.size();x++) {
|
||||
String agentsLine = stringArray.get(x);
|
||||
String[] agentsElements = agentsLine.split(";");
|
||||
int[] agentsValues = new int[3];
|
||||
for(int i=0; i<agentsElements.length;i++) {
|
||||
agentsValues[i]= Integer.parseInt(agentsElements[i]);
|
||||
}
|
||||
if(agentsValues[2]==1) {
|
||||
agents.add(new Sheep(agentsValues[0], agentsValues[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue