2008-04-28 09:18:59 +02:00
|
|
|
(in-package :gtp-handler)
|
|
|
|
|
2008-05-05 17:39:04 +02:00
|
|
|
(defparameter *quit?* nil)
|
|
|
|
|
2008-04-28 09:18:59 +02:00
|
|
|
(defun gtp-client ()
|
2008-05-05 17:39:04 +02:00
|
|
|
(setf *quit?* nil)
|
|
|
|
(do ()
|
|
|
|
((eql *quit?* t))
|
2008-05-05 17:00:06 +02:00
|
|
|
(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))))))
|
|
|
|
|
|
|
|
|
2008-04-28 09:18:59 +02:00
|
|
|
|
|
|
|
(defun dispatch-gtp-command (command-string)
|
2008-05-05 17:39:04 +02:00
|
|
|
(let* ((commands (cl-ppcre:split "\\s+" (string-upcase command-string)))
|
2008-04-28 09:18:59 +02:00
|
|
|
(command (intern (first commands))))
|
2008-05-05 17:00:06 +02:00
|
|
|
(progn (format t "'~a'~%" command)
|
|
|
|
(case command
|
2008-05-05 17:39:04 +02:00
|
|
|
(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)) "")
|
2008-05-05 17:00:06 +02:00
|
|
|
(otherwise (concatenate 'string "Unkown command '" (first commands) "'"))))))
|
2008-04-28 09:18:59 +02:00
|
|
|
|