Othello/src/othello/Main.java

38 lines
971 B
Java
Raw Normal View History

2021-01-27 12:24:17 +01:00
package othello;
2021-02-22 10:57:07 +01:00
import othello.players.NegamaxPlayer;
2021-02-16 13:41:20 +01:00
import othello.players.Player;
import othello.players.RandomPlayer;
2021-01-27 12:24:17 +01:00
public class Main {
2021-01-27 12:24:17 +01:00
public static void main(String[] args) {
Player p1 = new RandomPlayer(1);
2021-02-22 10:57:07 +01:00
Player p2 = new NegamaxPlayer(-1);
2021-02-16 13:41:20 +01:00
Player[][] board = initialize(p1, p2);
State game = new State(board, p1, p2);
System.out.println("joueur 1: " + p1);
System.out.println("joueur 2: " + p2);
while(!game.isOver()) {
2021-02-16 13:41:20 +01:00
Player player = game.getCurrentPlayer();
System.out.println(game.toString());
game = game.play(player.play(game));
}
System.out.println(game.toString());
System.out.println(game.getWinner() + " a gagné la partie");
System.out.println(game.getScore(p1));
System.out.println(game.getScore(p2));
2021-01-27 12:24:17 +01:00
}
2021-02-16 13:41:20 +01:00
public static Player[][] initialize(Player p1, Player p2){
Player[][] board = new Player[7][7];
2021-01-27 12:24:17 +01:00
board[0][0] = p2;
board[0][6] = p1;
board[6][0] = p1;
board[6][6] = p2;
return board;
}
}