méthode getMoves
This commit is contained in:
parent
02821f1886
commit
93d83adad7
@ -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){
|
||||
|
@ -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+")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user