fixed previousSituation
This commit is contained in:
parent
35f0158eb8
commit
c4c4a7ac76
@ -19,6 +19,7 @@ public class Main {
|
|||||||
System.out.println("joueur 1: " + p1);
|
System.out.println("joueur 1: " + p1);
|
||||||
System.out.println("joueur 2: " + p2);
|
System.out.println("joueur 2: " + p2);
|
||||||
while(!game.isOver()) {
|
while(!game.isOver()) {
|
||||||
|
State.previousSituations.add(game.toString());
|
||||||
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));
|
||||||
|
@ -26,6 +26,7 @@ public class MainStats {
|
|||||||
PrintWriter writer2 = new PrintWriter("statsj2.txt");
|
PrintWriter writer2 = new PrintWriter("statsj2.txt");
|
||||||
|
|
||||||
while(!game.isOver()) {
|
while(!game.isOver()) {
|
||||||
|
State.previousSituations.add(game.toString());
|
||||||
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));
|
||||||
|
@ -12,7 +12,7 @@ public class State {
|
|||||||
* been played, the game ends.
|
* been played, the game ends.
|
||||||
* We only keep the 10 previous situations due to performances issues
|
* 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[][] board;
|
||||||
private final Player player1;
|
private final Player player1;
|
||||||
@ -32,7 +32,7 @@ public class State {
|
|||||||
|
|
||||||
public boolean isOver() {
|
public boolean isOver() {
|
||||||
return n1 == 0 || n2 == 0 || (getMove(player1).isEmpty() && getMove(player2).isEmpty())
|
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
|
* @return a modified copy of the current situation
|
||||||
*/
|
*/
|
||||||
public State play(Pair<Point,Point> move) {
|
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.remove(0);
|
||||||
previousSituations.add(board);
|
|
||||||
State copy = this.copy();
|
State copy = this.copy();
|
||||||
boolean isJump = move.getLeft().isJump(move.getRight(), copy.board);
|
boolean isJump = move.getLeft().isJump(move.getRight(), copy.board);
|
||||||
copy.board[move.getRight().getY()][move.getRight().getX()] = copy.currentPlayer;
|
copy.board[move.getRight().getY()][move.getRight().getX()] = copy.currentPlayer;
|
||||||
|
33
statsj1.txt
33
statsj1.txt
@ -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
|
33
statsj2.txt
33
statsj2.txt
@ -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
|
Loading…
Reference in New Issue
Block a user