This commit is contained in:
maxim 2024-05-24 14:24:37 +02:00
parent 38abd2b6b6
commit 007363fcca
1 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,8 @@ package backend;
import java.util.ArrayList;
//Representing the grid for the simulation
public class Grid {
private int height;
private int width;
@ -15,6 +17,7 @@ public class Grid {
Grid = new ArrayList<>(height);
//Initialize the grid with cells set to 0
for (int i = 0; i < height; i++) {
this.Grid.add(i, new ArrayList<Cell>());
for (int j = 0; j < width; j++) {
@ -42,6 +45,7 @@ public class Grid {
this.Grid.get(row).set(column, cell);
}
//Count the number of neighboring cells with a value of 1
public int countAround(int row, int column) {
int count = 0;
boolean loopingBorder = isLoopingBorder();
@ -74,9 +78,9 @@ public class Grid {
//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 Grid of determined density
//TODO : set random (density) create a random Grid of determined density :
public void setRandom(double density) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {