test de getMove

This commit is contained in:
Antonin Boyon 2021-01-27 18:27:28 +01:00
parent 6363f7b750
commit 3d87d7234f
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,8 @@
package othello;
import java.awt.Point;
import java.util.ArrayList;
public class Main {
@ -11,6 +14,10 @@ public class Main {
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){

View File

@ -21,7 +21,7 @@ public class State {
return false;
}
public ArrayList<Point> getMove(String player) {
public ArrayList<Point> getMove(int player) {
ArrayList<Point> moves = null;
// Clonage
@ -30,12 +30,15 @@ public class State {
for (int j=0; j<this.board.length; j++) {
if (this.board[i][j] == this.currentPlayer) {
// Recherche autour du pion du joueur courant
System.out.println("recherche");
for (int k=-1; k<2;k++) {
for (int l=-1; l<2; l++) {
// La position du pion trouvé est exclue
if (k!=0 || l!=0) {
// 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));
}
}
@ -51,7 +54,7 @@ public class State {
return moves;
}
public int getScore(String player) {
public int getScore(int player) {
return 0;
}