Merge branch 'main' of https://gitarero.ecam.fr/guillaume.bonabau/OOP_F1_Project
This commit is contained in:
commit
eaeb33d9c2
121
README.md
121
README.md
|
|
@ -1,21 +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:
|
# Game Of Life
|
||||||
https://www.canva.com/design/DAGCBGF5b4c/4cNmhoS6lSC8Once9r_Tlg/edit?utm_content=DAGCBGF5b4c&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton
|
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
|
1. Any living cell with strictly fewer than two living neighbors dies (referred to
|
||||||
as underpopulation or exposure).
|
as underpopulation or exposure).
|
||||||
|
|
||||||
2. Any living cell with strictly more than three living neighbors dies (referred to
|
2. Any living cell with strictly more than three living neighbors dies (referred to
|
||||||
as overpopulation or overcrowding).
|
as overpopulation or overcrowding).
|
||||||
|
|
||||||
3. Any dead cell with exactly three living neighbors will come to life. (Referred to as
|
3. Any dead cell with exactly three living neighbors will come to life. (Referred to as
|
||||||
spreading or growth)
|
spreading or growth)
|
||||||
With the implied additional rules:
|
With the implied additional rules:
|
||||||
|
|
||||||
4. Any living cell with two or three living neighbors continues to live, unchanged.
|
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.
|
||||||
|
|
||||||
|
|
||||||
TEST
|
|
||||||
|
## 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 | [37,52,31] |
|
||||||
|
| Alived |  #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
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
[{"cell": {
|
||||||
|
"value" : 1,
|
||||||
|
"color" : [167,237,139],
|
||||||
|
"conditionCountNear" : [2,3],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 1,
|
||||||
|
"elseValue" : 0
|
||||||
|
}},
|
||||||
|
{"cell": {
|
||||||
|
"value" : 0,
|
||||||
|
"color" : [37,52,31],
|
||||||
|
"conditionCountNear" : [3],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 1,
|
||||||
|
"elseValue" : 0
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
[{"cell": {
|
||||||
|
"value" : 5,
|
||||||
|
"color" : [255,255,255],
|
||||||
|
"conditionCountNear" : [],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 4,
|
||||||
|
"elseValue" : 4
|
||||||
|
}},
|
||||||
|
{"cell": {
|
||||||
|
"value" : 4,
|
||||||
|
"color" : [204,204,204],
|
||||||
|
"conditionCountNear" : [],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 3,
|
||||||
|
"elseValue" : 3
|
||||||
|
}},
|
||||||
|
{"cell": {
|
||||||
|
"value" : 3,
|
||||||
|
"color" : [153,153,153],
|
||||||
|
"conditionCountNear" : [],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 2,
|
||||||
|
"elseValue" : 2
|
||||||
|
}},
|
||||||
|
{"cell": {
|
||||||
|
"value" : 2,
|
||||||
|
"color" : [102,102,102],
|
||||||
|
"conditionCountNear" : [],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 1,
|
||||||
|
"elseValue" : 1
|
||||||
|
}},
|
||||||
|
{"cell": {
|
||||||
|
"value" : 1,
|
||||||
|
"color" : [51,51,51],
|
||||||
|
"conditionCountNear" : [],
|
||||||
|
"conditionHighestNear" : [],
|
||||||
|
"ifValue" : 0,
|
||||||
|
"elseValue" : 0
|
||||||
|
}},
|
||||||
|
{"cell": {
|
||||||
|
"value" : 0,
|
||||||
|
"color" : [0,0,0],
|
||||||
|
"conditionCountNear" : [],
|
||||||
|
"conditionHighestNear" : [5],
|
||||||
|
"ifValue" : 5,
|
||||||
|
"elseValue" : 0
|
||||||
|
}}]
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
0;1;2;3;4
|
||||||
|
3
|
||||||
|
|
|
@ -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;0;0;0;5;0;0;5;0;0;5;0;5;0;5;0;5;5;5;5;5;0;0;5;0;0;0;5;5;0;0;5;5;0;5;0;0;0;0;0;5;5;0;0;5;0;5;5;5;0;5;0;5;0;0;5;5;5;0;5;0;5;0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;0;5;0;5;5;5;5;0;5;0;0;5;5;0;0;5;5;5;5;0;0;5;0;0;0;0;0;5;0;5;5;5;0;0;5;5;0;0;0;5;5;0;5;0;0;5;5;0;5;5;0;5;5;5;5;5;5;0;0;0;0;0;0;5;5;5;0
|
||||||
|
0;5;5;5;5;0;0;5;0;0;0;0;5;0;0;0;0;0;5;5;0;5;5;0;0;5;5;0;5;0;0;0;0;5;5;5;0;0;0;0;0;0;5;5;5;5;0;0;0;0;5;5;5;5;5;5;5;0;0;5;5;0;0;5;5;0;0;5;0;0;0;0;5;5;0;5;0;0;0;0;5;5;0;0;5;5;5;0;5;0;0;5;5;5;0;5;5;5;5;5
|
||||||
|
0;0;0;5;0;0;5;0;5;0;0;5;5;5;0;5;5;5;5;0;0;0;5;5;0;5;0;0;0;5;0;5;5;0;5;5;5;0;0;5;5;5;5;0;5;5;5;0;5;0;0;5;5;0;0;0;5;0;5;5;0;0;5;0;0;0;5;0;0;5;5;0;5;0;0;5;5;5;0;5;0;0;0;5;5;5;0;0;0;5;0;0;5;5;5;0;0;5;0;5
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package backend;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Rule {
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
private ArrayList<Integer> color;
|
||||||
|
private ArrayList<Integer> conditionCountNear;
|
||||||
|
private ArrayList<Integer> conditionHighestNear;
|
||||||
|
private int ifValue;
|
||||||
|
private int elseValue;
|
||||||
|
|
||||||
|
public Rule(int value , ArrayList<Integer> color, ArrayList<Integer> conditionCountNear, ArrayList<Integer> 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 ArrayList<Integer> getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(ArrayList<Integer> color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getConditionCountNear() {
|
||||||
|
return conditionCountNear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConditionCountNear(ArrayList<Integer> conditionCountNear) {
|
||||||
|
this.conditionCountNear = conditionCountNear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getConditionHighestNear() {
|
||||||
|
return conditionHighestNear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConditionHighestNear(ArrayList<Integer> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
package backend;
|
package backend;
|
||||||
import java.awt.Color;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
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;
|
import windowInterface.MyInterface;
|
||||||
|
|
||||||
|
|
@ -32,6 +42,11 @@ public class Simulator extends Thread {
|
||||||
private Table table;
|
private Table table;
|
||||||
private boolean cellDensityToggle;
|
private boolean cellDensityToggle;
|
||||||
|
|
||||||
|
//Rules Arraylists
|
||||||
|
private ArrayList<Rule> ruleArrayList = new ArrayList<Rule>();
|
||||||
|
private ArrayList<ArrayList<Integer>> colorArrayList = new ArrayList<ArrayList<Integer>>();
|
||||||
|
|
||||||
|
|
||||||
public Simulator(MyInterface mjfParam) {
|
public Simulator(MyInterface mjfParam) {
|
||||||
mjf = mjfParam;
|
mjf = mjfParam;
|
||||||
stopFlag=false;
|
stopFlag=false;
|
||||||
|
|
@ -49,14 +64,12 @@ public class Simulator extends Thread {
|
||||||
this.height=LINE_NUM;
|
this.height=LINE_NUM;
|
||||||
enableLogs = true; // for debugging purposes
|
enableLogs = true; // for debugging purposes
|
||||||
table = new Table(height, width, this);
|
table = new Table(height, width, this);
|
||||||
cellDensityToggle=false;
|
cellDensityToggle=true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Default rule : Survive always, birth never
|
//Default rule : Survive always, birth never
|
||||||
for(int i =0; i<9; i++) {
|
loadRule("OOP_F1_Project\\conwayRule.json");
|
||||||
fieldSurviveValues.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,7 +129,7 @@ public class Simulator extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//then evolution of the field
|
//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();
|
this.applyRule();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -169,20 +182,10 @@ public class Simulator extends Thread {
|
||||||
int currentCellValue = getCell(x, y);
|
int currentCellValue = getCell(x, y);
|
||||||
int newCellValue = 0;
|
int newCellValue = 0;
|
||||||
if(cellDensityToggle) {
|
if(cellDensityToggle) {
|
||||||
if (currentCellValue == -1) {
|
if (currentCellValue <6) {
|
||||||
newCellValue = 0;
|
newCellValue = currentCellValue +1;
|
||||||
}
|
} else {
|
||||||
if (currentCellValue == 0) {
|
newCellValue=-1;
|
||||||
newCellValue = 1;
|
|
||||||
}
|
|
||||||
if (currentCellValue == 1) {
|
|
||||||
newCellValue = 2;
|
|
||||||
}
|
|
||||||
if (currentCellValue == 2) {
|
|
||||||
newCellValue = 3;
|
|
||||||
}
|
|
||||||
if (currentCellValue == 3) {
|
|
||||||
newCellValue = -1;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentCellValue == 0) {
|
if (currentCellValue == 0) {
|
||||||
|
|
@ -438,62 +441,119 @@ public class Simulator extends Thread {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRule(ArrayList<String> lines) {
|
@SuppressWarnings("unchecked")
|
||||||
if(lines.size()<=0) {
|
public void loadRule(String fileName) {
|
||||||
System.out.println("empty rule file");
|
System.out.println(fileName);
|
||||||
return;
|
//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();
|
||||||
}
|
}
|
||||||
//TODO-INPROGRESS : remove previous rule (=emptying lists)
|
//DEBUG
|
||||||
fieldSurviveValues = new ArrayList<Integer>();
|
//printRules(ruleArrayList);
|
||||||
fieldBirthValues = new ArrayList<Integer>();
|
}
|
||||||
|
|
||||||
String surviveLine = lines.get(0);
|
@SuppressWarnings("unchecked")
|
||||||
String birthLine = lines.get(1);
|
private void parseCellObject(JSONObject cell) {
|
||||||
|
// Get cell object within list
|
||||||
|
JSONObject cellObject = (JSONObject) cell.get("cell");
|
||||||
|
|
||||||
String[] surviveElements = surviveLine.split(";");
|
// Get value
|
||||||
for(int x=0; x<surviveElements.length;x++) {
|
int cellValue = ((Long) cellObject.get("value")).intValue();
|
||||||
String elem = surviveElements[x];
|
System.out.println("cell value rule loaded: " + cellValue);
|
||||||
int value = Integer.parseInt(elem);
|
|
||||||
//TODO-INPROGRESS : add value to possible survive values
|
|
||||||
fieldSurviveValues.add(value);
|
|
||||||
|
|
||||||
|
// Get color
|
||||||
|
JSONArray colorValueJsonArray = (JSONArray) cellObject.get("color");
|
||||||
|
ArrayList<Integer> rgbList = new ArrayList<>();
|
||||||
|
colorValueJsonArray.forEach(value -> rgbList.add(((Long) value).intValue()));
|
||||||
|
|
||||||
|
// Get Condition Count Near
|
||||||
|
JSONArray countNearJsonArray = (JSONArray) cellObject.get("conditionCountNear");
|
||||||
|
ArrayList<Integer> conditionCountNearList = new ArrayList<>();
|
||||||
|
countNearJsonArray.forEach(value -> conditionCountNearList.add(((Long) value).intValue()));
|
||||||
|
|
||||||
|
// Get Condition Highest Near
|
||||||
|
JSONArray conditionHighestNearJsonArray = (JSONArray) cellObject.get("conditionHighestNear");
|
||||||
|
ArrayList<Integer> 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.set(cellValue, rgbList);
|
||||||
|
|
||||||
String[] birthElements = birthLine.split(";");
|
// Ensure the ruleArrayList is large enough
|
||||||
for(int x=0; x<birthElements.length;x++) {
|
while (ruleArrayList.size() <= cellValue) {
|
||||||
String elem = birthElements[x];
|
ruleArrayList.add(null);
|
||||||
int value = Integer.parseInt(elem);
|
|
||||||
//TODO-INPROGRESS : add value to possible birth values
|
|
||||||
fieldBirthValues.add(value);
|
|
||||||
}
|
}
|
||||||
|
ruleArrayList.set(cellValue, new Rule(cellValue, rgbList, conditionCountNearList, conditionHighestNearList, ifValue, elseValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyRule(){
|
public void applyRule(){
|
||||||
Table tempTable = new Table(this.height, this.width, this);
|
Table tempTable = new Table(this.height, this.width, this);
|
||||||
for(int x=0; x<width; x++) {
|
for(int x = 0; x < width; x++) {
|
||||||
for(int y=0; y<height; y++) {
|
for(int y = 0; y < height; y++) {
|
||||||
int resultCountNear = this.table.countNear(x, y);
|
int valueCountNear = table.countNear(x, y);
|
||||||
if (this.getCell(x,y)==1) {
|
int valueHighestNear = table.highestNear(x, y);
|
||||||
if (this.fieldSurviveValues.contains(resultCountNear)) {
|
int currentValue = table.getCell(x, y).getValue();
|
||||||
tempTable.getCell(x, y).setValue(1);
|
Rule currentRule = ruleArrayList.get(currentValue);
|
||||||
} else {
|
|
||||||
tempTable.getCell(x, y).setValue(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(this.getCell(x,y)==0) {
|
|
||||||
if (this.fieldBirthValues.contains(resultCountNear)) {
|
|
||||||
tempTable.getCell(x, y).setValue(1);
|
|
||||||
} else {
|
|
||||||
tempTable.getCell(x, y).setValue(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//DEBUG:
|
|
||||||
//System.out.println("applying rule to cell: "+x+", "+y + " | countnear = " + resultCountNear + " | new cell value = " + this.getCell(x, y));
|
|
||||||
|
|
||||||
|
if (currentRule.getConditionCountNear().isEmpty() && currentRule.getConditionHighestNear().isEmpty()) {
|
||||||
|
// Both condition lists are empty, directly take if value
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getIfValue());
|
||||||
|
} else if (!currentRule.getConditionCountNear().isEmpty() && currentRule.getConditionHighestNear().isEmpty()) {
|
||||||
|
// Only countNear condition
|
||||||
|
if (currentRule.getConditionCountNear().contains(valueCountNear)) {
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getIfValue());
|
||||||
|
} else {
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getElseValue());
|
||||||
|
}
|
||||||
|
} else if (currentRule.getConditionCountNear().isEmpty() && !currentRule.getConditionHighestNear().isEmpty()) {
|
||||||
|
// Only highestNear condition
|
||||||
|
if (currentRule.getConditionHighestNear().contains(valueHighestNear)) {
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getIfValue());
|
||||||
|
} else {
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getElseValue());
|
||||||
|
}
|
||||||
|
} else if (!currentRule.getConditionCountNear().isEmpty() && !currentRule.getConditionHighestNear().isEmpty()) {
|
||||||
|
// Both conditions
|
||||||
|
if (currentRule.getConditionHighestNear().contains(valueHighestNear)
|
||||||
|
&& currentRule.getConditionCountNear().contains(valueCountNear)) {
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getIfValue());
|
||||||
|
} else {
|
||||||
|
tempTable.getCell(x, y).setValue(currentRule.getElseValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// DEBUG:
|
||||||
}
|
//System.out.println("Applying rule to cell: " + x + ", " + y +" | countNear = " + valueCountNear +" | highestNear = " + valueHighestNear +" | current cell value = " + currentValue +" | new cell value = " + tempTable.getCell(x, y).getValue());
|
||||||
this.table = tempTable;
|
}
|
||||||
|
}
|
||||||
|
this.table = tempTable;
|
||||||
|
//DEBUG
|
||||||
|
//table.serialPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -523,5 +583,22 @@ public class Simulator extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//debug print the list of rules
|
||||||
|
public void printRules(ArrayList<Rule> ruleArrayList) {
|
||||||
|
System.out.println("-----------------------------------");
|
||||||
|
System.out.println("Rule list size: "+ruleArrayList.size());
|
||||||
|
System.out.println("-----------------------------------");
|
||||||
|
for (Rule rule : ruleArrayList) {
|
||||||
|
System.out.println("Rule for value: " + rule.getValue());
|
||||||
|
System.out.println("Color: " + rule.getColor());
|
||||||
|
System.out.println("Condition Count Near: " + rule.getConditionCountNear());
|
||||||
|
System.out.println("Condition Highest Near: " + rule.getConditionHighestNear());
|
||||||
|
System.out.println("If Value: " + rule.getIfValue());
|
||||||
|
System.out.println("Else Value: " + rule.getElseValue());
|
||||||
|
System.out.println("-----------------------------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,40 @@ public class Table {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int highestNear(int row, int column) {
|
||||||
|
int highest = Integer.MIN_VALUE; // Initialize to the minimum integer value
|
||||||
|
boolean loopingBorder = isLoopingBorder();
|
||||||
|
|
||||||
|
// Define the relative positions of neighboring cells (assuming 8 neighbors)
|
||||||
|
int[][] neighbors = {
|
||||||
|
{-1, -1}, {-1, 0}, {-1, 1},
|
||||||
|
{0, -1}, {0, 1},
|
||||||
|
{1, -1}, {1, 0}, {1, 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int[] neighbor : neighbors) {
|
||||||
|
int x = row + neighbor[0];
|
||||||
|
int y = column + neighbor[1];
|
||||||
|
|
||||||
|
if (loopingBorder) {
|
||||||
|
x = (x + width) % width;
|
||||||
|
y = (y + height) % height;
|
||||||
|
} else {
|
||||||
|
if (x < 0 || x >= width || y < 0 || y >= height) {
|
||||||
|
// Border cell is outside the grid
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cellValue = this.getCell(x, y).getValue();
|
||||||
|
if (cellValue > highest) {
|
||||||
|
highest = cellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return highest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO : set random (density) create a random table of determined density
|
//TODO : set random (density) create a random table of determined density
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ public class JPanelDraw extends JPanel {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Simulator mySimu;
|
private Simulator mySimu;
|
||||||
private MyInterface interfaceGlobal;
|
private MyInterface interfaceGlobal;
|
||||||
|
ArrayList<ArrayList<Integer>> colorArrayList;
|
||||||
|
|
||||||
public JPanelDraw(MyInterface itf) {
|
public JPanelDraw(MyInterface itf) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -37,6 +38,7 @@ public class JPanelDraw extends JPanel {
|
||||||
|
|
||||||
public void setSimu(Simulator simu) {
|
public void setSimu(Simulator simu) {
|
||||||
mySimu = simu;
|
mySimu = simu;
|
||||||
|
colorArrayList = mySimu.getColorArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -61,19 +63,14 @@ public class JPanelDraw extends JPanel {
|
||||||
int cellContent = mySimu.getCell(x,y);
|
int cellContent = mySimu.getCell(x,y);
|
||||||
if(cellContent == -1) {
|
if(cellContent == -1) {
|
||||||
g.setColor(Color.gray);
|
g.setColor(Color.gray);
|
||||||
}
|
} else if(cellContent<colorArrayList.size() && cellContent>=0) {
|
||||||
if(cellContent == 0) {
|
int red = colorArrayList.get(cellContent).get(0);
|
||||||
continue;
|
int green = colorArrayList.get(cellContent).get(1);
|
||||||
}
|
int blue = colorArrayList.get(cellContent).get(2);
|
||||||
if(cellContent == 1) {
|
g.setColor(new Color(red,green,blue));
|
||||||
|
} else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
}
|
}
|
||||||
if(cellContent == 2) {
|
|
||||||
g.setColor(Color.yellow);
|
|
||||||
}
|
|
||||||
if(cellContent == 3) {
|
|
||||||
g.setColor(Color.red);
|
|
||||||
}
|
|
||||||
g.fillRect(
|
g.fillRect(
|
||||||
(int) Math.round(x*cellWidth),
|
(int) Math.round(x*cellWidth),
|
||||||
(int) Math.round(y*cellHeight),
|
(int) Math.round(y*cellHeight),
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,22 @@ import javax.swing.JLabel;
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
//added imports for loading jsons
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.*;
|
||||||
|
|
||||||
|
|
||||||
public class MyInterface extends JFrame {
|
public class MyInterface extends JFrame {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6840815447618468846L;
|
private static final long serialVersionUID = -6840815447618468846L;
|
||||||
|
|
@ -300,17 +310,13 @@ public class MyInterface extends JFrame {
|
||||||
ArrayList<String> stringArray = new ArrayList<String>();
|
ArrayList<String> stringArray = new ArrayList<String>();
|
||||||
if (fileName.length()>0) {
|
if (fileName.length()>0) {
|
||||||
try {
|
try {
|
||||||
BufferedReader fileContent = new BufferedReader(new FileReader(fileName));
|
mySimu.loadRule(fileName);
|
||||||
String line = fileContent.readLine();
|
|
||||||
while (line != null) {
|
|
||||||
stringArray.add(line);
|
|
||||||
line = fileContent.readLine();
|
|
||||||
}
|
|
||||||
fileContent.close();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
mySimu.loadRule(stringArray);
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue