Implementation Example

In general recognizer functions must distinguish between three different types of recognitions corresponding to the different modes of their results (bound, exact, or fail). For any KB[B]K recognizer that does not access endgame databases taken as an example, this implies to detect the three conditions below.

1.
KB[B]K is drawn if the Bishops cover squares of a single colour only. Then, the strong side is unable to mate the lone King and the KB[B]K recognizer can return an exact result with a draw score.

2.
The lone King might still draw if it attacks a bishop (possible conversion to drawn KBK) or if it stands on any edge of the board with the strong King near (possible stalemate). In both cases, the KB[B]K recognizer has to back off and return a recognition failure as its result.

3.
All other KB[B]K positions feature a winning KBB side and the recognizer can return bounded scores that indicate the great advantage.

Thanks to the KBBK scoring function from Section 1.4.4, we already know how to calculate the bounded scores for a winning KBB side. Now we simply put everything together in order to implement a working function for our KB[B]K example. Figure 1.6 presents an according skeleton for a KB[B]K recognizer function in ANSI-C. The skeleton outlines the decision procedure of the recognizer that evaluates the above three conditions and returns the appropriate results. As usual it assumes all not explicitly declared identifiers to be suitably defined and initialized.

  
Figure 1.6: Recognizer Function for KB[B]K Endgame Positions.
\begin{figure}
{\begin{center}\fbox{{{\parbox{359pt}{\smallskip\smallskip\small
...
...raggedright} \smallskip \smallskip}}}}\end{center}} \vspace*{-12pt}
\end{figure}



Created by Ernst A. Heinz, Thu Dec 16 23:28:11 EST 1999