fixed previousSituation

This commit is contained in:
Quentin Legot 2021-02-28 20:32:31 +01:00
parent 35f0158eb8
commit c4c4a7ac76
5 changed files with 71 additions and 4 deletions

View File

@ -19,6 +19,7 @@ public class Main {
System.out.println("joueur 1: " + p1);
System.out.println("joueur 2: " + p2);
while(!game.isOver()) {
State.previousSituations.add(game.toString());
Player player = game.getCurrentPlayer();
System.out.println(game.toString());
game = game.play(player.play(game));

View File

@ -26,6 +26,7 @@ public class MainStats {
PrintWriter writer2 = new PrintWriter("statsj2.txt");
while(!game.isOver()) {
State.previousSituations.add(game.toString());
Player player = game.getCurrentPlayer();
System.out.println(game.toString());
game = game.play(player.play(game));

View File

@ -12,7 +12,7 @@ public class State {
* been played, the game ends.
* We only keep the 10 previous situations due to performances issues
*/
public static List<Player[][]> previousSituations = new LinkedList<>();
public static List<String> previousSituations = new LinkedList<>();
private final Player[][] board;
private final Player player1;
@ -32,7 +32,7 @@ public class State {
public boolean isOver() {
return n1 == 0 || n2 == 0 || (getMove(player1).isEmpty() && getMove(player2).isEmpty())
|| previousSituations.contains(this.board);
|| previousSituations.contains(toString());
}
/**
@ -101,9 +101,8 @@ public class State {
* @return a modified copy of the current situation
*/
public State play(Pair<Point,Point> move) {
if(previousSituations.size() == 10) // on ne garde que les 10 dernieres situations par soucis de perfs
if(previousSituations.size() == 15) // on ne garde que les 10 dernieres situations par soucis de perfs
previousSituations.remove(0);
previousSituations.add(board);
State copy = this.copy();
boolean isJump = move.getLeft().isJump(move.getRight(), copy.board);
copy.board[move.getRight().getY()][move.getRight().getX()] = copy.currentPlayer;

View File

@ -0,0 +1,33 @@
6
16
29
46
66
98
134
166
208
233
262
291
327
382
442
497
537
590
651
680
718
758
786
804
812
828
853
863
889
918
945
974
1003

View File

@ -0,0 +1,33 @@
6
16
28
39
42
52
68
82
111
139
172
208
224
234
248
261
278
281
294
318
350
387
437
480
524
557
587
632
664
689
711
733
757