This commit is contained in:
Balthazar SQUINABOL 2024-04-25 10:42:18 +02:00
commit 7c4b0bc3b4
3 changed files with 7 additions and 25 deletions

View File

@ -15,4 +15,7 @@ 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 doesnt have exactly 3 living neighbors stays dead, 5. Any dead cell who doesnt have exactly 3 living neighbors stays dead,
unchanged. unchanged.
TEST

View File

@ -117,7 +117,7 @@ public class Simulator extends Thread {
Table tempTable = new Table(this.height, this.width); Table tempTable = new Table(this.height, this.width);
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++) {
if (this.table.getCell(x, y).getValue()=1) { if (table.getCell(x, y).getValue()==1) {
if (table.countNear(x,y)<2) { if (table.countNear(x,y)<2) {
tempTable.getCell(x,y).setValue(0); tempTable.getCell(x,y).setValue(0);
} else if(table.countNear(x,y)>3) { } else if(table.countNear(x,y)>3) {

View File

@ -34,31 +34,10 @@ public class Table {
//return the Cell object of coordinates x, y //return the Cell object of coordinates x, y
return table.get(x).get(y); return table.get(x).get(y);
} }
//TODO-INPROGRESS : set(Cell, x, y) set an object Cell to coordinate x, y //TODO : set(Cell, x, y) set an object Cell to coordinate x, y
public void setCell(Cell cell, int x, int y) {
table.get(x).set(y, cell);
}
public boolean isLoopingBorder() { //TODO : count around (xy) -> return how many around this cell
return simulator.isLoopingBorder();
}
//TODO-INPROGRESS : count around (xy) -> return how many around this cell
//2 modes needed : 1 with borders and 1 without
public int countNear(int x, int y) {
// Count the number of living cells around the specified cell
int count = 0;
return count;
}
//TODO : set agent (x y agent) load an agent to coordinates x,y //TODO : set agent (x y agent) load an agent to coordinates x,y
//TODO : set random (density) create a random table of determined density //TODO : set random (density) create a random table of determined density