Computer Chess Club Archives


Search

Terms

Messages

Subject: Symbolic: code example

Author: Steven Edwards

Date: 07:03:55 01/22/04


Here's some example code for the ChessLisp intepreter in my program Symbolic:

;;;; emp.lsp: Enumerate movepaths

(defun emp (theFEN theDepth)
 "Enumerate distinct movepaths from a FEN string to a depth"
 (cond
  ((not (string? theFEN))
    "Error: first argument must be a FEN string")
  ((not (and (integer? theDepth) (nonnegative? theDepth)))
    "Error: second argument must be a nonnegative integer")
  (t
   (let ((thePos (PosFromFEN theFEN)))
    (if (null? thePos)
     "Error: invalid position"
     (emp-aux thePos theDepth))))))

(defun emp-aux (thePos theDepth)
 "Enumerate distinct movepaths from a position to a depth"
 (cond
  ((= theDepth 0) 1)
  ((= theDepth 1) (length (Generate thePos)))
  (t
   (let ((theSum 0) (theEnv nil) (theMove nil) (theML (Generate thePos)))
    (dolist (theMove theML)
     (Execute theMove thePos theEnv)
     (incf theSum (emp-aux thePos (1- theDepth)))
     (Retract theMove thePos theEnv))
    theSum))))



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.