Skip to content

Commit

Permalink
add small check to canKingMoveToAdjacentSquares() : The king can capt…
Browse files Browse the repository at this point in the history
…ure the piece if it's on the adjacent square so i ignore this piece in this square
  • Loading branch information
OsamaX01 committed Aug 26, 2022
1 parent 2f1b688 commit 6e032a8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/simulators/GameStatesChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ private boolean canKingMoveToAdjacentSquares(StandardChessBoard board, Player ki

checkReachability:
for (Piece piece : board.getPiecesWithColor(opponentColor)) {
if (piece.getLocation().equals(square)) {
continue;
}

for (MoveStrategy moveStrategy : piece.getMovements()) {
if (moveStrategy.validateMove(board, piece.getLocation(), square)) {
canReachThisSquare = true;
Expand Down

0 comments on commit 6e032a8

Please sign in to comment.