From 9fb8305e6005c35f639a46d00c626805054e3d4a Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Fri, 25 Oct 2002 13:14:00 +0000 Subject: [PATCH] r3190: *** empty log message *** --- .cvsignore | 1 - README | 16 ++++++++++++++++ base.lisp | 25 +------------------------ debian/upload.sh | 2 +- io-clim.lisp | 7 ++----- package.lisp | 19 +++++++++++-------- strategies.lisp | 5 ++++- 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/.cvsignore b/.cvsignore index e5f6120..ca8d09f 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,2 +1 @@ .bin -edge-table.dat diff --git a/README b/README index cb07af2..d462524 100644 --- a/README +++ b/README @@ -3,3 +3,19 @@ This is a Common Lisp implementation of the Reversi game. The web site for this package is http://reversi.b9.com which has documentation for this package. +Reversi is based on the Othello(tm) game presented in Peter Norvig's +book "Paradigms of Artificial Intelligence Programming", chapter 18. +I highly suggest this book in general. If you wish to take full +advantage of this package, you should read the chapter referenced. + +Quickstart +========== + +If you are using AllegroCL or Lispworks with CLIM, you can play +Reversi with a graphical user interface using the command + (reversi:clim-reversi) + +Otherwise, you can play in a text mode, such as + (reversi:reversi #'reversi:human (reversi:iago 1)) + + diff --git a/base.lisp b/base.lisp index 587a843..10edbde 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.1 2002/10/25 12:42:42 kevin Exp $ +;;;; $Id: base.lisp,v 1.2 2002/10/25 13:09:11 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2001-2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1998-2002 Peter Norvig @@ -387,34 +387,11 @@ (count-difference black (board game))) - (defun reversi (bl-strategy wh-strategy &optional (print t) (minutes +default-max-minutes+)) (play-game (make-game bl-strategy wh-strategy :print print :record-game nil :minutes minutes))) - -#+ignore -(defun reversi (bl-strategy wh-strategy - &optional (print t) (minutes 30)) - "Play a game of reversi. Return the score, where a positive - difference means black, the first player, wins." - (let ((board (initial-board)) - (clock (make-clock minutes))) - (declare (type board board)) - (catch 'game-over - (loop for *move-number* from 1 - for player = black then (next-to-play board player print) - for strategy = (if (eql player black) - bl-strategy - wh-strategy) - until (null player) - do (get-move nil strategy player board print clock)) - (when print - (format t "~&The game is over. Final result:") - (print-board board clock)) - (count-difference black board)))) - (defvar *clock* (make-clock +default-max-minutes+) "A copy of the game clock") (defvar *board* (initial-board) "A copy of the game board") diff --git a/debian/upload.sh b/debian/upload.sh index c98cd66..632d4af 100755 --- a/debian/upload.sh +++ b/debian/upload.sh @@ -1,4 +1,4 @@ #!/bin/bash -e -dup reversi -Uftp.med-info.com -D/home/ftp/reversi -C"(cd /opt/apache/htdocs/reversi.med-info.com; make install)" -su $* +dup reversi -Uftp.med-info.com -D/home/ftp/reversi -C"(cd /opt/apache/htdocs/reversi; make install)" -su $* diff --git a/io-clim.lisp b/io-clim.lisp index 9dcfb13..78775de 100644 --- a/io-clim.lisp +++ b/io-clim.lisp @@ -8,7 +8,7 @@ ;;;; Programer: Kevin M. Rosenberg ;;;; Date Started: 1 Nov 2001 ;;;; -;;;; $Id: io-clim.lisp,v 1.2 2002/10/25 09:23:39 kevin Exp $ +;;;; $Id: io-clim.lisp,v 1.3 2002/10/25 13:09:11 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2001-2002 by Kevin M. Rosenberg ;;;; @@ -427,10 +427,7 @@ #-(and os-threads microsoft-32) nil)) -(defun g () - (greversi)) - -(defun greversi () +(defun clim-reversi () (unless (or *force* (null *reversi-frame*)) (setq *reversi-frame* (make-application-frame 'reversi))) (setq *reversi-frame* (run-frame 'reversi *reversi-frame*))) diff --git a/package.lisp b/package.lisp index c50d3ef..9597916 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programer: Kevin M. Rosenberg ;;;; Date Started: 1 Nov 2001 ;;;; -;;;; $Id: package.lisp,v 1.2 2002/10/25 09:23:39 kevin Exp $ +;;;; $Id: package.lisp,v 1.3 2002/10/25 13:09:11 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2001-2002 by Kevin M. Rosenberg ;;;; @@ -17,19 +17,20 @@ ;;;;*************************************************************************** -(in-package :cl-user) +(in-package #:cl-user) -(defpackage :reversi - (:use :common-lisp :common-lisp-user - #+clisp :ext - #+clim :clim - #+clim :clim-sys) +(defpackage #:reversi + (:use #:common-lisp #:common-lisp-user + #+clisp #:ext + #+clim #:clim + #+clim #:clim-sys) #+clim (:shadowing-import-from :clim :pathname) #+clim (:shadowing-import-from :clim :interactive-stream-p) #+clim (:shadowing-import-from :clim :boolean) + (:export #:reversi #:random-reversi-series @@ -43,6 +44,8 @@ #:count-difference #:weighted-squares #:modified-weighted-squares - #+clim #:greversi + + #:text-reversi + #+clim #:gui-reversi )) diff --git a/strategies.lisp b/strategies.lisp index b18a7c3..5529d01 100644 --- a/strategies.lisp +++ b/strategies.lisp @@ -8,7 +8,7 @@ ;;;; Programer: Kevin Rosenberg based on code by Peter Norvig ;;;; Date Started: 1 Nov 2001 ;;;; -;;;; $Id: strategies.lisp,v 1.3 2002/10/25 12:39:15 kevin Exp $ +;;;; $Id: strategies.lisp,v 1.4 2002/10/25 13:09:11 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2001-2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1998-2002 Peter Norvig @@ -533,6 +533,9 @@ '(random ab3-df ab3-wt ab3-md-wt iago))) +(defun text-reversi () + "Sets up a text game between player and computer" + ) -- 2.34.1