Merge branch 'master' of
https://gitarero.ecam.fr/keshini.nistar/OOP_Groupe_1A3_Project.git
This commit is contained in:
commit
0449c8220a
|
|
@ -1,5 +1,7 @@
|
||||||
package backend;
|
package backend;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class AutoPlayer {
|
public class AutoPlayer {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,9 +11,13 @@ public class AutoPlayer {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Move computeBestMove(Board board) {
|
public Move computeBestMove(Board board) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -376,18 +376,6 @@ return false; }
|
||||||
this.highlightedSquares.clear();
|
this.highlightedSquares.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void updateTurnLabel() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void repaint() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public Board(Board board) {
|
/*public Board(Board board) {
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
|
@ -401,4 +389,6 @@ return false; }
|
||||||
public Piece[][] getBoardArray() {
|
public Piece[][] getBoardArray() {
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ public class Game extends Thread {
|
||||||
|
|
||||||
private void aiPlayerTurn() {
|
private void aiPlayerTurn() {
|
||||||
if(isAITurn()) {
|
if(isAITurn()) {
|
||||||
board.playMove(aiPlayer.computeBestMove(new Board(board)));
|
board.playMove(aiPlayer.computeBestMove(board));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,6 +114,13 @@ public class Game extends Thread {
|
||||||
public Board getBoard() {
|
public Board getBoard() {
|
||||||
return board; // assuming your Game keeps its Board in a field named “board”
|
return board; // assuming your Game keeps its Board in a field named “board”
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,24 +226,26 @@ public class MovePiece {
|
||||||
|
|
||||||
//Pawn movement logic simulation
|
//Pawn movement logic simulation
|
||||||
|
|
||||||
public boolean movePawnSimulate(int x, int y) {
|
public boolean movePawnSimulate(int x, int y) {
|
||||||
int currentX = piece.getX();
|
int currentX = piece.getX();
|
||||||
int currentY = piece.getY();
|
int currentY = piece.getY();
|
||||||
boolean isWhite = piece.isWhite();
|
boolean isWhite = piece.isWhite();
|
||||||
int direction = isWhite ? -1 : 1;
|
int direction = isWhite ? -1 : 1;
|
||||||
boolean firstMove = isWhite ? currentY == 6 : currentY == 1;
|
boolean firstMove = isWhite ? currentY == 6 : currentY == 1;
|
||||||
|
|
||||||
|
// Same logic as movePawn but no actual move
|
||||||
|
if (x == currentX && y == currentY + direction && board.getPiece(x, y) == null) {
|
||||||
|
return true;
|
||||||
|
}else if (x == currentX && y == currentY + (2 * direction) && firstMove &&
|
||||||
|
board.getPiece(x, y) == null && board.getPiece(x, currentY + direction) == null) {
|
||||||
|
return true;
|
||||||
|
}else if (Math.abs(x - currentX) == 1 && y == currentY + direction &&
|
||||||
|
board.getPiece(x, y) != null && board.getPiece(x, y).isWhite() != isWhite) {
|
||||||
|
return true;
|
||||||
|
}return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Same logic as movePawn but no actual move
|
|
||||||
if (x == currentX && y == currentY + direction && board.getPiece(x, y) == null) {
|
|
||||||
return true;
|
|
||||||
}else if (x == currentX && y == currentY + (2 * direction) && firstMove &&
|
|
||||||
board.getPiece(x, y) == null && board.getPiece(x, currentY + direction) == null) {
|
|
||||||
return true;
|
|
||||||
}else if (Math.abs(x - currentX) == 1 && y == currentY + direction &&
|
|
||||||
board.getPiece(x, y) != null && board.getPiece(x, y).isWhite() != isWhite) {
|
|
||||||
return true;
|
|
||||||
}return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//bishop movement simulate
|
//bishop movement simulate
|
||||||
public boolean moveBishopSimulate(int x, int y) {
|
public boolean moveBishopSimulate(int x, int y) {
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,9 @@ public class Piece {
|
||||||
didMove=value;
|
didMove=value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public void setPosition(int x, int y) {
|
||||||
|
this.x_coor = x;
|
||||||
|
this.y_coor = y;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue