Othello/src/othello/State.java

66 lines
1.2 KiB
Java
Raw Normal View History

2021-01-27 11:49:49 +01:00
package othello;
2021-01-27 13:00:52 +01:00
import java.util.ArrayList;
2021-01-27 11:49:49 +01:00
public class State {
2021-01-27 13:00:52 +01:00
private int[][] board;
private int player1;
private int player2;
private int currentPlayer;
2021-01-27 12:24:17 +01:00
2021-01-27 13:00:52 +01:00
public State(int[][] board, int p1, int p2) {
2021-01-27 12:24:17 +01:00
this.board = board;
this.player1 = p1;
this.player2 = p2;
currentPlayer = p1;
}
2021-01-27 11:49:49 +01:00
public boolean isOver() {
return false;
}
2021-01-27 13:00:52 +01:00
public ArrayList<int[][]> getMove(String player) {
return null;
2021-01-27 11:49:49 +01:00
}
public int getScore(String player) {
return 0;
}
2021-01-27 13:00:52 +01:00
public State play(int x, int y) {
State copie = this.copie();
copie.board[x][y] = copie.getCurrentPlayer();
copie.switchPlayer();
return copie;
2021-01-27 11:49:49 +01:00
}
2021-01-27 12:24:17 +01:00
2021-01-27 13:00:52 +01:00
public int getCurrentPlayer() {
2021-01-27 12:24:17 +01:00
return currentPlayer;
}
2021-01-27 11:49:49 +01:00
2021-01-27 13:00:52 +01:00
public void setCurrentPlayer(int currentPlayer) {
this.currentPlayer = currentPlayer;
}
public State copie () {
State copie = new State (this.board, this.player1, this.player2);
for (int i=0; i<this.board.length;i++) {
for (int j=0; j<this.board.length; j++) {
copie.board[i][j] = this.board[i][j];
}
}
return copie;
}
public void switchPlayer () {
if (getCurrentPlayer()==this.player1) {
setCurrentPlayer(player2);
}
else {
setCurrentPlayer(player1);
}
}
2021-01-27 11:49:49 +01:00
}