Legal Move

Home * Chess * Moves * Legal Move

[[FILE:The_King_Can_Never_Be_Captured.jpg|border|right|thumb|link=https://fineartamerica.com/featured/the-king-can-never-be-captured-marina-kalinovsky.html
 * Marina Kalinovsky - The King can never be Captured ]]

A Legal Move is a pseudo-legal move which does not leave its own king in check. If not in check, most programs delay the legality test to the child node, after incremental updates attack and defend maps or an explicit square attacked test direct after make move. Earlier programs were even more "lazy", to determine illegal moves after an illegal king capture, while many programs consider absolutely pinned pieces in move generation and also for evaluation purpose, or even perform a strictly legal generation to demand searching legal positions. If in check, most programs apply a special move generator to omit the majority of illegal moves. =Legality Test= Beside the pseudo-legal condition which might already be sufficient for a subset of chess programs, there are several conditions to test, dependent whether the king is in check or not.

Not in Check

 * The moving piece is not absolutely pinned on its move direction
 * En passant requires special horizontal pin test of both involved pawns, which disappear from the same rank
 * While castling, rook is not pinned horizontally in Chess960

Double Check

 * Only king moves to non attacked squares, sliding check x-rays the king

Single Check

 * Capture of checking piece. The capturing piece is not absolutely pinned
 * King moves to non attacked squares, sliding check x-rays the king
 * Interposing moves in case of distant sliding check. The moving piece is not absolutely pinned.

=See also=
 * DirGolem
 * Hash Move
 * Killer Move
 * Mate Killers
 * Move Generation
 * Pseudo-Legal Move
 * Pseudo Legality Test with Bitboards

=Forum Posts=
 * Question about testing legality of moves by ambrooks1, Winboard Forum, February 07, 2014
 * En-passant legality test by tetra, OpenChess Forum, August 07, 2014 » En passant
 * TTMove legality checking ? & Killers Move Format? by Mahmoud Uthman, CCC, February 08, 2017 » Hash Move, Killer Move

=References=

Up one Level