2008-05-05 15:00:06 +00:00
|
|
|
(in-package :go-bot)
|
|
|
|
|
2008-05-16 22:17:38 +00:00
|
|
|
(defparameter *name* "fink")
|
2008-05-27 00:46:43 +00:00
|
|
|
(defparameter *version* "0.3.0-dev")
|
2008-05-05 15:39:04 +00:00
|
|
|
(defparameter *author* "Dan Ballard")
|
2008-05-16 22:17:38 +00:00
|
|
|
|
2008-05-06 07:53:22 +00:00
|
|
|
(defparameter *default-komi* 5.5)
|
|
|
|
(defparameter *komi* *default-komi*)
|
|
|
|
(defparameter *default-boardsize* 19)
|
|
|
|
(defparameter *boardsize* *default-boardsize*)
|
|
|
|
|
|
|
|
(defparameter *board* nil)
|
2008-05-26 23:30:59 +00:00
|
|
|
(defparameter *cputime* 0.0)
|
2008-05-05 15:39:04 +00:00
|
|
|
|
2008-05-07 09:07:47 +00:00
|
|
|
(defparameter *passed* nil)
|
|
|
|
(defparameter *player* nil)
|
|
|
|
(defparameter *last-player* nil)
|
|
|
|
|
2008-06-21 06:03:06 +00:00
|
|
|
(defclass composite-board (liberty-shape-board)
|
2008-05-29 02:40:25 +00:00
|
|
|
((final
|
|
|
|
:initform 0)))
|
2008-05-06 07:53:22 +00:00
|
|
|
|
|
|
|
(defun set-komi (new-komi)
|
|
|
|
(setf *komi* new-komi))
|
|
|
|
|
|
|
|
(defun set-boardsize (newsize)
|
|
|
|
(setf *boardsize* newsize))
|
|
|
|
|
|
|
|
(defun init-board ()
|
2008-05-29 02:40:25 +00:00
|
|
|
(setf *board* (make-instance 'composite-board :boardsize *boardsize*))
|
2008-05-07 09:07:47 +00:00
|
|
|
(setf *passed* nil)
|
2008-05-29 02:40:25 +00:00
|
|
|
(setf *player* nil)
|
|
|
|
(setf *last-player* nil))
|
|
|
|
|
2008-05-06 07:53:22 +00:00
|
|
|
|
|
|
|
(defun init ()
|
|
|
|
;(init other game specific stuff)
|
2008-05-29 02:40:25 +00:00
|
|
|
(setf *random-state* (make-random-state t))
|
2008-05-26 23:30:59 +00:00
|
|
|
(setf *cputime* 0.0)
|
2008-05-06 07:53:22 +00:00
|
|
|
(init-board))
|
|
|
|
|
2008-05-07 09:07:47 +00:00
|
|
|
|
|
|
|
|
2008-05-26 19:13:18 +00:00
|
|
|
(defun play (board coords player)
|
|
|
|
(set-stone board coords player))
|
2008-05-19 04:00:04 +00:00
|
|
|
|
2008-05-06 07:53:22 +00:00
|
|
|
|
2008-05-19 04:00:04 +00:00
|
|
|
(defun do-play (player coord-str)
|
2008-05-07 09:07:47 +00:00
|
|
|
(setf *last-player* player)
|
|
|
|
(if (string= coord-str "PASS")
|
|
|
|
(setf *passed* t)
|
2008-05-19 04:00:04 +00:00
|
|
|
;(set-stone *board* (str-to-coord coord-str) player)))
|
2008-05-29 02:40:25 +00:00
|
|
|
(progn
|
|
|
|
(setf *passed* nil)
|
|
|
|
(play *board* (str-to-coord coord-str) player))))
|
2008-05-07 09:07:47 +00:00
|
|
|
|
2008-05-19 04:00:04 +00:00
|
|
|
(defun do-genmove (player)
|
2008-05-29 10:32:39 +00:00
|
|
|
; (format t "do-genmove ~a~%" player)
|
2008-05-07 09:07:47 +00:00
|
|
|
(setf *player* player)
|
|
|
|
(if (or (eql *passed* t) (eql *last-player* player))
|
|
|
|
"pass"
|
2008-05-26 19:16:07 +00:00
|
|
|
(let* ((move (genmove *board* player))
|
2008-06-24 17:45:26 +00:00
|
|
|
; (board-score (first move))
|
|
|
|
(coord (second move)))
|
2008-05-29 10:32:39 +00:00
|
|
|
;(format t "score: ~a for player ~a ~%" board-score player)
|
2008-06-24 17:45:26 +00:00
|
|
|
(if (listp coord) ; string= coord "pass"))
|
|
|
|
(let ((coord-str (coord-to-str coord)))
|
|
|
|
(do-play player coord-str)
|
|
|
|
coord-str)
|
|
|
|
coord))))
|
|
|
|
|
|
|
|
;(if (< board-score 0)
|
|
|
|
; "pass"
|
|
|
|
; (progn
|
|
|
|
; (do-play player coord)
|
|
|
|
; coord)))))
|
2008-05-07 09:07:47 +00:00
|
|
|
|
2008-05-29 02:40:25 +00:00
|
|
|
|
|
|
|
(defun analyze-score ()
|
|
|
|
(analyze-board-score *board* *player*))
|
|
|
|
|
|
|
|
(defun analyze-liberty ()
|
|
|
|
(liberty-to-analyze *board*))
|
2008-06-19 06:16:51 +00:00
|
|
|
|
|
|
|
(defun analyze-shapes ()
|
|
|
|
(shapes-to-analyze *board*))
|
2008-06-21 06:03:06 +00:00
|
|
|
|
|
|
|
(defun analyze-shape-liberties ()
|
|
|
|
(liberty-shape-to-analyze *board*))
|
2008-06-24 17:45:26 +00:00
|
|
|
|
|
|
|
(defun analyze-shape-stone-liberties ()
|
|
|
|
(liberty-shape-stone-to-analyze *board*))
|