play funcytion

This commit is contained in:
Cyprien111
2025-04-07 09:01:15 +02:00
parent e27f842198
commit 60afcfac8f
2 changed files with 25 additions and 2 deletions

View File

@@ -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.
*/

View File

@@ -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