From 38a2a0cccff284a5a2f1abfb581d31de730c7d39 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 5 May 2008 08:39:04 -0700 Subject: [PATCH] most basic working client functionality --- gobot.lisp | 4 ++++ gtp.lisp | 23 ++++++++++++++++++----- packages.lisp | 7 +++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gobot.lisp b/gobot.lisp index b7eb3bb..54c3579 100644 --- a/gobot.lisp +++ b/gobot.lisp @@ -1,5 +1,9 @@ (in-package :go-bot) +(defparameter *name* "gobot") +(defparameter *version* "0.01") +(defparameter *author* "Dan Ballard") + (defun make-board (size) (make-array size :initial-element (make-array size :initial-element nil))) diff --git a/gtp.lisp b/gtp.lisp index ca87005..4686b5c 100644 --- a/gtp.lisp +++ b/gtp.lisp @@ -1,8 +1,11 @@ (in-package :gtp-handler) +(defparameter *quit?* nil) + (defun gtp-client () - (do ((quit? nil)) - ((eql quit? t)) + (setf *quit?* nil) + (do () + ((eql *quit?* t)) (format t "= ~a~%~%" (dispatch-gtp-command (read-line t))))) (defun split-string (string pivot-str) @@ -17,11 +20,21 @@ (defun dispatch-gtp-command (command-string) - (let* ((commands (split-string (string-downcase command-string) " ")) + (let* ((commands (cl-ppcre:split "\\s+" (string-upcase command-string))) (command (intern (first commands)))) (progn (format t "'~a'~%" command) (case command - (name "GoBot") - (version "0.1") + (name go-bot:*name*) + (version go-bot:*version*) + ;(boardsize (progn + ; (go-bot:set-boardsize (parse-integer (second commands))) + ; (go-bot:init-board))) + ;(komi (go-bot:set-komi (parse-integer (second commands)))) + ;(clearboard (go-bot:init) + ;(play (go-bot:play (second commands) (third commands))) + ;(genmove (go-bot:genmove (char (second commands) 0))) + ;(known_command) + ;(list_commands + (quit (progn (setf *quit?* t)) "") (otherwise (concatenate 'string "Unkown command '" (first commands) "'")))))) \ No newline at end of file diff --git a/packages.lisp b/packages.lisp index dd16624..dfca0be 100644 --- a/packages.lisp +++ b/packages.lisp @@ -4,7 +4,10 @@ (defpackage gtp-handler (:use :common-lisp) - (:export gtp-client)) + (:export :gtp-client)) (defpackage go-bot - (:use :common-lisp)) \ No newline at end of file + (:use :common-lisp) + (:export :*name* + :*version* + :*author*)) \ No newline at end of file