671 |
(cond ((< gomoku-number-of-moves 20) |
(cond ((< gomoku-number-of-moves 20) |
672 |
"This was a REALLY QUICK win.") |
"This was a REALLY QUICK win.") |
673 |
(gomoku-human-refused-draw |
(gomoku-human-refused-draw |
674 |
"I won... Too bad you refused my offer of a draw !") |
"I won... Too bad you refused my offer of a draw!") |
675 |
(gomoku-human-took-back |
(gomoku-human-took-back |
676 |
"I won... Taking moves back will not help you !") |
"I won... Taking moves back will not help you!") |
677 |
((not gomoku-emacs-played-first) |
((not gomoku-emacs-played-first) |
678 |
"I won... Playing first did not help you much !") |
"I won... Playing first did not help you much!") |
679 |
((and (zerop gomoku-number-of-human-wins) |
((and (zerop gomoku-number-of-human-wins) |
680 |
(zerop gomoku-number-of-draws) |
(zerop gomoku-number-of-draws) |
681 |
(> gomoku-number-of-emacs-wins 1)) |
(> gomoku-number-of-emacs-wins 1)) |
688 |
(gomoku-human-took-back |
(gomoku-human-took-back |
689 |
" I, for one, never take my moves back...") |
" I, for one, never take my moves back...") |
690 |
(gomoku-emacs-played-first |
(gomoku-emacs-played-first |
691 |
".. so what ?") |
".. so what?") |
692 |
(" Now, let me play first just once.")))) |
(" Now, let me play first just once.")))) |
693 |
((eq result 'human-resigned) |
((eq result 'human-resigned) |
694 |
(setq gomoku-number-of-emacs-wins (1+ gomoku-number-of-emacs-wins)) |
(setq gomoku-number-of-emacs-wins (1+ gomoku-number-of-emacs-wins)) |
758 |
(setq gomoku-emacs-is-computing nil) |
(setq gomoku-emacs-is-computing nil) |
759 |
(gomoku-terminate-game 'crash-game) |
(gomoku-terminate-game 'crash-game) |
760 |
(sit-for 4) |
(sit-for 4) |
761 |
(or (y-or-n-p "Another game ") (error "Chicken !"))) |
(or (y-or-n-p "Another game? ") (error "Chicken!"))) |
762 |
(switch-to-buffer gomoku-buffer-name) |
(switch-to-buffer gomoku-buffer-name) |
763 |
(gomoku-mode)) |
(gomoku-mode)) |
764 |
(cond |
(cond |
779 |
(if (and (> m max-height) |
(if (and (> m max-height) |
780 |
(not (eq m gomoku-saved-board-height)) |
(not (eq m gomoku-saved-board-height)) |
781 |
;; Use EQ because SAVED-BOARD-HEIGHT may be nil |
;; Use EQ because SAVED-BOARD-HEIGHT may be nil |
782 |
(not (y-or-n-p (format "Do you really want %d rows " m)))) |
(not (y-or-n-p (format "Do you really want %d rows? " m)))) |
783 |
(setq m max-height))) |
(setq m max-height))) |
784 |
(message "One moment, please...") |
(message "One moment, please...") |
785 |
(gomoku-start-game n m) |
(gomoku-start-game n m) |
786 |
(if (y-or-n-p "Do you allow me to play first ") |
(if (y-or-n-p "Do you allow me to play first? ") |
787 |
(gomoku-emacs-plays) |
(gomoku-emacs-plays) |
788 |
(gomoku-prompt-for-move))) |
(gomoku-prompt-for-move))) |
789 |
((y-or-n-p "Shall we continue our game ") |
((y-or-n-p "Shall we continue our game? ") |
790 |
(gomoku-prompt-for-move)) |
(gomoku-prompt-for-move)) |
791 |
(t |
(t |
792 |
(gomoku-human-resigns)))) |
(gomoku-human-resigns)))) |
875 |
(let (square score) |
(let (square score) |
876 |
(setq square (gomoku-point-square)) |
(setq square (gomoku-point-square)) |
877 |
(cond ((null square) |
(cond ((null square) |
878 |
(error "Your point is not on a square. Retry !")) |
(error "Your point is not on a square. Retry!")) |
879 |
((not (zerop (aref gomoku-board square))) |
((not (zerop (aref gomoku-board square))) |
880 |
(error "Your point is not on a free square. Retry !")) |
(error "Your point is not on a free square. Retry!")) |
881 |
(t |
(t |
882 |
(setq score (aref gomoku-score-table square)) |
(setq score (aref gomoku-score-table square)) |
883 |
(gomoku-play-move square 1) |
(gomoku-play-move square 1) |
902 |
(sit-for 4) |
(sit-for 4) |
903 |
(gomoku-prompt-for-other-game)) |
(gomoku-prompt-for-other-game)) |
904 |
((zerop gomoku-number-of-human-moves) |
((zerop gomoku-number-of-human-moves) |
905 |
(message "You have not played yet... Your move ?")) |
(message "You have not played yet... Your move?")) |
906 |
(t |
(t |
907 |
(message "One moment, please...") |
(message "One moment, please...") |
908 |
;; It is possible for the user to let Emacs play several consecutive |
;; It is possible for the user to let Emacs play several consecutive |
923 |
(gomoku-crash-game)) |
(gomoku-crash-game)) |
924 |
((not gomoku-game-in-progress) |
((not gomoku-game-in-progress) |
925 |
(message "There is no game in progress")) |
(message "There is no game in progress")) |
926 |
((y-or-n-p "You mean, you resign ") |
((y-or-n-p "You mean, you resign? ") |
927 |
(gomoku-terminate-game 'human-resigned)) |
(gomoku-terminate-game 'human-resigned)) |
928 |
((y-or-n-p "You mean, we continue ") |
((y-or-n-p "You mean, we continue? ") |
929 |
(gomoku-prompt-for-move)) |
(gomoku-prompt-for-move)) |
930 |
(t |
(t |
931 |
(gomoku-terminate-game 'human-resigned)))) ; OK. Accept it |
(gomoku-terminate-game 'human-resigned)))) ; OK. Accept it |
937 |
(defun gomoku-prompt-for-move () |
(defun gomoku-prompt-for-move () |
938 |
"Display a message asking for Human's move." |
"Display a message asking for Human's move." |
939 |
(message (if (zerop gomoku-number-of-human-moves) |
(message (if (zerop gomoku-number-of-human-moves) |
940 |
"Your move ? (move to a free square and hit X, RET ...)" |
"Your move? (move to a free square and hit X, RET ...)" |
941 |
"Your move ?")) |
"Your move?")) |
942 |
;; 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 |
943 |
;; 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. |
944 |
(save-excursion (set-buffer (other-buffer)))) |
(save-excursion (set-buffer (other-buffer)))) |
945 |
|
|
946 |
(defun gomoku-prompt-for-other-game () |
(defun gomoku-prompt-for-other-game () |
947 |
"Ask for another game, and start it." |
"Ask for another game, and start it." |
948 |
(if (y-or-n-p "Another game ") |
(if (y-or-n-p "Another game? ") |
949 |
(gomoku gomoku-board-width gomoku-board-height) |
(gomoku gomoku-board-width gomoku-board-height) |
950 |
(error "Chicken !"))) |
(error "Chicken!"))) |
951 |
|
|
952 |
(defun gomoku-offer-a-draw () |
(defun gomoku-offer-a-draw () |
953 |
"Offer a draw and return t if Human accepted it." |
"Offer a draw and return t if Human accepted it." |
954 |
(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? ") |
955 |
(not (setq gomoku-human-refused-draw t)))) |
(not (setq gomoku-human-refused-draw t)))) |
956 |
|
|
957 |
;;; |
;;; |