Author: Steven Edwards
Date: 13:59:06 03/08/04
;;;; Main.lsp: Top level Lisp 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 Symbolic (MyOptSym) "Search from the chess data (properties of the given symbol); return global symbol" ;; Set the global OptSym (setf TheOptSym MyOptSym) ;; Set the initial values of the optsym working data properties (putprop TheOptSym 'BookWLD nil) (putprop TheOptSym 'RootMoveCount 0) (putprop TheOptSym 'RootMoves nil) (putprop TheOptSym 'RootNode nil) (putprop TheOptSym 'RootPos nil) (putprop TheOptSym 'StartUsage (usage)) (putprop TheOptSym 'Tree nil) ;; Set the initial values of the optsym result data properties (putprop TheOptSym 'Error nil) (putprop TheOptSym 'Narrative nil) (putprop TheOptSym 'SelectedMove nil) (putprop TheOptSym 'StatReport nil) (putprop TheOptSym 'TotalUsage 0.0) ;; Check input: FEN must be present (unless (getprop TheOptSym 'Error) (if (not (getprop TheOptSym 'FEN)) (putprop TheOptSym 'Error "The FEN property value must be present."))) ;; Check input: FEN must be a string (unless (getprop TheOptSym 'Error) (if (not (string? (getprop TheOptSym 'FEN))) (putprop TheOptSym 'Error "The FEN property value must be a string."))) ;; Check input: FEN must be a valid position (unless (getprop TheOptSym 'Error) (if (null? (PosValFromFEN (getprop TheOptSym 'FEN))) (putprop TheOptSym 'Error "The FEN property value must be a valid position."))) ;; Check input: History must be a list (unless (getprop TheOptSym 'Error) (if (not (list? (getprop TheOptSym 'History))) (putprop TheOptSym 'Error "The History property value must be a list."))) ;; Check input: History must contain all hash values (unless (getprop TheOptSym 'Error) (let ((NoFault t) (Hashes (getprop TheOptSym 'History))) (dowhile (and NoFault Hashes) (if (not (eq (ChessType (pop Hashes)) 'ChessHash)) (setf NoFault nil))) (if (not NoFault) (putprop TheOptSym 'Error "The History property value must be a list of hash values.")))) ;; Check input: NarrativeFN, if present, must be a string (unless (getprop TheOptSym 'Error) (if (and (getprop TheOptSym 'NarrativeFN) (not (string? (getprop TheOptSym 'NarrativeFN)))) (putprop TheOptSym 'Error "The NarrativeFN property value must be a string."))) ;; Check input: StatReportFN, if present, must be a string (unless (getprop TheOptSym 'Error) (if (and (getprop TheOptSym 'StatReportFN) (not (string? (getprop TheOptSym 'StatReportFN)))) (putprop TheOptSym 'Error "The StatReportFN property value must be a string."))) ;; Handle default narrative file name (unless (getprop TheOptSym 'Error) (if (and (getprop TheOptSym 'DoStory) (not (getprop TheOptSym 'NarrativeFN))) (putprop TheOptSym 'NarrativeFN "Narrative.txt"))) ;; Handle default statistics report file name (unless (getprop TheOptSym 'Error) (if (and (getprop TheOptSym 'DoStat) (not (getprop TheOptSym 'StatReportFN))) (putprop TheOptSym 'StatReportFN "Report.txt"))) ;; Start the narration (unless (getprop TheOptSym 'Error) (putprop TheOptSym 'DoNarrate (or (getprop TheOptSym 'DoShow) (getprop TheOptSym 'DoSpeak) (getprop TheOptSym 'DoStory))) (NarrateSelectionStart)) ;; Create the search tree (unless (getprop TheOptSym 'Error) (putprop TheOptSym 'Tree (TreeFromFENHistory (getprop TheOptSym 'FEN) (getprop TheOptSym 'History))) (NarrateTreeCreation)) ;; Create values for the remaining working storage properties (unless (getprop TheOptSym 'Error) (putprop TheOptSym 'RootNode (getprop (getprop TheOptSym 'Tree) 'RootNode)) (putprop TheOptSym 'RootPos (getprop (getprop TheOptSym 'RootNode) 'Position)) (putprop TheOptSym 'RootMoves (getprop (getprop TheOptSym 'RootNode) 'Moves)) (putprop TheOptSym 'RootMoveCount (length (getprop TheOptSym 'RootMoves)))) ;; Check for at least one move (unless (getprop TheOptSym 'Error) (if (zero? (getprop TheOptSym 'RootMoveCount)) (putprop TheOptSym 'Error "There are no moves available in the input position."))) ;; Select a move (unless (getprop TheOptSym 'Error) (SelectMove)) ;; Set the total usage (putprop TheOptSym 'TotalUsage (- (usage) (getprop TheOptSym 'StartUsage))) ;; Handle the statistics report (unless (getprop TheOptSym 'Error) (if (getprop TheOptSym 'DoStat) (DoStatReport))) ;; End the narration (unless (getprop TheOptSym 'Error) (NarrateSelectionEnd)) ;; Handle the narrative story file output (unless (getprop TheOptSym 'Error) (if (getprop TheOptSym 'DoStory) (WriteNarrative))) ;; Return the global optsym TheOptSym)
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.