play funcytion
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user