From 3a92e315d0773de97a4454599d05912bf0dcdc7d Mon Sep 17 00:00:00 2001 From: Antonin Boyon Date: Thu, 25 Feb 2021 13:57:49 +0100 Subject: [PATCH] Statistics --- src/othello/Main.java | 13 ++++---- src/othello/MainStats.java | 55 +++++++++++++++++++++++++++++++ statsj1.txt | 67 ++++++++++++++++++++++++++++++++++++++ statsj2.txt | 67 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 196 insertions(+), 6 deletions(-) create mode 100644 src/othello/MainStats.java create mode 100644 statsj1.txt create mode 100644 statsj2.txt diff --git a/src/othello/Main.java b/src/othello/Main.java index f0eb560..094c7f2 100644 --- a/src/othello/Main.java +++ b/src/othello/Main.java @@ -1,25 +1,26 @@ package othello; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; + import othello.players.AlphaBetaPlayer; import othello.players.Player; public class Main { - public static void main(String[] args) { - Player p1 = new AlphaBetaPlayer(5); - Player p2 = new AlphaBetaPlayer(5); + public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { + Player p1 = new AlphaBetaPlayer(4); + Player p2 = new AlphaBetaPlayer(4); Player[][] board = initialize(p1, p2); State game = new State(board, p1, p2); System.out.println("joueur 1: " + p1); System.out.println("joueur 2: " + p2); - int tour = 0; // Pour le rapport while(!game.isOver()) { Player player = game.getCurrentPlayer(); System.out.println(game.toString()); game = game.play(player.play(game)); - System.out.println("Tour "+tour+" ; complex : "+player.getComplexity()); - tour++; } System.out.println(game.toString()); System.out.println(game.getN1()+" "+ game.getN2()); diff --git a/src/othello/MainStats.java b/src/othello/MainStats.java new file mode 100644 index 0000000..ce0a310 --- /dev/null +++ b/src/othello/MainStats.java @@ -0,0 +1,55 @@ +package othello; + +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; + +import othello.players.AlphaBetaPlayer; +import othello.players.Player; + +public class MainStats { + + + public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { + Player p1 = new AlphaBetaPlayer(1); + Player p2 = new AlphaBetaPlayer(5); + Player[][] board = initialize(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", "UTF-8"); + PrintWriter writer2 = new PrintWriter("statsj2.txt", "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 { + writer.println(player.getComplexity()); + } + tour++; + } + writer.close(); + writer2.close(); + 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.getN1()); + System.out.println("Score joueur 2 -> "+ game.getN2()); + + } + + public static Player[][] initialize(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; + } + +} diff --git a/statsj1.txt b/statsj1.txt new file mode 100644 index 0000000..021ccfa --- /dev/null +++ b/statsj1.txt @@ -0,0 +1,67 @@ +6 +16 +29 +44 +66 +90 +111 +142 +168 +195 +221 +249 +287 +327 +362 +393 +424 +461 +494 +527 +563 +607 +638 +671 +706 +737 +766 +797 +827 +854 +886 +915 +940 +969 +992 +1023 +1053 +1091 +1125 +1165 +1196 +1234 +1274 +1313 +1348 +1386 +1424 +1462 +1501 +1538 +1579 +1615 +1654 +1684 +1710 +1742 +1767 +1791 +1810 +1836 +1856 +1875 +1895 +1905 +1914 +1922 +1928 diff --git a/statsj2.txt b/statsj2.txt new file mode 100644 index 0000000..ce2cc9a --- /dev/null +++ b/statsj2.txt @@ -0,0 +1,67 @@ +6 +16 +28 +37 +46 +56 +65 +75 +86 +107 +121 +133 +149 +172 +194 +206 +234 +254 +272 +295 +319 +338 +357 +378 +409 +435 +465 +495 +523 +551 +577 +605 +630 +654 +681 +709 +735 +757 +785 +800 +825 +836 +849 +867 +875 +891 +905 +921 +936 +951 +961 +983 +1003 +1020 +1036 +1047 +1061 +1075 +1084 +1098 +1112 +1120 +1123 +1128 +1136 +1139 +1146