More ground work
This commit is contained in:
parent
8e81da8849
commit
54ce7b3e58
|
@ -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")))
|
|
@ -0,0 +1,5 @@
|
|||
(in-package :go-bot)
|
||||
|
||||
(defun make-board (size)
|
||||
(make-array size :initial-element (make-array size :initial-element nil)))
|
||||
|
22
gtp.lisp
22
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) "'"))))))
|
||||
|
|
@ -5,3 +5,6 @@
|
|||
(defpackage gtp-handler
|
||||
(:use :common-lisp)
|
||||
(:export gtp-client))
|
||||
|
||||
(defpackage go-bot
|
||||
(:use :common-lisp))
|
Loading…
Reference in New Issue