;;;; Programer: Kevin M. Rosenberg based on code by Peter Norvig
;;;; Date Started: 1 Nov 2001
;;;;
-;;;; $Id: edge-table.lisp,v 1.5 2003/06/12 13:28:55 kevin Exp $
+;;;; $Id: edge-table.lisp,v 1.6 2003/06/17 05:47:18 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2001-2003 by Kevin M. Rosenberg
;;;; and Copyright (c) 1998-2002 Peter Norvig
(init-edge-table)
*edge-table*)
+(deftype edge-table () '(simple-array fixnum (*)))
+
(defun map-edge-n-pieces (fn player board n squares index)
"Call fn on all edges with n pieces."
;; Index counts 1 for player; 2 for opponent
- (declare (fixnum index)
+ (declare (fixnum n index)
(type player player)
(type square index)
(type (simple-array fixnum (100)) board)
(sq (first squares)))
(declare (fixnum index3 sq))
(map-edge-n-pieces fn player board n (rest squares) index3)
- (when (and (> n 0) (eql (bref board sq) empty))
+ (when (and (plusp n) (= (bref board sq) empty))
(setf (bref board sq) player)
(map-edge-n-pieces fn player board (- n 1) (rest squares)
(+ 1 index3))
(defun combine-edge-moves (possibilities player)
"Combine the best moves."
- (declare (optimize (speed 3) (safety 0) (space 0)))
+ (declare (type player player)
+ (optimize (speed 3) (safety 0) (space 0)))
(let ((prob 1.0)
(val 0.0)
(fn (if (= player black) #'> #'<)))
for i from 0
sum (the fixnum
(cond
- ((= (bref board sq) empty) 0)
+ ((= (bref board sq) empty) 0d0)
((= (bref board sq) player)
(aref *static-edge-table* i
(piece-stability board sq)))