diff --git a/Grid.java b/Grid.java index 7d3d88e936c9c0a62cb4f3a3c85ccfcb2f2ca504..09e0d081843738b6928704459652083fbf5c71dc 100644 --- a/Grid.java +++ b/Grid.java @@ -133,6 +133,29 @@ public class Grid implements Iterable<Cell> { } return tableau; } + private String countColorNeighbours(int rowIndex, int columnIndex) { + String CounterColorCell; + int Red = 0; + int Blue = 0; + for (Cell NeighboursCell : this.getNeighbours(rowIndex, columnIndex)) { + if (NeighboursCell.isAlive()) { + if ((NeighboursCell.getColor()).equals("Red")) { + Red+=1; + } + else { + Blue+=1; + } + } + } + if (Red>Blue) { + CounterColorCell="Red"; + } + else { + CounterColorCell="Blue"; + } + + return CounterColorCell; + }