Remove debug echo statements. Rooks are now considered moved even when captured (castling)
This commit is contained in:
parent
31f77fa22d
commit
82a203c98b
|
@ -1094,6 +1094,29 @@ proc doMove(self: ChessBoard, move: Move) =
|
|||
castlingAvailable.black.king = false
|
||||
else:
|
||||
discard
|
||||
# Has a rook been captured?
|
||||
let capture = self.getCapture(move)
|
||||
if capture != emptyLocation():
|
||||
let piece = self.grid[capture.row, capture.col]
|
||||
if piece.kind == Rook:
|
||||
case piece.color:
|
||||
of White:
|
||||
if capture == piece.color.queenSideRook():
|
||||
# Queen side
|
||||
castlingAvailable.white.queen = false
|
||||
elif capture == piece.color.kingSideRook():
|
||||
# King side
|
||||
castlingAvailable.white.king = false
|
||||
of Black:
|
||||
if capture == piece.color.queenSideRook():
|
||||
# Queen side
|
||||
castlingAvailable.black.queen = false
|
||||
elif capture == piece.color.kingSideRook():
|
||||
# King side
|
||||
castlingAvailable.black.king = false
|
||||
else:
|
||||
# Unreachable
|
||||
discard
|
||||
# Has the king moved?
|
||||
if move.piece.kind == King:
|
||||
case move.piece.color:
|
||||
|
@ -1234,17 +1257,10 @@ proc isLegal(self: ChessBoard, move: Move): bool =
|
|||
if destination.kind != Empty and destination.color == self.getActiveColor():
|
||||
return false
|
||||
|
||||
echo "A"
|
||||
echo move.piece.color.longCastleKing()
|
||||
echo move.startSquare
|
||||
echo move.targetSquare
|
||||
echo "B"
|
||||
if move.piece.kind == King and move.piece.color.longCastleKing() + move.startSquare == move.targetSquare:
|
||||
move.flag = CastleLong
|
||||
elif move.piece.kind == King and move.piece.color.shortCastleKing() + move.startSquare == move.targetSquare:
|
||||
move.flag = CastleShort
|
||||
echo move
|
||||
echo self.generateMoves(move.startSquare)
|
||||
if move notin self.generateMoves(move.startSquare):
|
||||
# Piece cannot arrive to destination (blocked
|
||||
# or otherwise invalid move)
|
||||
|
|
Loading…
Reference in New Issue