More ground work

This commit is contained in:
Dan 2008-05-05 08:00:06 -07:00
parent 8e81da8849
commit 54ce7b3e58
4 changed files with 34 additions and 5 deletions

7
env.lisp Normal file
View File

@ -0,0 +1,7 @@
(in-package :common-lisp)
(defparameter *src-root* "/home/dan/src/my/gobot/")
(load (compile-file (concatenate 'string *src-root* "packages.lisp")))
(load (compile-file (concatenate 'string *src-root* "gtp.lisp")))
(load (compile-file (concatenate 'string *src-root* "gobot.lisp")))

5
gobot.lisp Normal file
View File

@ -0,0 +1,5 @@
(in-package :go-bot)
(defun make-board (size)
(make-array size :initial-element (make-array size :initial-element nil)))

View File

@ -2,12 +2,26 @@
(defun gtp-client () (defun gtp-client ()
(do ((quit? nil)) (do ((quit? nil))
(= quit? nil) ((eql quit? t))
(dispatch-gtp-command (read-line t)))) (format t "= ~a~%~%" (dispatch-gtp-command (read-line t)))))
(defun split-string (string pivot-str)
(do ((pivot (char pivot-str 0))
(i 0 (+ i 1))
(beg 0)
(strings '()))
((> i (length string)) (reverse strings))
(if (or (eql (length string) i) (eql (aref string i) pivot))
(progn (push (subseq string beg i) strings) (setf beg (+ i 1))))))
(defun dispatch-gtp-command (command-string) (defun dispatch-gtp-command (command-string)
(let* ((commands (split-string (string-downcase command-string) " ")) (let* ((commands (split-string (string-downcase command-string) " "))
(command (intern (first commands)))) (command (intern (first commands))))
(case (command) (progn (format t "'~a'~%" command)
(thing (case command
(name "GoBot")
(version "0.1")
(otherwise (concatenate 'string "Unkown command '" (first commands) "'"))))))

View File

@ -4,4 +4,7 @@
(defpackage gtp-handler (defpackage gtp-handler
(:use :common-lisp) (:use :common-lisp)
(:export gtp-client)) (:export gtp-client))
(defpackage go-bot
(:use :common-lisp))