From 54ce7b3e5801df78c55dfad160fab5e8eaa99620 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 5 May 2008 08:00:06 -0700 Subject: [PATCH] More ground work --- env.lisp | 7 +++++++ gobot.lisp | 5 +++++ gtp.lisp | 22 ++++++++++++++++++---- packages.lisp | 5 ++++- 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 env.lisp create mode 100644 gobot.lisp diff --git a/env.lisp b/env.lisp new file mode 100644 index 0000000..fd26c55 --- /dev/null +++ b/env.lisp @@ -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"))) \ No newline at end of file diff --git a/gobot.lisp b/gobot.lisp new file mode 100644 index 0000000..b7eb3bb --- /dev/null +++ b/gobot.lisp @@ -0,0 +1,5 @@ +(in-package :go-bot) + +(defun make-board (size) + (make-array size :initial-element (make-array size :initial-element nil))) + diff --git a/gtp.lisp b/gtp.lisp index 091742c..ca87005 100644 --- a/gtp.lisp +++ b/gtp.lisp @@ -2,12 +2,26 @@ (defun gtp-client () (do ((quit? nil)) - (= quit? nil) - (dispatch-gtp-command (read-line t)))) + ((eql quit? 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) (let* ((commands (split-string (string-downcase command-string) " ")) (command (intern (first commands)))) - (case (command) - (thing + (progn (format t "'~a'~%" command) + (case command + (name "GoBot") + (version "0.1") + (otherwise (concatenate 'string "Unkown command '" (first commands) "'")))))) \ No newline at end of file diff --git a/packages.lisp b/packages.lisp index 7abbcb8..dd16624 100644 --- a/packages.lisp +++ b/packages.lisp @@ -4,4 +4,7 @@ (defpackage gtp-handler (:use :common-lisp) - (:export gtp-client)) \ No newline at end of file + (:export gtp-client)) + +(defpackage go-bot + (:use :common-lisp)) \ No newline at end of file