méthode getMoves

This commit is contained in:
Antonin Boyon 2021-02-10 13:35:22 +01:00
parent 02821f1886
commit 93d83adad7
3 changed files with 10 additions and 4 deletions

View File

@ -9,11 +9,13 @@ public class Main {
int p1 = 1, p2 = 2;
int[][] board = initialize(p1, p2);
State game = new State(board, p1, p2);
while(!game.isOver()) {
board[1][5]=game.getCurrentPlayer();
/*while(!game.isOver()) {
int player = game.getCurrentPlayer();
ArrayList<Pair<Point, Point>> moves = game.getMove(player);
}
} */
ArrayList<Pair<Point, Point>> moves = game.getMove(game.getCurrentPlayer());
System.out.println(moves.toString());
}
public static int[][] initialize(int p1, int p2){

View File

@ -14,4 +14,9 @@ public class Point {
return Math.pow(other.x - this.x, 2) + Math.pow(other.y - this.y, 2) == 4;
}
@Override
public String toString () {
return "("+x+","+y+")";
}
}

View File

@ -50,7 +50,6 @@ public class State {
if(this.board[y+deltaY][x+deltaX]!=0){
if(this.board[y+2*deltaY][x+2*deltaX] == 0)
moves.add(new Pair<Point, Point>(new Point(y, x), new Point(y+2*deltaY, x+2*deltaX)));
}
} catch(ArrayIndexOutOfBoundsException ignored) {}
}