From bd7a8e1f84d21acdcadd9d7367f6e483114664ac Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Sun, 28 Feb 2021 12:27:13 +0100 Subject: [PATCH] revert commit 6e4241c5 --- ...phaBetaPlayer.java => AlphaBetaPlayer.txt} | 0 Rapport/META-INF/MANIFEST.MF | 3 + .../{NegamaxPlayer.java => NegamaxPlayer.txt} | 0 Rapport/Rapport.tex | 4 +- src/othello/MainStats.java | 63 +++---------------- 5 files changed, 14 insertions(+), 56 deletions(-) rename Rapport/{AlphaBetaPlayer.java => AlphaBetaPlayer.txt} (100%) create mode 100644 Rapport/META-INF/MANIFEST.MF rename Rapport/{NegamaxPlayer.java => NegamaxPlayer.txt} (100%) diff --git a/Rapport/AlphaBetaPlayer.java b/Rapport/AlphaBetaPlayer.txt similarity index 100% rename from Rapport/AlphaBetaPlayer.java rename to Rapport/AlphaBetaPlayer.txt diff --git a/Rapport/META-INF/MANIFEST.MF b/Rapport/META-INF/MANIFEST.MF new file mode 100644 index 0000000..4f39cf6 --- /dev/null +++ b/Rapport/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: othello.MainStats + diff --git a/Rapport/NegamaxPlayer.java b/Rapport/NegamaxPlayer.txt similarity index 100% rename from Rapport/NegamaxPlayer.java rename to Rapport/NegamaxPlayer.txt diff --git a/Rapport/Rapport.tex b/Rapport/Rapport.tex index c65c13a..7c471e9 100644 --- a/Rapport/Rapport.tex +++ b/Rapport/Rapport.tex @@ -44,14 +44,14 @@ Notre code se compose de plusieurs classes dont nous allons détailler les rôle Nous avons utilisé un algorithme Negamax pour résoudre le problème, représenté en pseudo-code ci-dessous. -\lstinputlisting[language=Java]{NegamaxPlayer.java} +\lstinputlisting[language=Java]{NegamaxPlayer.txt} \newpage \subsection{Algorithme d'élagage} Afin d'améliorer les performances de notre algorithme de base, nous avons implémenté une version avec élagage Alpha-Beta, plus performante. -\lstinputlisting[language=Java]{AlphaBetaPlayer.java} +\lstinputlisting[language=Java]{AlphaBetaPlayer.txt} \newpage \section{Mesures} diff --git a/src/othello/MainStats.java b/src/othello/MainStats.java index c831f9b..ec99fe6 100644 --- a/src/othello/MainStats.java +++ b/src/othello/MainStats.java @@ -10,26 +10,25 @@ import othello.players.AlphaBetaPlayer; import othello.players.NegamaxPlayer; import othello.players.Player; + public class MainStats { - - public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { - Player p1 = new NegamaxPlayer(1); - Player p2 = new NegamaxPlayer(1); - Player[][] board = initializeBoard(p1, p2); - + public static void main(String[] args) throws IOException { + Player[] players = Main.extractArgs(args); + Player p1 = players[0]; + Player p2 = players[1]; + Player[][] board = Main.initializeBoard(p1, p2); State game = new State(board, p1, p2); System.out.println("joueur 1: " + p1); System.out.println("joueur 2: " + p2); int tour = 1; // Pour le rapport - PrintWriter writer = new PrintWriter("statsj1.txt"); - PrintWriter writer2 = new PrintWriter("statsj2.txt"); - + PrintWriter writer = new PrintWriter("statsj1.txt", StandardCharsets.UTF_8); + PrintWriter writer2 = new PrintWriter("statsj2.txt", StandardCharsets.UTF_8); + while(!game.isOver()) { Player player = game.getCurrentPlayer(); System.out.println(game.toString()); game = game.play(player.play(game)); - if(tour % 2 == 0) writer2.println(player.getComplexity()); else @@ -40,49 +39,5 @@ public class MainStats { writer2.close(); Main.endGame(game, p1, p2); } - - public static Player[] extractArgs(String[] args) { - Player p1; - Player p2; - int depthP1 = 4; - int depthP2 = 4; - boolean useAlphaBeta = true; - try { - if(args.length >= 3) { // les paramètres > 3 sont ignorés - depthP1 = Integer.parseInt(args[0]); - depthP2 = Integer.parseInt(args[1]); - useAlphaBeta = Boolean.parseBoolean(args[2]); - } - } catch (NumberFormatException e) { - System.out.println("Les arguments de lancement ne pas corrects (pas des nombres entiers)"); - System.out.println("Utilisation des paramètres par défaut ( 4 4 true )"); - } finally { - if(useAlphaBeta) { - p1 = new AlphaBetaPlayer(depthP1); - p2 = new AlphaBetaPlayer(depthP2); - } else { - p1 = new NegamaxPlayer(depthP1); - p2 = new NegamaxPlayer(depthP2); - } - } - return new Player[]{p1, p2}; - } - - public static Player[][] initializeBoard(Player p1, Player p2){ - Player[][] board = new Player[7][7]; - board[0][0] = p2; - board[0][6] = p1; - board[6][0] = p1; - board[6][6] = p2; - return board; - } - public static void endGame(State game, Player p1, Player p2) { - System.out.println(game.toString()); - System.out.println(game.getN1()+" "+ game.getN2()); - System.out.println(game.getWinner() + " a gagné la partie"); - System.out.println("Score joueur 1 -> " + game.getScore(p1)); - System.out.println("Score joueur 2 -> "+ game.getScore(p2)); - } - }