Check

toc =Kind of Checks=
 * Home * Chess * Check**
 * [[image:Lighthouse.JPG link="http://www.chgs.umn.edu/museum/responses/bak/chess.html"]] ||~  || Inside a game of chess, a **check** occurs if a king is under immediate attack by one (or two) opponent pieces. If the king has no way to remove it from attack on the next move, the check is even checkmate. Since check is crucial concerning the outcome of game and the horizon effect, check extensions might be applied to evade the check. ||
 * Samuel Bak - Lighthouse ||~   ||^   ||

Single Check
The king is attacked by one opponent piece, either by the piece which just moved directly attacking the king, or alternatively a discovered check where a distant sliding piece attacks the king by opening the ray in opponent king direction with another piece.

Double Check
A double check occurs if the moving piece directly attacks the king but also discovers a distant sliding attacker.  =In Check Detection= Whether the side to move is in check is essential to know inside the search for various reasons. It might be checkmate, and most pseudo-legal moves generated may be illegal, leaving the king attacked. Null move would yield in an illegal position as well, at or below the horizon we don't want to stand pat if material balance or static evaluation is far greater than beta.

By last Move
The cheapest and most straightforward way to detect checks is to consider the previous move just made by the opponent. It might be a direct check or discovered check, so one has to test whether piece on target square attacks the king, or whether piece on origin square is attacked by an own sliding piece on an otherwise open ray in opponent king direction. If the last move was an en passant capture, one has to consider a few more complicated cases of possible discovered checks, since the captured pawn is not on the target square, and two pawns disappear from the 4th (5th) rank.

Attack Tables
Based on the design and data structure of a chess program, an incremental updated attack and defend map may immedeatly answer whether the king is under attack of one or even two opponent pieces.

On the Fly
With bitboards one may determine a square attacked as mentioned in checks and pinned pieces.  =Getting out of check= While in check, it is recommended to perform a specialized Move Generation for check evasion of either a reasonable subset of all pseudo-legal moves or even a strict legal move generation: 

Double Check

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

Single Check
 =Perpetual Check= A perpetual check occurs if one player forces an "endless" series of checks with repeated reversible moves, finally resulting in a draw by threefold repetitions.
 * 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=
 * Check Extensions
 * Checkmate
 * Checks and Pinned Pieces (Bitboards)
 * Checks in Quiescence Search
 * Desperado
 * DirGolem
 * Horizon Effect
 * Stalemate

=Publications=
 * Richard L. Smith, Fernand Gobet, Peter Lane (**2009**). //[|Checking chess checks with chunks: A model of simple check detection]//. [|ICCM 2009] » CHREST, Chunking

=Forum Posts=

1997 ...

 * [|quiescence search] by Andrew Tridgell, rgcc, April 16, 1997 » Quiescence Search, Crafty

2000 ...

 * [|Checks in the Qsearch] by Scott Gasch, CCC, June 28, 2002 » Quiescence Search
 * [|Idea for check function] by Zach Wegner, CCC, November 14, 2002
 * [|Fast check detection in bitboard engine] by Jean-Francois Romang, CCC, December 10, 2003
 * [|Rebel's long checks concept in QS] by milix, CCC, January 23, 2004 » Rebel, Quiescence Search
 * [|Qsearch Checks] by Tor Lattimore, CCC, August 29, 2004 » Quiescence Search
 * [|Checks in QSearch] by Dan Honeycutt, Winboard Programming Forum, November 23, 2004 » Checks in Quiescence Search

2005 ...

 * [|in check test] by Anonymous, Winboard Forum, July 07, 2005
 * [|How to Best Limit Checks in the Quiescence ?] by Stuart Cracraft, CCC, August 20, 2007 » Checks in Quiescence Search
 * [|discovered check definition] by Uri Blass, CCC, September 12, 2007 » Discovered Check
 * [|checks in q-search] by Robert Hyatt, CCC, September 02, 2008

2010 ...

 * [|Standpat and check] by Vlad Stamate, CCC, February 06, 2010 » Standing Pat
 * [|Detecting Checks] by beneficii, Winboard Programming Forum, November 27, 2010
 * [|out of check move ordering] by Don Dailey, CCC, March 12, 2011 » Move Ordering
 * [|checks in quies] by Larry Kaufman, CCC, March 22, 2012 » Quiescence Search
 * [|What is (in your opinion) the best check validation method?] by goodgame0111, OpenChess Forum, February 24, 2014
 * [|Spite checks] by Harm Geert Muller, CCC, May 13, 2014

2015 ...

 * [|Check-extension in QS] by Harm Geert Muller, CCC, April 03, 2015 » Checks in Quiescence Search
 * [|Ostrich tactics and pointless checks] by Colin Jenkins, CCC, May 29, 2015 » Horizon Effect
 * [|Checks in qsearch - must-have or optional?] by Martin Fierz, CCC, March 15, 2016 » Checks in Quiescence Search
 * [|perpetual check position] by Erin Dame, CCC, August 16, 2016
 * [|Spite checks, again] by Harm Geert Muller, CCC, October 23, 2016

=External Links=
 * [|Check (chess) from Wikipedia]
 * [|Double check from Wikipedia]
 * [|Perpetual check from Wikipedia], see Repetitions
 * [|Cross-check from Wikipedia]
 * [|Check (disambiguation) from Wikipedia]
 * [|Check: A unit testing framework for C] » C
 * [|Checkbox from Wikipedia] » GUI

=References= =What links here?= include page="Check" component="backlinks" limit="120"
 * Up one Level**