loadAgents
This commit is contained in:
commit
123b4f6adf
|
|
@ -29,7 +29,8 @@ public class Simulator extends Thread {
|
||||||
private boolean loopingBorder;
|
private boolean loopingBorder;
|
||||||
private boolean clickActionFlag;
|
private boolean clickActionFlag;
|
||||||
private int loopDelay = 150;
|
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>() ;
|
private ArrayList<Integer> ruleBirthCriteria=new ArrayList<Integer>() ;
|
||||||
//Rules rule = new Rules();
|
//Rules rule = new Rules();
|
||||||
//TODO : add missing attribute(s)
|
//TODO : add missing attribute(s)
|
||||||
|
|
@ -49,9 +50,9 @@ public class Simulator extends Thread {
|
||||||
|
|
||||||
//TODO : add missing attribute initialization
|
//TODO : add missing attribute initialization
|
||||||
|
|
||||||
|
ruleSurviveCriteria.add(2);//initializing system with conway rule
|
||||||
|
ruleSurviveCriteria.add(3);
|
||||||
|
ruleBirthCriteria.add(3);
|
||||||
//initialize grid with dead cells
|
//initialize grid with dead cells
|
||||||
for(int x=0; x < getWidth();x++) {
|
for(int x=0; x < getWidth();x++) {
|
||||||
ArrayList<Cell> arrayCell = new ArrayList<Cell>(); //initialize first dimension with ArrayLists
|
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) {
|
public void loadAgents(ArrayList<String> stringArray) {
|
||||||
//TODO : Same idea as other load methods, but for agent list
|
//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