Add expandable board mechanic, and add static array in Cardinal

This commit is contained in:
Dorian HAMDANI
2025-04-14 10:44:50 +02:00
parent 77becb3492
commit 207ba12714
3 changed files with 12 additions and 1 deletions

View File

@@ -147,6 +147,14 @@ public class GomokuGame {
while (currentPlay == null) {
currentPlay = this.play(this.currentPlayer);
}
// Expand the board if one of the neighbours of the cell is null
// Only check for North, South, East and West neighbours
for (Cardinal cardinal : Cardinal.NS_EW) {
GomokuCell neighbour = currentPlay.getNeighbour(cardinal);
if (neighbour == null) {
this.board.expandBoard(cardinal);
}
}
System.out.println(board.countMax(board.countAlignedCells(currentPlay)));
if (NB_CELL_PLAY <= board.countMax(board.countAlignedCells(currentPlay))) {
System.out.println("Le joueur " + this.currentPlayer + " a gagné !");