cleanup stuff related to move legality checks and attack checks
Closed this issue · 0 comments
Sopel97 commented
- in chess_pos_db_ we have to cleanup some stuff related to move/position legality checks.
-
in particular Board::isKingAttackedAfterMove, Board::isSquareAttackedAfterMove need better implementations
-
Board::isSquareAttacked shouldn't have the 'captured' and 'occupied' parameter
-
remove this assert https://github.com/Sopel97/chess_pos_db/blob/master/src/chess/Position.cpp#L26
-
overall all predicates that chess whether something is attacked now or after a move need to be rethought and reimplemented.
-
what we need (all of these happen to not require pos state info so they may be implemented in board only):
- pos/board.isSquareAttacked(Square, Color attacker)
- pos/board.isSquareAttackedAfterMove(Square, Move, Color attacker)
- pos/board.isPieceAttacked(Square) - similar to isSquareAttacked but attacker depends on the piece color. false if empty
- pos/board.isPieceAttackedAfterMove(Square pieceSq, Move) - false if empty
- pos/board.createsDiscoveredAttackOnOwnKing(Move) - attacker color opposite to color of the piece being moved
- pos/board.createsAttackOnOwnKing(Move) - calls board.isPieceAttackedAfterMove(ksq, Move)
- pos/board.attackers(Square)
- pos/board.attacks(Square) - empty bitboard if square empty
-
additionally we may want
- pos.isMoveLegal(Move) - this would take ANY move, not just a pseudoLegalMove
- pos.isPseudoLegalMoveLegal(Move) - like it is in movegen now
- pos.isMovePseudoLegal(Move) - takes ANY move
-