Statistics

This commit is contained in:
Antonin Boyon 2021-02-25 13:57:49 +01:00
parent 56b97547b1
commit 3a92e315d0
4 changed files with 196 additions and 6 deletions

View File

@ -1,25 +1,26 @@
package othello; package othello;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import othello.players.AlphaBetaPlayer; import othello.players.AlphaBetaPlayer;
import othello.players.Player; import othello.players.Player;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
Player p1 = new AlphaBetaPlayer(5); Player p1 = new AlphaBetaPlayer(4);
Player p2 = new AlphaBetaPlayer(5); Player p2 = new AlphaBetaPlayer(4);
Player[][] board = initialize(p1, p2); Player[][] board = initialize(p1, p2);
State game = new State(board, p1, p2); State game = new State(board, p1, p2);
System.out.println("joueur 1: " + p1); System.out.println("joueur 1: " + p1);
System.out.println("joueur 2: " + p2); System.out.println("joueur 2: " + p2);
int tour = 0; // Pour le rapport
while(!game.isOver()) { while(!game.isOver()) {
Player player = game.getCurrentPlayer(); Player player = game.getCurrentPlayer();
System.out.println(game.toString()); System.out.println(game.toString());
game = game.play(player.play(game)); game = game.play(player.play(game));
System.out.println("Tour "+tour+" ; complex : "+player.getComplexity());
tour++;
} }
System.out.println(game.toString()); System.out.println(game.toString());
System.out.println(game.getN1()+" "+ game.getN2()); System.out.println(game.getN1()+" "+ game.getN2());

View File

@ -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;
}
}

67
statsj1.txt Normal file
View File

@ -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

67
statsj2.txt Normal file
View File

@ -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