differencing jump and clone
This commit is contained in:
parent
af4d9d8504
commit
e675b8ae59
@ -38,15 +38,20 @@ public class State {
|
|||||||
for (int x = 0; x < this.board[y].length; x++) {
|
for (int x = 0; x < this.board[y].length; x++) {
|
||||||
if (this.board[y][x] == player) {
|
if (this.board[y][x] == player) {
|
||||||
// Recherche autour du pion du joueur courant
|
// Recherche autour du pion du joueur courant
|
||||||
for (int deltaY = -2; deltaY < 3; deltaY++) {
|
for (int deltaY = -1; deltaY < 2; deltaY++) {
|
||||||
for (int deltaX = -2; deltaX < 3; deltaX++) {
|
for (int deltaX = -1; deltaX < 2; deltaX++) {
|
||||||
// La position du pion trouv<EFBFBD> est exclue
|
// La position du pion trouv<EFBFBD> est exclue
|
||||||
if (deltaY != 0 && deltaX != 0) {
|
if (deltaY != 0 && deltaX != 0) {
|
||||||
// Si une place libre est trouv<EFBFBD>e elle est ajout<EFBFBD>e à la liste des coups
|
// Si une place libre est trouv<EFBFBD>e elle est ajout<EFBFBD>e à la liste des coups
|
||||||
try {
|
try {
|
||||||
if ((this.board[y+deltaY][x+deltaX]==0)) {
|
if (this.board[y+deltaY][x+deltaX]==0) {
|
||||||
moves.add(new Pair<Point, Point>(new Point(y, x), new Point(y+deltaY, x+deltaX)));
|
moves.add(new Pair<Point, Point>(new Point(y, x), new Point(y+deltaY, x+deltaX)));
|
||||||
}
|
}
|
||||||
|
if(deltaX == 0 ^ deltaY == 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) {}
|
} catch(ArrayIndexOutOfBoundsException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user