most basic working client functionality

This commit is contained in:
Dan 2008-05-05 08:39:04 -07:00
parent 54ce7b3e58
commit 38a2a0cccf
3 changed files with 27 additions and 7 deletions

View File

@ -1,5 +1,9 @@
(in-package :go-bot) (in-package :go-bot)
(defparameter *name* "gobot")
(defparameter *version* "0.01")
(defparameter *author* "Dan Ballard")
(defun make-board (size) (defun make-board (size)
(make-array size :initial-element (make-array size :initial-element nil))) (make-array size :initial-element (make-array size :initial-element nil)))

View File

@ -1,8 +1,11 @@
(in-package :gtp-handler) (in-package :gtp-handler)
(defparameter *quit?* nil)
(defun gtp-client () (defun gtp-client ()
(do ((quit? nil)) (setf *quit?* nil)
((eql quit? t)) (do ()
((eql *quit?* t))
(format t "= ~a~%~%" (dispatch-gtp-command (read-line t))))) (format t "= ~a~%~%" (dispatch-gtp-command (read-line t)))))
(defun split-string (string pivot-str) (defun split-string (string pivot-str)
@ -17,11 +20,21 @@
(defun dispatch-gtp-command (command-string) (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)))) (command (intern (first commands))))
(progn (format t "'~a'~%" command) (progn (format t "'~a'~%" command)
(case command (case command
(name "GoBot") (name go-bot:*name*)
(version "0.1") (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) "'")))))) (otherwise (concatenate 'string "Unkown command '" (first commands) "'"))))))

View File

@ -4,7 +4,10 @@
(defpackage gtp-handler (defpackage gtp-handler
(:use :common-lisp) (:use :common-lisp)
(:export gtp-client)) (:export :gtp-client))
(defpackage go-bot (defpackage go-bot
(:use :common-lisp)) (:use :common-lisp)
(:export :*name*
:*version*
:*author*))