diff --git a/src/GomokuAI.java b/src/GomokuAI.java index f7d9ceb..13c3f55 100644 --- a/src/GomokuAI.java +++ b/src/GomokuAI.java @@ -9,7 +9,7 @@ public class GomokuAI extends Player{ //------------------Constructors-------------------------- /** - * The constructor of the Human. + * The constructor of the GomokuAI. * @param name The name of the player. * @param color The color of the player. */ diff --git a/src/GomokuGame.java b/src/GomokuGame.java index 10eee43..1d47eea 100644 --- a/src/GomokuGame.java +++ b/src/GomokuGame.java @@ -1,8 +1,8 @@ -import java.nio.file.Path; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; public class GomokuGame { @@ -44,6 +44,29 @@ public class GomokuGame { } + /** + * Place the token on the cell where the player play. + * @param turn the turn of the player. + */ + public void play(int turn) { + + GomokuCell cellToPlay = null; + switch (turn) { + case 1: + cellToPlay = player1.chooseMove(board); + break; + case 2: + cellToPlay = player2.chooseMove(board); + break; + default: + throw new IllegalArgumentException("Invalid turn: " + turn); + } + + cellToPlay.setState(colorP1); + } + + + public boolean save(Path filename) { // save the game state to the file // 1. Open the file