Computer Chess Club Archives


Search

Terms

Messages

Subject: Symbolic Lisp source: function Select [Select.lsp]

Author: Steven Edwards

Date: 14:00:47 03/08/04


;;;; Select.lsp: Move selection code for the Symbolic Chess Program
;;
;; Copyright (C) 2004 by S. J. Edwards / All rights reserved.
;;
;; Revised: 2004.03.08 by chessnotation@mac.com
;;
;; Distribution is prohibited except when explicitly permitted by the author.
;; There is no warranty, implied or otherwise.  Use at your own risk.


(defun SelectMove ()
    "Select a chess move from the established global variable"

    ;; Is only one move available?

    (when (null? (getprop TheOptSym 'SelectedMove))
        (when (one? (getprop TheOptSym 'RootMoveCount))
            (putprop TheOptSym 'SelectedMove
                (first (getprop TheOptSym 'RootMoves)))
            (AddToNarration "There is only one candidiate move available.")))

    ;; Is a checkmating move available?

    (when (null? (getprop TheOptSym 'SelectedMove))
        (putprop TheOptSym 'SelectedMove
            (RandomCheckmatingMove (getprop TheOptSym 'RootNode)))
        (if (getprop TheOptSym 'SelectedMove)
            (AddToNarration "A checkmating candidiate move is chosen.")))

    ;; Is a winning tablebase move available?

    (when (null? (getprop TheOptSym 'SelectedMove))
        (putprop TheOptSym 'SelectedMove
            (RandomBestWinningTablebaseMove (getprop TheOptSym 'RootNode)))
        (if (getprop TheOptSym 'SelectedMove)
            (AddToNarration "A winning tablebase candidiate move is chosen.")))

    ;; Do all candidate moves have certain values?

    (when (null? (getprop TheOptSym 'SelectedMove))
        (when (AreAllSubNodesCertain? (getprop TheOptSym 'RootNode))
            (putprop TheOptSym 'SelectedMove
                (RandomBestScoreMove (getprop TheOptSym 'RootNode)))
            (if (getprop TheOptSym 'SelectedMove)
                (AddToNarration "All candidiate moves are certain; the best is
chosen."))))

    ;; Is a decent book move available?

    (when (null? (getprop TheOptSym 'SelectedMove))
        (putprop TheOptSym 'SelectedMove
            (DecentBookMove (getprop TheOptSym 'RootNode)))
        (when (getprop TheOptSym 'SelectedMove)
            (AddToNarration "An opening book candidiate move is chosen.")
            (let*
                (
                    (BookWLD (getprop TheOptSym 'BookWLD))
                    (TotalCount (WLDTotalFromBookWLD BookWLD))
                    (BookExp (BookExpFromWLD BookWLD))
                    (WinCount (first BookWLD))
                    (LoseCount (second BookWLD))
                    (DrawCount (third BookWLD))
                )
                (AddToNarration (format nil "Total book games for %u: %c."
                    (getprop (getprop TheOptSym 'SelectedMove) 'SAN)
TotalCount))
                (AddToNarration (format nil "The move's winning percentage is:
%u."
                    (* BookExp 100.0)))
                (if (nonzero? WinCount)
                    (AddToNarration (format nil "Book win count: %c."
WinCount)))
                (if (nonzero? LoseCount)
                    (AddToNarration (format nil "Book lose count: %c."
LoseCount)))
                (if (nonzero? DrawCount)
                    (AddToNarration (format nil "Book draw count: %c."
DrawCount)))
            )))

    ;; Is a search needed?

    (when (null? (getprop TheOptSym 'SelectedMove))
        (Search)
        (AddToNarration "A search result candidiate move is chosen.")))



This page took 0 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.