Computer Chess Club Archives


Search

Terms

Messages

Subject: Symbolic: The KBNK recognizer

Author: Steven Edwards

Date: 09:30:47 02/23/04


Heres some example code from Symbolic, the KBNK endgame class recognizer:

(defun IsKBNK? (MyPos)
    "Return White if KBNK, Black if KBNK reversed, nil otherwise"
    (cond
        ((and
            (= (CountByColorPos White MyPos) 3)
            (= (CountByColorPos Black MyPos) 1)
            (= (CountByManPos WhiteBishop MyPos) 1)
            (= (CountByManPos WhiteKnight MyPos) 1)) White)
        ((and
            (= (CountByColorPos Black MyPos) 3)
            (= (CountByColorPos White MyPos) 1)
            (= (CountByManPos BlackBishop MyPos) 1)
            (= (CountByManPos BlackKnight MyPos) 1)) Black)
        (t nil)))

Comments:

1. Does anyone really think that Lisp is hard to read?

2. While the above could have been done in the C++ code of the underlying
tookit, it wouldn't have been that much faster.

3. The above code, like all of ChessLisp, is typesafe.  This means that a
function that expects a color checks for a color value, one that expects a
position symbol checks for a position symbol, etc.

4. Further work on KBNK will help with the design and implementation of the
pattern recognition and planning facilities.



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.