From 007363fccadcc14e234a3c65fbb39d429c799fb4 Mon Sep 17 00:00:00 2001 From: maxim Date: Fri, 24 May 2024 14:24:37 +0200 Subject: [PATCH] V3256.2 --- src/backend/Grid.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/Grid.java b/src/backend/Grid.java index 408965c..3884856 100644 --- a/src/backend/Grid.java +++ b/src/backend/Grid.java @@ -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()); 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++) {