From 11043e233378fe27f830e97dc4c34b2f29f21486 Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 29 May 2024 10:15:34 +0200 Subject: [PATCH 1/5] moved rules.json in rule folder --- ressources/Rule/BlobRule.csv | 2 -- ressources/Rule/BlobRule.json | 17 +++++++++++++++++ ressources/Rule/ConwayRule.csv | 2 -- .../Rule/conwayRule.json | 0 ressources/Rule/cutsomrule.csv | 2 -- gasRule.json => ressources/Rule/gasRule.json | 0 src/backend/Simulator.java | 1 + 7 files changed, 18 insertions(+), 6 deletions(-) delete mode 100644 ressources/Rule/BlobRule.csv create mode 100644 ressources/Rule/BlobRule.json delete mode 100644 ressources/Rule/ConwayRule.csv rename conwayRule.json => ressources/Rule/conwayRule.json (100%) delete mode 100644 ressources/Rule/cutsomrule.csv rename gasRule.json => ressources/Rule/gasRule.json (100%) diff --git a/ressources/Rule/BlobRule.csv b/ressources/Rule/BlobRule.csv deleted file mode 100644 index 10f61a6..0000000 --- a/ressources/Rule/BlobRule.csv +++ /dev/null @@ -1,2 +0,0 @@ -1;3;5;8 -3;5;7; diff --git a/ressources/Rule/BlobRule.json b/ressources/Rule/BlobRule.json new file mode 100644 index 0000000..822a900 --- /dev/null +++ b/ressources/Rule/BlobRule.json @@ -0,0 +1,17 @@ +[{"cell": { + "value" : 1, + "color" : [167,237,139], + "conditionCountNear" : [3,5,7], + "conditionHighestNear" : [], + "ifValue" : 1, + "elseValue" : 0 +}}, +{"cell": { + "value" : 0, + "color" : [37,52,31], + "conditionCountNear" : [1,3,5,8], + "conditionHighestNear" : [], + "ifValue" : 1, + "elseValue" : 0 +}} +] \ No newline at end of file diff --git a/ressources/Rule/ConwayRule.csv b/ressources/Rule/ConwayRule.csv deleted file mode 100644 index 3563b76..0000000 --- a/ressources/Rule/ConwayRule.csv +++ /dev/null @@ -1,2 +0,0 @@ -2;3 -3 \ No newline at end of file diff --git a/conwayRule.json b/ressources/Rule/conwayRule.json similarity index 100% rename from conwayRule.json rename to ressources/Rule/conwayRule.json diff --git a/ressources/Rule/cutsomrule.csv b/ressources/Rule/cutsomrule.csv deleted file mode 100644 index e16241f..0000000 --- a/ressources/Rule/cutsomrule.csv +++ /dev/null @@ -1,2 +0,0 @@ -0;1;2;3;4 -3 \ No newline at end of file diff --git a/gasRule.json b/ressources/Rule/gasRule.json similarity index 100% rename from gasRule.json rename to ressources/Rule/gasRule.json diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index c36f1be..ee1f58c 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -1,3 +1,4 @@ + package backend; import java.io.FileNotFoundException; import java.io.FileReader; From 82d53fcb228e382893938de97782a865b68d21e0 Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 29 May 2024 10:41:37 +0200 Subject: [PATCH 2/5] changed path default rule --- src/backend/Simulator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index ee1f58c..ef1892b 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -72,7 +72,7 @@ public class Simulator extends Thread { //Default rule : Survive always, birth never - loadRule("OOP_F1_Project\\conwayRule.json"); + loadRule("ressources\\Rule\\conwayRule.json"); } From 5d408b84e09eb9babc9a2c52866b1950e14061cb Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 29 May 2024 11:22:42 +0200 Subject: [PATCH 3/5] stop button & blobrule color --- ressources/Rule/BlobRule.json | 4 ++-- src/windowInterface/MyInterface.java | 29 +++++++++++++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ressources/Rule/BlobRule.json b/ressources/Rule/BlobRule.json index 822a900..be22af7 100644 --- a/ressources/Rule/BlobRule.json +++ b/ressources/Rule/BlobRule.json @@ -1,6 +1,6 @@ [{"cell": { "value" : 1, - "color" : [167,237,139], + "color" : [255,255,66], "conditionCountNear" : [3,5,7], "conditionHighestNear" : [], "ifValue" : 1, @@ -8,7 +8,7 @@ }}, {"cell": { "value" : 0, - "color" : [37,52,31], + "color" : [97, 94, 58], "conditionCountNear" : [1,3,5,8], "conditionHighestNear" : [], "ifValue" : 1, diff --git a/src/windowInterface/MyInterface.java b/src/windowInterface/MyInterface.java index d58cc85..30d431b 100644 --- a/src/windowInterface/MyInterface.java +++ b/src/windowInterface/MyInterface.java @@ -66,6 +66,14 @@ public class MyInterface extends JFrame { panelRight.setLayout(new GridLayout(12,1)); contentPane.add(panelRight, BorderLayout.EAST); + JButton btnStop = new JButton("Stop/Reset"); + btnStop.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + stopSimu(); + } + }); + panelTop.add(btnStop); + JButton btnGo = new JButton("Start/Pause"); btnGo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { @@ -133,14 +141,6 @@ public class MyInterface extends JFrame { } }); panelRight.add(btnLoadRule); - - JButton btnSaveRule = new JButton("Save Rule"); - btnSaveRule.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - clicSaveRuleToFileButton(); - } - }); - panelRight.add(btnSaveRule); JButton btnLoadAgents = new JButton("Load Agents"); btnLoadAgents.addActionListener(new ActionListener() { @@ -205,6 +205,11 @@ public class MyInterface extends JFrame { panelRight.add(clickLabel); clickLabel.setText("click : " + mySimu.clickActionName()); } + public void stopSimu() { + mySimu = new Simulator(this); + panelDraw.setSimu(mySimu); + panelDraw.repaint(); + } public void setStepBanner(String s) { stepLabel.setText(s); @@ -350,14 +355,6 @@ public class MyInterface extends JFrame { } } - public void clicSaveRuleToFileButton() { - String fileName=SelectFile(); - if (fileName.length()>0) { - ArrayList content = mySimu.getRule(); - writeFile(fileName, (String[]) content.toArray()); - } - } - public void clicSaveAgentsToFileButton() { String fileName=SelectFile(); if (fileName.length()>0) { From 3ceb42614ad4b17978414eff4d6659a9b631d4bd Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 29 May 2024 11:27:38 +0200 Subject: [PATCH 4/5] fixed colorarraylist missing --- src/backend/Simulator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index d6db4ad..aa0d270 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -85,6 +85,10 @@ public class Simulator extends Thread { return this.height; } + public ArrayList> getColorArrayList(){ + return colorArrayList; + } + //Should probably stay as is public void run() { int stepCount=0; From 375742504ba471ff605045701d5f8f185ede10a4 Mon Sep 17 00:00:00 2001 From: "guillaume.bonabau" Date: Wed, 29 May 2024 11:36:05 +0200 Subject: [PATCH 5/5] fixed simu not pausing when stopped --- src/backend/Simulator.java | 4 ++-- src/windowInterface/MyInterface.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index aa0d270..0619dd6 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -20,8 +20,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; diff --git a/src/windowInterface/MyInterface.java b/src/windowInterface/MyInterface.java index 30d431b..60dbdf8 100644 --- a/src/windowInterface/MyInterface.java +++ b/src/windowInterface/MyInterface.java @@ -206,6 +206,7 @@ public class MyInterface extends JFrame { clickLabel.setText("click : " + mySimu.clickActionName()); } public void stopSimu() { + mySimu.togglePause(); mySimu = new Simulator(this); panelDraw.setSimu(mySimu); panelDraw.repaint();