diff --git a/Rule/BlobRule.csv b/Rule/BlobRule.csv index 10f61a6..922060c 100644 --- a/Rule/BlobRule.csv +++ b/Rule/BlobRule.csv @@ -1,2 +1,2 @@ 1;3;5;8 -3;5;7; +3;5;7 diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 4f7a38b..dba94a7 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -129,11 +129,11 @@ public class Simulator extends Thread { agent.getX(), agent.getY(), ANIMAL_AREA_RADIUS);} - //if(!agent.liveTurn( - // neighbors, - //this)) { - //agents.remove(agent); - //{ + /*if(!agent.liveTurn( + neighbors, + this)) { + agents.remove(agent); + {*/ // Apply Game of Life rules @@ -415,23 +415,46 @@ public class Simulator extends Thread { public ArrayList getAgentsSave() { - ArrayList 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(","); - } + ArrayList agentsList = new ArrayList(); + String sheepLine = "1,"; + String wolfLine = "2,"; + for (Agent agent : agents) { + int x = agent.getX(); + int y = agent.getY(); + if (agent instanceof Sheep) + { + sheepLine = sheepLine + x + ";" + y + ","; + } + else if (agent instanceof Wolf) + { + wolfLine = wolfLine + x + ";" + y + ","; } - agentsSave.add(lineState.toString()); } - return agentsSave; + agentsList.add(sheepLine); + agentsList.add(wolfLine); + return agentsList; } public void loadAgents(ArrayList stringArray) { //TODO : Same idea as other load methods, but for agent list - + for(int y =0; y