# Checkmate

Home * Chess * Checkmate

Shannon Larratt - Fool's mate (2007) [1] [2] [3]

Checkmate (often shortened to mate) occurs if a king is under immediate attack by one (or two) opponent pieces (in check) and has no way to remove it from attack on the next move. Checkmate is the object of the game of chess, it ends with the mate giving player as the winner, and the mated player the loser.

# Mate Score

## At the Root

At the root the score of a mated player is the worst score one can get, that is a negative score with the greatest absolute value of the score range. It is quite common and sufficient to use something like this in C, C++:

#include <limits.h>
/* (-32768/2 = -16384) */
#define VALUE_MATED (SHRT_MIN/2)

Inside a 16-bit short integer range, assuming centipawn evaluation, it translates to roughly being 16 queens down. Note that using SHRT_MIN instead of SHRT_MIN/2 as mate value has issues in greater/less comparisons of additive expressions, where summands around SHRT_MIN or SHRT_MAX may under- or overflow, which has somehow relaxed with the advent of the usual 32-bit sign-extension.

## Down the Tree

Inside a negamax based search, most [4] programs assign VALUE_MATED + ply distance to the root as worst case score if entering a node, which if propagated as mate score along the Principal Variation to the root, translates in mate in odd plies (positive values), or getting mated in even plies. However, those scores need ply-adjustment if stored as exact score inside the transposition table, and re-adjustment if retrieving from TT. An alternative approach, not only related to mate scores was proposed by Harm Geert Muller, The Delay Penalty as implemented in Micro-Max [5] [6] [7] [8].

# Detecting Mate

Some programs rely on pseudo-legal move generation, and find Checkmate if all those moves are in fact illegal after making and finding the "refutation" of capturing the king. At the latest, if no legal move was found, programs need the information whether the king is in check to decide about checkmate or stalemate score. Despite, most programs (should be) are aware of check in advance, and use special move generator(s) if in check or even in double check:

1. Double check
1. Only King moves or captures
2. Single check
1. Capture the checking piece
2. King moves or captures
3. In case of distant checks, interposing a piece between the threatening sliding piece and the king

# Forum Posts

## 1997 ...

Re: Using too-shallow mate scores from the hash table by David Eppstein, CCC, July 06, 1998
Re: Using too-shallow mate scores from the hash table by Don Dailey, CCC, July 07, 1998
Is "Interesting mate test..." the longest ever thread.... by Tina Long, CCC, September 11, 1999