763 |
(let (square score) |
(let (square score) |
764 |
(setq square (lm-point-square)) |
(setq square (lm-point-square)) |
765 |
(cond ((null square) |
(cond ((null square) |
766 |
(error "Your point is not on a square. Retry !")) |
(error "Your point is not on a square. Retry!")) |
767 |
((not (zerop (aref lm-board square))) |
((not (zerop (aref lm-board square))) |
768 |
(error "Your point is not on a free square. Retry !")) |
(error "Your point is not on a free square. Retry!")) |
769 |
(t |
(t |
770 |
(setq score (aref lm-score-table square)) |
(setq score (aref lm-score-table square)) |
771 |
(lm-play-move square 1) |
(lm-play-move square 1) |
790 |
(sit-for 4) |
(sit-for 4) |
791 |
(lm-prompt-for-other-game)) |
(lm-prompt-for-other-game)) |
792 |
((zerop lm-number-of-human-moves) |
((zerop lm-number-of-human-moves) |
793 |
(message "You have not played yet... Your move ?")) |
(message "You have not played yet... Your move?")) |
794 |
(t |
(t |
795 |
(message "One moment, please...") |
(message "One moment, please...") |
796 |
;; It is possible for the user to let Emacs play several consecutive |
;; It is possible for the user to let Emacs play several consecutive |
811 |
(lm-crash-game)) |
(lm-crash-game)) |
812 |
((not lm-game-in-progress) |
((not lm-game-in-progress) |
813 |
(message "There is no game in progress")) |
(message "There is no game in progress")) |
814 |
((y-or-n-p "You mean, you resign ") |
((y-or-n-p "You mean, you resign? ") |
815 |
(lm-terminate-game 'human-resigned)) |
(lm-terminate-game 'human-resigned)) |
816 |
((y-or-n-p "You mean, we continue ") |
((y-or-n-p "You mean, we continue? ") |
817 |
(lm-prompt-for-move)) |
(lm-prompt-for-move)) |
818 |
(t |
(t |
819 |
(lm-terminate-game 'human-resigned)))) ; OK. Accept it |
(lm-terminate-game 'human-resigned)))) ; OK. Accept it |
823 |
(defun lm-prompt-for-move () |
(defun lm-prompt-for-move () |
824 |
"Display a message asking for Human's move." |
"Display a message asking for Human's move." |
825 |
(message (if (zerop lm-number-of-human-moves) |
(message (if (zerop lm-number-of-human-moves) |
826 |
"Your move ? (move to a free square and hit X, RET ...)" |
"Your move? (move to a free square and hit X, RET ...)" |
827 |
"Your move ?")) |
"Your move?")) |
828 |
;; This may seem silly, but if one omits the following line (or a similar |
;; This may seem silly, but if one omits the following line (or a similar |
829 |
;; one), the cursor may very well go to some place where POINT is not. |
;; one), the cursor may very well go to some place where POINT is not. |
830 |
(save-excursion (set-buffer (other-buffer)))) |
(save-excursion (set-buffer (other-buffer)))) |
831 |
|
|
832 |
(defun lm-prompt-for-other-game () |
(defun lm-prompt-for-other-game () |
833 |
"Ask for another game, and start it." |
"Ask for another game, and start it." |
834 |
(if (y-or-n-p "Another game ") |
(if (y-or-n-p "Another game? ") |
835 |
(if (y-or-n-p "Retain learned weights ") |
(if (y-or-n-p "Retain learned weights ") |
836 |
(lm 2) |
(lm 2) |
837 |
(lm 1)) |
(lm 1)) |
838 |
(message "Chicken !"))) |
(message "Chicken!"))) |
839 |
|
|
840 |
(defun lm-offer-a-draw () |
(defun lm-offer-a-draw () |
841 |
"Offer a draw and return t if Human accepted it." |
"Offer a draw and return t if Human accepted it." |
842 |
(or (y-or-n-p "I offer you a draw. Do you accept it ") |
(or (y-or-n-p "I offer you a draw. Do you accept it? ") |
843 |
(not (setq lm-human-refused-draw t)))) |
(not (setq lm-human-refused-draw t)))) |
844 |
|
|
845 |
|
|
1523 |
(let (square score) |
(let (square score) |
1524 |
(setq square (lm-point-square)) |
(setq square (lm-point-square)) |
1525 |
(cond ((null square) |
(cond ((null square) |
1526 |
(error "Your point is not on a square. Retry !")) |
(error "Your point is not on a square. Retry!")) |
1527 |
((not (zerop (aref lm-board square))) |
((not (zerop (aref lm-board square))) |
1528 |
(error "Your point is not on a free square. Retry !")) |
(error "Your point is not on a free square. Retry!")) |
1529 |
(t |
(t |
1530 |
(progn |
(progn |
1531 |
(lm-plot-square square 1) |
(lm-plot-square square 1) |
1678 |
(if (and (> lm-m max-height) |
(if (and (> lm-m max-height) |
1679 |
(not (eq lm-m lm-saved-board-height)) |
(not (eq lm-m lm-saved-board-height)) |
1680 |
;; Use EQ because SAVED-BOARD-HEIGHT may be nil |
;; Use EQ because SAVED-BOARD-HEIGHT may be nil |
1681 |
(not (y-or-n-p (format "Do you really want %d rows " lm-m)))) |
(not (y-or-n-p (format "Do you really want %d rows? " lm-m)))) |
1682 |
(setq lm-m max-height))) |
(setq lm-m max-height))) |
1683 |
(if lm-one-moment-please |
(if lm-one-moment-please |
1684 |
(message "One moment, please...")) |
(message "One moment, please...")) |