;;;; Programer: Kevin Rosenberg based on code by Peter Norvig
;;;; Date Started: 1 Nov 2001
;;;;
-;;;; $Id: base.lisp,v 1.6 2003/06/12 13:28:55 kevin Exp $
+;;;; $Id: base.lisp,v 1.7 2003/06/17 05:47:18 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2001-2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1998-2002 Peter Norvig
(defun count-difference (player board)
"Count player's pieces minus opponent's pieces."
(declare (type board board)
- (fixnum player)
+ (type fixnum player)
(optimize (speed 3) (safety 0) (space 0)))
(the fixnum (- (the fixnum (count player board))
- (the fixum (count (opponent player) board)))))
+ (the fixnum (count (opponent player) board)))))
(defun valid-p (move)
(declare (type move move)
+cl-reversi (1.0.8-1) unstable; urgency=low
+
+ * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org> Mon, 16 Jun 2003 23:46:53 -0600
+
cl-reversi (1.0.7-1) unstable; urgency=low
* New upstream
;;;; Programer: Kevin Rosenberg
;;;; Date Started: 1 Nov 2001
;;;;
-;;;; $Id: edge-table-storage.lisp,v 1.4 2003/06/12 12:42:13 kevin Exp $
+;;;; $Id: edge-table-storage.lisp,v 1.5 2003/06/17 05:47:18 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2001-2003 by Kevin M. Rosenberg
;;;;
:name "edge-table"
:type "dat"))))
- (defun store-edge-table (et &optional (path *et-path*))
+ (defun store-edge-table (et &optional (path *et-path*))
+ (declare (type edge-table et))
(with-open-file (stream path :direction :output
:if-exists :supersede)
(print (length et) stream)
(with-open-file (stream path :direction :input)
(let* ((length (read stream))
(et (make-array length :element-type 'fixnum)))
- (dotimes (i length)
- (declare (fixnum i))
- (setf (aref et i) (read stream)))
- et))))
+ (declare (type (simple-array fixnum (*)) et))
+ (dotimes (i length)
+ (declare (fixnum i))
+ (setf (aref et i) (read stream)))
+ et))))
(unless (probe-file *et-path*)
(format *trace-output* ";; Recompiling edge-table, this make take several minutes")
;;;; 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)))
;;;; Programer: Kevin Rosenberg based on code by Peter Norvig
;;;; Date Started: 1 Nov 2001
;;;;
-;;;; $Id: io.lisp,v 1.5 2003/06/12 13:28:55 kevin Exp $
+;;;; $Id: io.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
(cross-product #'concat-symbol
'(? A B C D E F G H ?)
'(? 1 2 3 4 5 6 7 8 ?))))
- (declaim (type list square-names))
+ (declare (type list square-names))
(defun h8->88 (str)
"Convert from alphanumeric to numeric square notation."