From b5619ae8a2f25d654840532e401b76b7e88bb4fc Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Mon, 13 May 2024 10:51:27 +0200 Subject: [PATCH 01/10] init commit dev json --- ressources/Rule/cutsomrule.csv | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 ressources/Rule/cutsomrule.csv diff --git a/ressources/Rule/cutsomrule.csv b/ressources/Rule/cutsomrule.csv new file mode 100644 index 0000000..e16241f --- /dev/null +++ b/ressources/Rule/cutsomrule.csv @@ -0,0 +1,2 @@ +0;1;2;3;4 +3 \ No newline at end of file From e6eb59b08dfcf6f666df14a46d62c06c1a4c0058 Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Mon, 13 May 2024 11:15:39 +0200 Subject: [PATCH 02/10] json format --- conwayRule.json | 16 ++++++++++++++++ gasRule.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 conwayRule.json create mode 100644 gasRule.json diff --git a/conwayRule.json b/conwayRule.json new file mode 100644 index 0000000..34bb7a3 --- /dev/null +++ b/conwayRule.json @@ -0,0 +1,16 @@ +[{ + "value" : 1, + "color" : [255,255,255], + "conditionCountNear" : [2,3], + "conditionHighestNear" : null, + "ifValue" : 1, + "elseValue" : 0 +}, +{ + "value" : 0, + "color" : [0,0,0], + "conditionCountNear" : [3], + "conditionHighestNear" : null, + "ifValue" : 1, + "elseValue" : 0 +}] \ No newline at end of file diff --git a/gasRule.json b/gasRule.json new file mode 100644 index 0000000..58b3c5a --- /dev/null +++ b/gasRule.json @@ -0,0 +1,48 @@ +[{ + "value" : 5, + "color" : [255,255,255], + "conditionCountNear" : null, + "conditionHighestNear" : null, + "ifValue" : 4, + "elseValue" : null +}, +{ + "value" : 4, + "color" : [204,204,204], + "conditionCountNear" : null, + "conditionHighestNear" : null, + "ifValue" : 3, + "elseValue" : null +}, +{ + "value" : 3, + "color" : [153,153,153], + "conditionCountNear" : null, + "conditionHighestNear" : null, + "ifValue" : 2, + "elseValue" : null +}, +{ + "value" : 2, + "color" : [102,102,102], + "conditionCountNear" : null, + "conditionHighestNear" : null, + "ifValue" : 1, + "elseValue" : null +}, +{ + "value" : 1, + "color" : [51,51,51], + "conditionCountNear" : null, + "conditionHighestNear" : null, + "ifValue" : 0, + "elseValue" : null +}, +{ + "value" : 0, + "color" : [0,0,0], + "conditionCountNear" : null, + "conditionHighestNear" : [5], + "ifValue" : 5, + "elseValue" : 0 +}] \ No newline at end of file From 0d8c47a0ed15f7c07c7ed90c90af81ab7605be74 Mon Sep 17 00:00:00 2001 From: Balthazar Squinabol Date: Mon, 13 May 2024 21:13:31 +0200 Subject: [PATCH 03/10] // --- src/windowInterface/JPanelDraw.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/windowInterface/JPanelDraw.java b/src/windowInterface/JPanelDraw.java index b77c0e9..8ea1c24 100644 --- a/src/windowInterface/JPanelDraw.java +++ b/src/windowInterface/JPanelDraw.java @@ -69,7 +69,8 @@ public class JPanelDraw extends JPanel { g.setColor(Color.white); } if(cellContent == 2) { - g.setColor(Color.yellow); + g.setColor(Color.yellow); //set collor with rgb value (255,255,0) + //g.setColor(new Color(255,255,0)); } if(cellContent == 3) { g.setColor(Color.red); From 896f8e88d28049f163d791ab01b93376d0f1b40b Mon Sep 17 00:00:00 2001 From: Balthazar Squinabol Date: Mon, 13 May 2024 21:24:01 +0200 Subject: [PATCH 04/10] add rules file, creating an object with every attr ibutes and methods needed to create a rule --- src/backend/rules.java | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/backend/rules.java diff --git a/src/backend/rules.java b/src/backend/rules.java new file mode 100644 index 0000000..cbe5c94 --- /dev/null +++ b/src/backend/rules.java @@ -0,0 +1,65 @@ +package backend; + +public class rules { + + private int value; + private int[] color; + private int[] conditionCountNear; + private int[] conditionHighestNear; + private int ifValue; + private int elseValue; + + public rules(int value , int[] color, int[] conditionCountNear, int[] conditionHighestNear, int ifValue, int elseValue) { + this.value = value; + this.color = color; + this.conditionCountNear = conditionCountNear; + this.conditionHighestNear = conditionHighestNear; + this.ifValue = ifValue; + this.elseValue = elseValue; + } + + public int getValue() { + return value; + } + + public int[] getColor() { + return color; + } + + public void setColor(int[] color) { + this.color = color; + } + + public int[] getConditionCountNear() { + return conditionCountNear; + } + + public void setConditionCountNear(int[] conditionCountNear) { + this.conditionCountNear = conditionCountNear; + } + + public int[] getConditionHighestNear() { + return conditionHighestNear; + } + + public void setConditionHighestNear(int[] conditionHighestNear) { + this.conditionHighestNear = conditionHighestNear; + } + + public int getIfValue() { + return ifValue; + } + + public void setIfValue(int ifValue) { + this.ifValue = ifValue; + } + + public int getElseValue() { + return elseValue; + } + + public void setElseValue(int elseValue) { + this.elseValue = elseValue; + } + +} From 30155a16486d70568c0750ecb46e9b3ac91fcbaa Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Thu, 16 May 2024 10:35:28 +0200 Subject: [PATCH 05/10] json import --- README.md | 6 +- conwayRule.json | 9 +-- gasRule.json | 24 +++---- src/backend/{rules.java => Rule.java} | 24 +++---- src/backend/Simulator.java | 90 ++++++++++++++++++--------- src/windowInterface/MyInterface.java | 38 ++++++++--- 6 files changed, 127 insertions(+), 64 deletions(-) rename src/backend/{rules.java => Rule.java} (56%) diff --git a/README.md b/README.md index 6c3fd2e..6f81b49 100644 --- a/README.md +++ b/README.md @@ -17,5 +17,7 @@ With the implied additional rules: 5. Any dead cell who doesn’t have exactly 3 living neighbors stays dead, unchanged. - -TEST \ No newline at end of file +To download the json library: +https://code.google.com/archive/p/json-simple/downloads +tutorial to install it on vscode: +https://www.youtube.com/watch?v=g6vvEEm2hhs \ No newline at end of file diff --git a/conwayRule.json b/conwayRule.json index 34bb7a3..2c5ce56 100644 --- a/conwayRule.json +++ b/conwayRule.json @@ -1,16 +1,17 @@ -[{ +[{"cell": { "value" : 1, "color" : [255,255,255], "conditionCountNear" : [2,3], "conditionHighestNear" : null, "ifValue" : 1, "elseValue" : 0 -}, -{ +}}, +{"cell": { "value" : 0, "color" : [0,0,0], "conditionCountNear" : [3], "conditionHighestNear" : null, "ifValue" : 1, "elseValue" : 0 -}] \ No newline at end of file +}} +] \ No newline at end of file diff --git a/gasRule.json b/gasRule.json index 58b3c5a..70ba527 100644 --- a/gasRule.json +++ b/gasRule.json @@ -1,48 +1,48 @@ -[{ +[{"cell": { "value" : 5, "color" : [255,255,255], "conditionCountNear" : null, "conditionHighestNear" : null, "ifValue" : 4, "elseValue" : null -}, -{ +}}, +{"cell": { "value" : 4, "color" : [204,204,204], "conditionCountNear" : null, "conditionHighestNear" : null, "ifValue" : 3, "elseValue" : null -}, -{ +}}, +{"cell": { "value" : 3, "color" : [153,153,153], "conditionCountNear" : null, "conditionHighestNear" : null, "ifValue" : 2, "elseValue" : null -}, -{ +}}, +{"cell": { "value" : 2, "color" : [102,102,102], "conditionCountNear" : null, "conditionHighestNear" : null, "ifValue" : 1, "elseValue" : null -}, -{ +}}, +{"cell": { "value" : 1, "color" : [51,51,51], "conditionCountNear" : null, "conditionHighestNear" : null, "ifValue" : 0, "elseValue" : null -}, -{ +}}, +{"cell": { "value" : 0, "color" : [0,0,0], "conditionCountNear" : null, "conditionHighestNear" : [5], "ifValue" : 5, "elseValue" : 0 -}] \ No newline at end of file +}}] \ No newline at end of file diff --git a/src/backend/rules.java b/src/backend/Rule.java similarity index 56% rename from src/backend/rules.java rename to src/backend/Rule.java index cbe5c94..1b6bf12 100644 --- a/src/backend/rules.java +++ b/src/backend/Rule.java @@ -1,15 +1,17 @@ package backend; -public class rules { +import java.util.ArrayList; + +public class Rule { private int value; - private int[] color; - private int[] conditionCountNear; - private int[] conditionHighestNear; + private ArrayList color; + private ArrayList conditionCountNear; + private ArrayList conditionHighestNear; private int ifValue; private int elseValue; - public rules(int value , int[] color, int[] conditionCountNear, int[] conditionHighestNear, int ifValue, int elseValue) { + public Rule(int value , ArrayList color, ArrayList conditionCountNear, ArrayList conditionHighestNear, int ifValue, int elseValue) { this.value = value; this.color = color; this.conditionCountNear = conditionCountNear; @@ -22,27 +24,27 @@ public class rules { return value; } - public int[] getColor() { + public ArrayList getColor() { return color; } - public void setColor(int[] color) { + public void setColor(ArrayList color) { this.color = color; } - public int[] getConditionCountNear() { + public ArrayList getConditionCountNear() { return conditionCountNear; } - public void setConditionCountNear(int[] conditionCountNear) { + public void setConditionCountNear(ArrayList conditionCountNear) { this.conditionCountNear = conditionCountNear; } - public int[] getConditionHighestNear() { + public ArrayList getConditionHighestNear() { return conditionHighestNear; } - public void setConditionHighestNear(int[] conditionHighestNear) { + public void setConditionHighestNear(ArrayList conditionHighestNear) { this.conditionHighestNear = conditionHighestNear; } diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 7b4ff54..d521d05 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -1,5 +1,10 @@ package backend; import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; import windowInterface.MyInterface; @@ -33,6 +38,11 @@ public class Simulator extends Thread { private Table table; private boolean cellDensityToggle; + //Rules Arraylists + private ArrayList ruleArrayList = new ArrayList(); + private ArrayList> colorArrayList = new ArrayList>(); + + public Simulator(MyInterface mjfParam) { mjf = mjfParam; stopFlag=false; @@ -55,6 +65,7 @@ public class Simulator extends Thread { //Default rule : Survive always, birth never + for(int i =0; i<9; i++) { fieldSurviveValues.add(i); } @@ -374,36 +385,59 @@ public class Simulator extends Thread { return null; } - public void loadRule(ArrayList lines) { - if(lines.size()<=0) { - System.out.println("empty rule file"); - return; - } - //TODO-INPROGRESS : remove previous rule (=emptying lists) - fieldSurviveValues = new ArrayList(); - fieldBirthValues = new ArrayList(); - - String surviveLine = lines.get(0); - String birthLine = lines.get(1); - - String[] surviveElements = surviveLine.split(";"); - for(int x=0; x parseCellObject( (JSONObject) cell ) ); } + @SuppressWarnings("unchecked") + private void parseCellObject(JSONObject cell) { + //Get cell object within list + JSONObject cellObject = (JSONObject) cell.get("cell"); + + //Get value + String cellValueString = String.valueOf((Long)cellObject.get("value")); + int cellValue = Integer.valueOf(cellValueString); + System.out.println("cell value rule loaded: "+cellValue); + + //Get color + JSONArray colorValueJsonArray = (JSONArray) cellObject.get("color"); + ArrayList rgbList = new ArrayList(); + colorValueJsonArray.forEach(value -> rgbList.add(Integer.valueOf(String.valueOf((Long)value)))); + + //Get Condition Count Near + JSONArray countNearJsonArray = (JSONArray) cellObject.get("color"); + ArrayList conditionCountNearList = new ArrayList(); + countNearJsonArray.forEach(value -> conditionCountNearList.add(Integer.valueOf(String.valueOf((Long)value)))); + + //Get Condition highest near + JSONArray conditionHighestNearJsonArray = (JSONArray) cellObject.get("color"); + ArrayList conditionHighestNearList = new ArrayList(); + conditionHighestNearJsonArray.forEach(value -> conditionHighestNearList.add(Integer.valueOf(String.valueOf((Long)value)))); + + //Get ifValue + String ifValueString = String.valueOf((Long)cellObject.get("value")); + int ifValue = Integer.valueOf(ifValueString); + + //Get elseValue + String elseValueString = String.valueOf((Long)cellObject.get("value")); + int elseValue = Integer.valueOf(elseValueString); + + while (cellValue > colorArrayList.size()) { + colorArrayList.add(new ArrayList()); + } + colorArrayList.add(cellValue,rgbList); + Rule newRule = new Rule(cellValue, rgbList, conditionCountNearList, conditionHighestNearList, ifValue, elseValue); + + while (cellValue > ruleArrayList.size()) { + ruleArrayList.add(newRule); + } + ruleArrayList.add(cellValue,newRule); + + } + public void applyRule(){ Table tempTable = new Table(this.height, this.width, this); for(int x=0; x stringArray = new ArrayList(); if (fileName.length()>0) { try { - BufferedReader fileContent = new BufferedReader(new FileReader(fileName)); - String line = fileContent.readLine(); - while (line != null) { - stringArray.add(line); - line = fileContent.readLine(); + //TODO-INPROGRESS load json + JSONParser jsonParser = new JSONParser(); + try (FileReader reader = new FileReader(fileName)) + { + //Read JSON file + Object obj = jsonParser.parse(reader); + + JSONArray cellList = (JSONArray) obj; + //System.out.println(cellList); + mySimu.loadRule(cellList); + //Iterate over employee array + //cellList.forEach( emp -> parseEmployeeObject( (JSONObject) emp ) ); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); } - fileContent.close(); + } catch (Exception e) { e.printStackTrace(); } - mySimu.loadRule(stringArray); + this.repaint(); } } From c4239812643d53fd78b039257a8bfdd2a2c3719b Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Thu, 16 May 2024 11:55:54 +0200 Subject: [PATCH 06/10] conway working, gas flickering --- conwayRule.json | 6 +- gasRule.json | 32 ++++---- src/backend/Simulator.java | 109 ++++++++++++++++----------- src/backend/Table.java | 32 ++++++++ src/windowInterface/MyInterface.java | 22 +----- 5 files changed, 120 insertions(+), 81 deletions(-) diff --git a/conwayRule.json b/conwayRule.json index 2c5ce56..7f1a76e 100644 --- a/conwayRule.json +++ b/conwayRule.json @@ -2,15 +2,15 @@ "value" : 1, "color" : [255,255,255], "conditionCountNear" : [2,3], - "conditionHighestNear" : null, + "conditionHighestNear" : [], "ifValue" : 1, "elseValue" : 0 }}, {"cell": { "value" : 0, - "color" : [0,0,0], + "color" : [102,0,0], "conditionCountNear" : [3], - "conditionHighestNear" : null, + "conditionHighestNear" : [], "ifValue" : 1, "elseValue" : 0 }} diff --git a/gasRule.json b/gasRule.json index 70ba527..9c4290b 100644 --- a/gasRule.json +++ b/gasRule.json @@ -1,47 +1,47 @@ [{"cell": { "value" : 5, "color" : [255,255,255], - "conditionCountNear" : null, - "conditionHighestNear" : null, + "conditionCountNear" : [], + "conditionHighestNear" : [], "ifValue" : 4, - "elseValue" : null + "elseValue" : 4 }}, {"cell": { "value" : 4, "color" : [204,204,204], - "conditionCountNear" : null, - "conditionHighestNear" : null, + "conditionCountNear" : [], + "conditionHighestNear" : [], "ifValue" : 3, - "elseValue" : null + "elseValue" : 3 }}, {"cell": { "value" : 3, "color" : [153,153,153], - "conditionCountNear" : null, - "conditionHighestNear" : null, + "conditionCountNear" : [], + "conditionHighestNear" : [], "ifValue" : 2, - "elseValue" : null + "elseValue" : 2 }}, {"cell": { "value" : 2, "color" : [102,102,102], - "conditionCountNear" : null, - "conditionHighestNear" : null, + "conditionCountNear" : [], + "conditionHighestNear" : [], "ifValue" : 1, - "elseValue" : null + "elseValue" : 1 }}, {"cell": { "value" : 1, "color" : [51,51,51], - "conditionCountNear" : null, - "conditionHighestNear" : null, + "conditionCountNear" : [], + "conditionHighestNear" : [], "ifValue" : 0, - "elseValue" : null + "elseValue" : 0 }}, {"cell": { "value" : 0, "color" : [0,0,0], - "conditionCountNear" : null, + "conditionCountNear" : [], "conditionHighestNear" : [5], "ifValue" : 5, "elseValue" : 0 diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index d521d05..21d1d15 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -1,10 +1,16 @@ package backend; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; +//import for json import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; import windowInterface.MyInterface; @@ -12,8 +18,8 @@ public class Simulator extends Thread { private MyInterface mjf; - private final int COL_NUM = 100; - private final int LINE_NUM = 100; + private final int COL_NUM = 10; + private final int LINE_NUM = 10; private final int LIFE_TYPE_NUM = 4; //Conway Radius : 1 private final int LIFE_AREA_RADIUS = 1; @@ -60,15 +66,12 @@ public class Simulator extends Thread { this.height=LINE_NUM; enableLogs = true; // for debugging purposes table = new Table(height, width, this); - cellDensityToggle=false; + cellDensityToggle=true; //Default rule : Survive always, birth never - - for(int i =0; i<9; i++) { - fieldSurviveValues.add(i); - } + loadRule("OOP_F1_Project\\conwayRule.json"); } @@ -181,20 +184,10 @@ public class Simulator extends Thread { int currentCellValue = getCell(x, y); int newCellValue = 0; if(cellDensityToggle) { - if (currentCellValue == -1) { - newCellValue = 0; - } - if (currentCellValue == 0) { - newCellValue = 1; - } - if (currentCellValue == 1) { - newCellValue = 2; - } - if (currentCellValue == 2) { - newCellValue = 3; - } - if (currentCellValue == 3) { - newCellValue = -1; + if (currentCellValue <6) { + newCellValue = currentCellValue +1; + } else { + newCellValue=-1; } } else { if (currentCellValue == 0) { @@ -386,10 +379,28 @@ public class Simulator extends Thread { } @SuppressWarnings("unchecked") - public void loadRule(JSONArray cellList) { - ruleArrayList.clear(); - colorArrayList.clear(); - cellList.forEach( cell -> parseCellObject( (JSONObject) cell ) ); + public void loadRule(String fileName) { + System.out.println(fileName); + //TODO-INPROGRESS load json + JSONParser jsonParser = new JSONParser(); + try (FileReader reader = new FileReader(fileName)) + { + //Read JSON file + Object obj = jsonParser.parse(reader); + + JSONArray cellList = (JSONArray) obj; + ruleArrayList.clear(); + colorArrayList.clear(); + cellList.forEach( cell -> parseCellObject( (JSONObject) cell ) ); + + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } } @SuppressWarnings("unchecked") @@ -408,21 +419,21 @@ public class Simulator extends Thread { colorValueJsonArray.forEach(value -> rgbList.add(Integer.valueOf(String.valueOf((Long)value)))); //Get Condition Count Near - JSONArray countNearJsonArray = (JSONArray) cellObject.get("color"); + JSONArray countNearJsonArray = (JSONArray) cellObject.get("conditionCountNear"); ArrayList conditionCountNearList = new ArrayList(); countNearJsonArray.forEach(value -> conditionCountNearList.add(Integer.valueOf(String.valueOf((Long)value)))); //Get Condition highest near - JSONArray conditionHighestNearJsonArray = (JSONArray) cellObject.get("color"); + JSONArray conditionHighestNearJsonArray = (JSONArray) cellObject.get("conditionHighestNear"); ArrayList conditionHighestNearList = new ArrayList(); conditionHighestNearJsonArray.forEach(value -> conditionHighestNearList.add(Integer.valueOf(String.valueOf((Long)value)))); //Get ifValue - String ifValueString = String.valueOf((Long)cellObject.get("value")); + String ifValueString = String.valueOf((Long)cellObject.get("ifValue")); int ifValue = Integer.valueOf(ifValueString); //Get elseValue - String elseValueString = String.valueOf((Long)cellObject.get("value")); + String elseValueString = String.valueOf((Long)cellObject.get("elseValue")); int elseValue = Integer.valueOf(elseValueString); while (cellValue > colorArrayList.size()) { @@ -442,28 +453,42 @@ public class Simulator extends Thread { Table tempTable = new Table(this.height, this.width, this); for(int x=0; x Date: Wed, 22 May 2024 09:03:29 +0200 Subject: [PATCH 07/10] comments --- src/backend/Simulator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 21d1d15..e1ae068 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -457,11 +457,13 @@ public class Simulator extends Thread { int valueHighestNear = table.highestNear(x,y); if ( ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear().size() ==0 && ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear().size() ==0) { + //both conditions lists are empty, directly take if value tempTable.getCell(x, y).setValue(ruleArrayList.get(table.getCell(x, y).getValue()).getIfValue()); } else if ( ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear().size() !=0 && ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear().size() == 0) { + //only countnear condition if (ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear().contains(valueCountNear)){ tempTable.getCell(x, y).setValue(ruleArrayList.get(table.getCell(x, y).getValue()).getIfValue()); }else{ @@ -470,15 +472,20 @@ public class Simulator extends Thread { } else if ( ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear().size() ==0 && ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear().size() != 0) { + //only highest near condition if (ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear().contains(valueHighestNear)){ tempTable.getCell(x, y).setValue(ruleArrayList.get(table.getCell(x, y).getValue()).getIfValue()); }else{ tempTable.getCell(x, y).setValue(ruleArrayList.get(table.getCell(x, y).getValue()).getElseValue()); } - } else if ( ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear() !=null && - ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear() != null) { + } else if ( ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear().size() !=0 && + ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear().size() != 0) { + //both conditions + if (ruleArrayList.get(table.getCell(x, y).getValue()).getConditionHighestNear().contains(valueHighestNear) + && ruleArrayList.get(table.getCell(x, y).getValue()).getConditionCountNear().contains(valueCountNear)){ + } } //DEBUG: From 5aa4513148f3d1e8167610329956dab5dc6e2c27 Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 22 May 2024 09:51:59 +0200 Subject: [PATCH 08/10] gas rules works --- src/backend/Simulator.java | 220 +++++++++++++++++++------------------ src/backend/Table.java | 18 +-- 2 files changed, 126 insertions(+), 112 deletions(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index e1ae068..40a4f17 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -18,8 +18,8 @@ public class Simulator extends Thread { private MyInterface mjf; - private final int COL_NUM = 10; - private final int LINE_NUM = 10; + private final int COL_NUM = 100; + private final int LINE_NUM = 100; private final int LIFE_TYPE_NUM = 4; //Conway Radius : 1 private final int LIFE_AREA_RADIUS = 1; @@ -382,120 +382,115 @@ public class Simulator extends Thread { public void loadRule(String fileName) { System.out.println(fileName); //TODO-INPROGRESS load json - JSONParser jsonParser = new JSONParser(); - try (FileReader reader = new FileReader(fileName)) - { - //Read JSON file - Object obj = jsonParser.parse(reader); - - JSONArray cellList = (JSONArray) obj; - ruleArrayList.clear(); - colorArrayList.clear(); - cellList.forEach( cell -> parseCellObject( (JSONObject) cell ) ); + JSONParser jsonParser = new JSONParser(); + try (FileReader reader = new FileReader(fileName)) + { + //Read JSON file + Object obj = jsonParser.parse(reader); + + JSONArray cellList = (JSONArray) obj; + ruleArrayList.clear(); + colorArrayList.clear(); + cellList.forEach( cell -> parseCellObject( (JSONObject) cell ) ); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ParseException e) { - e.printStackTrace(); - } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + //DEBUG + //printRules(ruleArrayList); } @SuppressWarnings("unchecked") private void parseCellObject(JSONObject cell) { - //Get cell object within list - JSONObject cellObject = (JSONObject) cell.get("cell"); - - //Get value - String cellValueString = String.valueOf((Long)cellObject.get("value")); - int cellValue = Integer.valueOf(cellValueString); - System.out.println("cell value rule loaded: "+cellValue); - - //Get color - JSONArray colorValueJsonArray = (JSONArray) cellObject.get("color"); - ArrayList rgbList = new ArrayList(); - colorValueJsonArray.forEach(value -> rgbList.add(Integer.valueOf(String.valueOf((Long)value)))); - - //Get Condition Count Near - JSONArray countNearJsonArray = (JSONArray) cellObject.get("conditionCountNear"); - ArrayList conditionCountNearList = new ArrayList(); - countNearJsonArray.forEach(value -> conditionCountNearList.add(Integer.valueOf(String.valueOf((Long)value)))); - - //Get Condition highest near - JSONArray conditionHighestNearJsonArray = (JSONArray) cellObject.get("conditionHighestNear"); - ArrayList conditionHighestNearList = new ArrayList(); - conditionHighestNearJsonArray.forEach(value -> conditionHighestNearList.add(Integer.valueOf(String.valueOf((Long)value)))); - - //Get ifValue - String ifValueString = String.valueOf((Long)cellObject.get("ifValue")); - int ifValue = Integer.valueOf(ifValueString); - - //Get elseValue - String elseValueString = String.valueOf((Long)cellObject.get("elseValue")); - int elseValue = Integer.valueOf(elseValueString); - - while (cellValue > colorArrayList.size()) { - colorArrayList.add(new ArrayList()); + // Get cell object within list + JSONObject cellObject = (JSONObject) cell.get("cell"); + + // Get value + int cellValue = ((Long) cellObject.get("value")).intValue(); + System.out.println("cell value rule loaded: " + cellValue); + + // Get color + JSONArray colorValueJsonArray = (JSONArray) cellObject.get("color"); + ArrayList rgbList = new ArrayList<>(); + colorValueJsonArray.forEach(value -> rgbList.add(((Long) value).intValue())); + + // Get Condition Count Near + JSONArray countNearJsonArray = (JSONArray) cellObject.get("conditionCountNear"); + ArrayList conditionCountNearList = new ArrayList<>(); + countNearJsonArray.forEach(value -> conditionCountNearList.add(((Long) value).intValue())); + + // Get Condition Highest Near + JSONArray conditionHighestNearJsonArray = (JSONArray) cellObject.get("conditionHighestNear"); + ArrayList conditionHighestNearList = new ArrayList<>(); + conditionHighestNearJsonArray.forEach(value -> conditionHighestNearList.add(((Long) value).intValue())); + + // Get ifValue + int ifValue = ((Long) cellObject.get("ifValue")).intValue(); + + // Get elseValue + int elseValue = ((Long) cellObject.get("elseValue")).intValue(); + + // Ensure the colorArrayList is large enough + while (colorArrayList.size() <= cellValue) { + colorArrayList.add(new ArrayList<>()); } - colorArrayList.add(cellValue,rgbList); - Rule newRule = new Rule(cellValue, rgbList, conditionCountNearList, conditionHighestNearList, ifValue, elseValue); - - while (cellValue > ruleArrayList.size()) { - ruleArrayList.add(newRule); + colorArrayList.set(cellValue, rgbList); + + // Ensure the ruleArrayList is large enough + while (ruleArrayList.size() <= cellValue) { + ruleArrayList.add(null); } - ruleArrayList.add(cellValue,newRule); - - } + ruleArrayList.set(cellValue, new Rule(cellValue, rgbList, conditionCountNearList, conditionHighestNearList, ifValue, elseValue)); + } public void applyRule(){ Table tempTable = new Table(this.height, this.width, this); - for(int x=0; x= width || y < 0 || y >= height) { - // Border cell is dead + // Border cell is outside the grid continue; } } - if (highest < this.getCell(x, y).getValue()) { - highest = this.getCell(x, y).getValue(); + + int cellValue = this.getCell(x, y).getValue(); + if (cellValue > highest) { + highest = cellValue; } } From 7d98ef78abfa612a18b71a9abc76806f347fe0b3 Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 22 May 2024 11:27:31 +0200 Subject: [PATCH 09/10] comrade --- conwayRule.json | 4 +- ressources/World/randomFive.csv | 100 ++++++++++++++++++++++++++++ src/backend/Simulator.java | 7 +- src/windowInterface/JPanelDraw.java | 19 +++--- 4 files changed, 115 insertions(+), 15 deletions(-) create mode 100644 ressources/World/randomFive.csv diff --git a/conwayRule.json b/conwayRule.json index 7f1a76e..12cb7a9 100644 --- a/conwayRule.json +++ b/conwayRule.json @@ -1,6 +1,6 @@ [{"cell": { "value" : 1, - "color" : [255,255,255], + "color" : [167,237,139], "conditionCountNear" : [2,3], "conditionHighestNear" : [], "ifValue" : 1, @@ -8,7 +8,7 @@ }}, {"cell": { "value" : 0, - "color" : [102,0,0], + "color" : [37,52,31], "conditionCountNear" : [3], "conditionHighestNear" : [], "ifValue" : 1, diff --git a/ressources/World/randomFive.csv b/ressources/World/randomFive.csv new file mode 100644 index 0000000..96026f8 --- /dev/null +++ b/ressources/World/randomFive.csv @@ -0,0 +1,100 @@ +5;0;0;5;5;0;0;0;0;5;5;5;0;5;5;5;5;0;5;0;5;0;0;5;5;0;5;0;0;5;0;0;0;0;0;5;5;0;0;0;5;0;0;0;0;0;5;5;0;0;0;0;5;0;5;0;5;0;0;0;0;0;0;5;0;5;5;0;5;5;0;0;5;0;0;5;5;0;0;5;5;5;0;0;5;5;0;0;5;5;5;0;5;5;5;0;5;5;5;5 +5;0;0;5;0;0;0;0;0;5;5;0;0;0;0;0;5;0;0;5;0;0;5;5;5;0;5;5;5;5;0;0;0;0;5;5;0;5;0;0;5;0;5;0;0;5;0;5;0;5;5;5;5;0;0;5;0;0;0;5;5;5;0;5;0;5;0;5;5;5;0;0;5;5;5;0;0;5;0;5;0;0;5;5;0;5;5;5;5;0;0;5;0;5;0;5;0;0;0;5 +0;5;0;0;0;0;0;5;0;0;0;0;0;0;0;0;5;0;0;0;0;5;0;0;5;5;5;0;0;5;5;0;5;5;0;5;0;5;0;5;5;0;0;0;0;0;5;0;0;0;0;0;0;0;5;5;5;0;0;0;5;5;0;5;0;0;0;0;0;5;5;0;5;0;5;0;5;5;5;5;5;5;0;0;0;0;0;0;0;0;5;5;0;5;0;0;0;0;5;0 +5;5;0;5;0;0;0;0;0;0;5;5;0;0;5;5;0;0;0;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5 diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 40a4f17..c36f1be 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -84,6 +84,9 @@ public class Simulator extends Thread { //TODO-COMPLETE : replace with proper return return this.height; } + public ArrayList> getColorArrayList() { + return colorArrayList; + } //Should probably stay as is public void run() { @@ -131,7 +134,7 @@ public class Simulator extends Thread { } } //then evolution of the field - // TODO-INPROGRESS : apply game rule to all cells of the field + //TODO-INPROGRESS : apply game rule to all cells of the field this.applyRule(); @@ -520,7 +523,7 @@ public class Simulator extends Thread { } - + //debug print the list of rules public void printRules(ArrayList ruleArrayList) { System.out.println("-----------------------------------"); System.out.println("Rule list size: "+ruleArrayList.size()); diff --git a/src/windowInterface/JPanelDraw.java b/src/windowInterface/JPanelDraw.java index b77c0e9..e1bf255 100644 --- a/src/windowInterface/JPanelDraw.java +++ b/src/windowInterface/JPanelDraw.java @@ -16,6 +16,7 @@ public class JPanelDraw extends JPanel { private static final long serialVersionUID = 1L; private Simulator mySimu; private MyInterface interfaceGlobal; + ArrayList> colorArrayList; public JPanelDraw(MyInterface itf) { super(); @@ -37,6 +38,7 @@ public class JPanelDraw extends JPanel { public void setSimu(Simulator simu) { mySimu = simu; + colorArrayList = mySimu.getColorArrayList(); } @Override @@ -61,19 +63,14 @@ public class JPanelDraw extends JPanel { int cellContent = mySimu.getCell(x,y); if(cellContent == -1) { g.setColor(Color.gray); - } - if(cellContent == 0) { - continue; - } - if(cellContent == 1) { + } else if(cellContent=0) { + int red = colorArrayList.get(cellContent).get(0); + int green = colorArrayList.get(cellContent).get(1); + int blue = colorArrayList.get(cellContent).get(2); + g.setColor(new Color(red,green,blue)); + } else { g.setColor(Color.white); } - if(cellContent == 2) { - g.setColor(Color.yellow); - } - if(cellContent == 3) { - g.setColor(Color.red); - } g.fillRect( (int) Math.round(x*cellWidth), (int) Math.round(y*cellHeight), From 8ea68ad89f6ad1a82a60592abeeb0ba0f33aeda2 Mon Sep 17 00:00:00 2001 From: Balthazar SQUINABOL Date: Wed, 22 May 2024 14:06:14 +0200 Subject: [PATCH 10/10] Actualiser README.md --- README.md | 121 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 111 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6f81b49..f0f7270 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,124 @@ -When starting a task "TODO" edit it to "TODO-INPROGRESS" -When task is done edit it to "TODO-COMPLETE" -If there is an error in the code edit it to "TODO-ERROR" -Link Canva Whiteboard: -https://www.canva.com/design/DAGCBGF5b4c/4cNmhoS6lSC8Once9r_Tlg/edit?utm_content=DAGCBGF5b4c&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton +# Game Of Life +The Game of Life (an example of a cellular automaton) is played on an infinite two-dimensional rectangular grid of cells. Each cell can be either alive or dead. The status of each cell changes each turn of the game (also called a generation) depending on the statuses of that cell's 8 neighbors. Neighbors of a cell are cells that touch that cell, either horizontal, vertical, or diagonal from that cell. -Reminder of game of life rules: +### Reminder of basic game of life rules 1. Any living cell with strictly fewer than two living neighbors dies (referred to as underpopulation or exposure). + 2. Any living cell with strictly more than three living neighbors dies (referred to as overpopulation or overcrowding). + 3. Any dead cell with exactly three living neighbors will come to life. (Referred to as spreading or growth) With the implied additional rules: + 4. Any living cell with two or three living neighbors continues to live, unchanged. -5. Any dead cell who doesn’t have exactly 3 living neighbors stays dead, -unchanged. + +5. Any dead cell who doesn’t have exactly 3 living neighbors stays dead, unchanged. + + + +## Features + +- Classic Game of Life Rules: Implements the traditional rules of Conway's Game of Life. +- Customizable Rulesets: Load and apply custom rulesets from JSON files. +- Agent Behavior: Simulate agents with specific behaviors based on their surroundings. +- Interactive Grid: Click on cells to change their states with two modes: cell state change and agent placement. +- Looping Borders: Option to enable or disable looping borders for the grid. (Opposit sides are connected) +- Adjustable Simulation Speed: Change the speed of the simulation using a slider. +- Random Cell Generation: Generate a random initial state for the grid, the density slider allows to adjust the probability for a cell to become alive. +- Save and Load States: Save/Load current state of the simulation. +- Pause and Resume. +- Visual Representation: Display the grid with different colors representing different cell states. + + + +## Run Locally + +Clone the project + +```bash + git clone https://gitarero.ecam.fr/guillaume.bonabau/OOP_F1_Project.git +``` + +Go to the project directory + +```bash + cd OOP_F1_Project +``` + +Install dependencies + +```bash + TODO How to install the json-simple-1.1.1.jar +``` + +Start the program + +```bash + TODO ???? => javac .\src\Main.java +``` + + +## Basic How to + +- Load Rules +By default, Coneways rules are loaded. You can load other set of rules by clicking the "Load Rule" button. + +- Create Field +Create the fild either by generating a random field, or by clicking yourself on cells (Don't forget to Toggle click). + +- Toggle Border +There is 2 different iterations methodes. + +1. Closed +The sides of the gride will count as dead. + +2. Loop +The gride technicaly has no sides. The left handside is connected to the right one, the top to the bottom. +All 4 corners cells are nearby cells of each others. +## Color Reference + +| Color | HEX | RGB | +| ----------------- | ------------------------------------------------------------------ |------| +| Dead | ![#25341F](https://via.placeholder.com/10/25341F?text=+) #25341F | [37,52,31] | +| Alived | ![#a7ed8b](https://via.placeholder.com/10/A7ED8B?text=+) #f8f8f8 | [167,237,139] | + + +## FAQ + +#### Question 1 + +Answer 1 + +#### Question 2 + +Answer 2 + + +## Acknowledgements + + - [OOP Project](https://gitarero.ecam.fr/francois.neron/OOP_H03_test_Project) + - [Francois NERON](https://gitarero.ecam.fr/francois.neron) + +## Appendix To download the json library: https://code.google.com/archive/p/json-simple/downloads -tutorial to install it on vscode: -https://www.youtube.com/watch?v=g6vvEEm2hhs \ No newline at end of file + +Workflow : +When starting a task "TODO" edit it to "TODO-INPROGRESS" + +When task is done edit it to "TODO-COMPLETE" + +If there is an error in the code edit it to "TODO-ERROR" + + +Link Canva Whiteboard: +https://www.canva.com/design/DAGCBGF5b4c/4cNmhoS6lSC8Once9r_Tlg/edit?utm_content=DAGCBGF5b4c&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton +## Authors + +- [@guillaume.bonabau](https://gitarero.ecam.fr/guillaume.bonabau) +- [@g.le-chartier](https://gitarero.ecam.fr/g.le-chartier) +- [@balthazar.squinabol](https://gitarero.ecam.fr/balthazar.squinabol)