Function: gomoku
gomoku is an autoloaded, interactive and byte-compiled function
defined in gomoku.el.gz.
Signature
(gomoku &optional N M)
Documentation
Start a Gomoku game between you and Emacs.
If a game is in progress, this command allows you to resume it. If optional arguments N and M are given, an N by M board is used. If prefix arg is given for N, M is prompted for.
You and Emacs play in turn by marking a free square. You mark it with X and Emacs marks it with O. The winner is the first to get five contiguous marks horizontally, vertically or in diagonal.
You play by moving the cursor over the square you choose and hitting
RET (gomoku-human-plays).
This program actually plays a simplified or archaic version of the Gomoku game, and ought to be upgraded to use the full modern rules.
Use C-h m (describe-mode) for more info.
Probably introduced at or before Emacs version 19.20.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/play/gomoku.el.gz
;;;
;;; INTERACTIVE COMMANDS.
;;;
;;;###autoload
(defun gomoku (&optional n m)
"Start a Gomoku game between you and Emacs.
If a game is in progress, this command allows you to resume it.
If optional arguments N and M are given, an N by M board is used.
If prefix arg is given for N, M is prompted for.
You and Emacs play in turn by marking a free square. You mark it with X
and Emacs marks it with O. The winner is the first to get five contiguous
marks horizontally, vertically or in diagonal.
You play by moving the cursor over the square you choose and hitting
\\<gomoku-mode-map>\\[gomoku-human-plays].
This program actually plays a simplified or archaic version of the
Gomoku game, and ought to be upgraded to use the full modern rules.
Use \\[describe-mode] for more info."
(interactive (if current-prefix-arg
(list (prefix-numeric-value current-prefix-arg)
(eval (read-minibuffer "Height: ")))))
;; gomoku-switch-to-window, but without the potential call to gomoku
;; from gomoku-prompt-for-other-game.
(if (get-buffer gomoku-buffer-name)
(switch-to-buffer gomoku-buffer-name)
(when gomoku-game-in-progress
(setq gomoku-emacs-is-computing nil)
(gomoku-terminate-game 'crash-game)
(sit-for 4)
(or (y-or-n-p "Another game? ") (error "Chicken!")))
(switch-to-buffer gomoku-buffer-name)
(gomoku-mode))
(cond
(gomoku-emacs-is-computing
(gomoku-crash-game))
((or (not gomoku-game-in-progress)
(<= gomoku-number-of-moves 2))
(let ((max-width (gomoku-max-width))
(max-height (gomoku-max-height)))
(or n (setq n max-width))
(or m (setq m max-height))
(cond ((< n 1)
(error "I need at least 1 column"))
((< m 1)
(error "I need at least 1 row"))
((> n max-width)
(error "I cannot display %d columns in that window" n)))
(if (and (> m max-height)
(not (eq m gomoku-saved-board-height))
;; Use EQ because SAVED-BOARD-HEIGHT may be nil
(not (y-or-n-p (format "Do you really want %d rows? " m))))
(setq m max-height)))
(message "One moment, please...")
(gomoku-start-game n m)
(if (y-or-n-p "Do you allow me to play first? ")
(gomoku-emacs-plays)
(gomoku-prompt-for-move)))
((y-or-n-p "Shall we continue our game? ")
(gomoku-prompt-for-move))
(t
(gomoku-human-resigns))))