test de getMove
This commit is contained in:
parent
6363f7b750
commit
3d87d7234f
@ -1,5 +1,8 @@
|
|||||||
package othello;
|
package othello;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
|
||||||
@ -11,6 +14,10 @@ public class Main {
|
|||||||
int player = game.getCurrentPlayer();
|
int player = game.getCurrentPlayer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ArrayList<Point> a = new ArrayList<Point>();
|
||||||
|
a.add(new Point(3,3));
|
||||||
|
System.out.println(game.getMove(p1).toString());
|
||||||
|
System.out.println(a.get(0).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[][] initialize(int p1, int p2){
|
public static int[][] initialize(int p1, int p2){
|
||||||
|
@ -21,7 +21,7 @@ public class State {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Point> getMove(String player) {
|
public ArrayList<Point> getMove(int player) {
|
||||||
ArrayList<Point> moves = null;
|
ArrayList<Point> moves = null;
|
||||||
|
|
||||||
// Clonage
|
// Clonage
|
||||||
@ -30,12 +30,15 @@ public class State {
|
|||||||
for (int j=0; j<this.board.length; j++) {
|
for (int j=0; j<this.board.length; j++) {
|
||||||
if (this.board[i][j] == this.currentPlayer) {
|
if (this.board[i][j] == this.currentPlayer) {
|
||||||
// Recherche autour du pion du joueur courant
|
// Recherche autour du pion du joueur courant
|
||||||
|
System.out.println("recherche");
|
||||||
for (int k=-1; k<2;k++) {
|
for (int k=-1; k<2;k++) {
|
||||||
for (int l=-1; l<2; l++) {
|
for (int l=-1; l<2; l++) {
|
||||||
// La position du pion trouvé est exclue
|
// La position du pion trouvé est exclue
|
||||||
if (k!=0 || l!=0) {
|
if (k!=0 || l!=0) {
|
||||||
// Si une place libre est trouvée elle est ajouté à la liste de coups
|
// Si une place libre est trouvée elle est ajouté à la liste de coups
|
||||||
if (this.board[i+k][j+l]==0) {
|
System.out.println("close");
|
||||||
|
if ( (this.board[i+k][j+l]==0) && (i+k >= 0) && (i+k < 7 ) && (j+l >= 0) && (j+l < 7 ) ) {
|
||||||
|
System.out.println("jadd");
|
||||||
moves.add(new Point(i+k, j+l));
|
moves.add(new Point(i+k, j+l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +54,7 @@ public class State {
|
|||||||
return moves;
|
return moves;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScore(String player) {
|
public int getScore(int player) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user