[Bese-devel] Re: Backtracking help

William Halliburton whalliburton at gmail.com
Fri Aug 5 04:11:23 UTC 2005


I have refactored the previoius example to make simpler. Could someone
please explain why I need the (let (x x)) in the example and how to
make the backtracking work propery. I have version that uses
individual slots for each member of the array and it backtracks
propery.

Thank you,
William Halliburton

;;; tictactoe

(defcomponent tictactoe (widget-component)
  ((state :backtrack #'copy-seq
	  :initform (make-array 9 :element-type 'fixnum))))

(defaction tictactoe-select ((tictactoe tictactoe) index)
  (with-slots (state) tictactoe
     (setf (aref state index) 1)))

(defmethod render-on ((res response) (tictactoe tictactoe))
  (with-slots (state) tictactoe
       (<:pre 
	(dotimes (x 9) 
	  (let ((x x))
	    (case (aref state x)
	      (0 (<ucw:a :action (tictactoe-select tictactoe x) (<:as-is " ")))
	      (1 (<:as-is "X"))
	      (2 (<:as-is "O"))))
	  (if (or (= x 2) (= x 5))
	      (progn
		(<:as-is #\Newline)
		(<:as-html "---------")
		(<:as-is #\Newline))
	    (if (= x 8) (<:as-is #\Newline)
	      (<:as-html " | ")))))))



More information about the bese-devel mailing list