X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=base.lisp;h=2987b1d212de35bd6b1e52db95adfa1c3a037b4a;hb=4c844bde197de54c0343f7ab500153278f859ec6;hp=bbcd87209a1b349a8d46e9712d395c3f090b8156;hpb=20c849f483c381f84eae22eee807280c8d00e554;p=reversi.git diff --git a/base.lisp b/base.lisp index bbcd872..2987b1d 100644 --- a/base.lisp +++ b/base.lisp @@ -8,7 +8,7 @@ ;;;; Programer: Kevin Rosenberg based on code by Peter Norvig ;;;; Date Started: 1 Nov 2001 ;;;; -;;;; $Id: base.lisp,v 1.4 2003/06/12 12:42:13 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file is Copyright (c) 2001-2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1998-2002 Peter Norvig @@ -77,7 +77,7 @@ (record-game? :type boolean :initarg :record-game? :documentation "Whether to record moves and clcck of this game" :reader record-game?) - (final-result :type fixnum :initarg :final-result + (final-result :type (or null fixnum) :initarg :final-result :documentation "Final count, is NIL while game in play" :accessor final-result) (max-minutes :type fixnum :initarg :max-minutes @@ -100,8 +100,10 @@ :clock (make-clock +default-max-minutes+))) -(defun name-of (piece) (char ".@O?" piece)) -(defun title-of (piece) (nth (1- piece) '("Black" "White")) ) +(defun name-of (piece) (schar ".@O?" piece)) +(defun title-of (piece) + (declare (fixnum piece)) + (nth (the fixnum (1- piece)) '("Black" "White")) ) (defmacro opponent (player) `(if (= ,player black) white black)) @@ -110,7 +112,9 @@ `(the piece (aref (the board ,board) (the square ,square)))) (defparameter all-squares - (loop for i fixum from 11 to 88 when (<= 1 (mod i 10) 8) collect i) + (loop for i fixnum from 11 to 88 + when (<= 1 (the fixnum (mod i 10)) 8) + collect i) "A list of all squares") (defun initial-board () @@ -152,10 +156,10 @@ (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) @@ -181,8 +185,7 @@ (declare (type board board) (type move move) (type player player) - (optimize speed (safety 0)) -) + (optimize speed (safety 0) (space 0))) (if (= (bref board move) empty) (block search (let ((i 0)) @@ -277,7 +280,7 @@ (let ((c (+ move dir))) (declare (type square c)) (and (= (the piece (bref board c)) (the player (opponent player))) - (find-bracketing-piece (+ c dir) player board dir)))) + (find-bracketing-piece (the fixnum (+ c dir)) player board dir)))) (defun find-bracketing-piece (square player board dir) "Return the square number of the bracketing piece."