diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index c6b539a..8031b8b 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -29,7 +29,8 @@ public class Simulator extends Thread { private boolean loopingBorder; private boolean clickActionFlag; private int loopDelay = 150; - + private ArrayList ruleSurviveCriteria= new ArrayList() ; + private ArrayList ruleBirthCriteria=new ArrayList() ; //Rules rule = new Rules(); //TODO : add missing attribute(s) @@ -114,7 +115,7 @@ public class Simulator extends Thread { public void cellDies(int x, int y) { int aliveNeighbors = getAliveNeighbors(x, y, LIFE_AREA_RADIUS); - if(aliveNeighbors < 2 || aliveNeighbors > 3) { + if(aliveNeighbors < ruleSurviveCriteria.get(0) || aliveNeighbors > ruleSurviveCriteria.get(1)) { setNewCell(x, y, 0); //newCells.get(x).set(y, 0); }else{setNewCell(x, y, 1);} @@ -123,7 +124,7 @@ public class Simulator extends Thread { public void cellBorns(int x, int y) { int aliveNeighbors = getAliveNeighbors(x, y, LIFE_AREA_RADIUS); - if(aliveNeighbors == 3) { + if(aliveNeighbors == ruleBirthCriteria.get(0)) { setNewCell(x, y, 1); //newCells.get(x).set(y, 1); }else{setNewCell(x, y, 0);} @@ -457,14 +458,14 @@ public class Simulator extends Thread { String elem = surviveElements[x]; int value = Integer.parseInt(elem); //TODO : add value to possible survive values - + ruleSurviveCriteria.add(value); } String[] birthElements = birthLine.split(";"); for(int x=0; x