File: gomoku.el.html

RULES:

Gomoku is a game played between two players on a rectangular board. Each player, in turn, marks a free square of its choice. The winner is the first one to mark five contiguous squares in any direction (horizontally, vertically or diagonally).

I have been told that, in "The TRUE Gomoku", some restrictions are made about the squares where one may play, or else there is a known forced win for the first player. This program has no such restriction, but it does not know about the forced win, nor do I. See https://renju.se/rif/r1rulhis.htm for more information.

There are two main places where you may want to customize the program: key bindings and board display. These features are commented in the code. Go and see.

HOW TO USE:

The command M-x gomoku displays a board, the size of which depends on the size of the current window. The size of the board is easily modified by giving numeric arguments to the gomoku command and/or by customizing the displaying parameters.

Emacs plays when it is its turn. When it is your turn, just put the cursor on the square where you want to play and hit RET, or X, or whatever key you bind to the command gomoku-human-plays. When it is your turn, Emacs is idle: you may switch buffers, read your mail, ... Just come back to the
*Gomoku* buffer and resume play.

ALGORITHM:

The algorithm is briefly described in section "THE SCORE TABLE". Some parameters may be modified if you want to change the style exhibited by the program.

Defined variables (43)

gomoku-OOOOscoreScore of a qtuple containing four O’s.
gomoku-OOOscoreScore of a qtuple containing three O’s.
gomoku-OOscoreScore of a qtuple containing two O’s.
gomoku-OscoreScore of a qtuple containing one O.
gomoku-XXXXscoreScore of a qtuple containing four X’s.
gomoku-XXXscoreScore of a qtuple containing three X’s.
gomoku-XXscoreScore of a qtuple containing two X’s.
gomoku-XscoreScore of a qtuple containing one X.
gomoku-boardVector recording the actual state of the Gomoku board.
gomoku-board-heightNumber of lines on the Gomoku board.
gomoku-board-widthNumber of columns on the Gomoku board.
gomoku-buffer-nameName of the Gomoku buffer.
gomoku-draw-limitAfter how many moves will Emacs offer a draw?
gomoku-emacs-is-computingNon-nil if Emacs is in the middle of a computation.
gomoku-emacs-played-firstNon-nil if Emacs played first.
gomoku-emacs-wonFor making font-lock use the winner’s face for the line.
gomoku-font-lock-keywordsFont lock rules for Gomoku.
gomoku-game-historyA record of all moves that have been played during current game.
gomoku-game-in-progressNon-nil if a game is in progress.
gomoku-human-refused-drawNon-nil if Human refused Emacs offer of a draw.
gomoku-human-took-backNon-nil if Human took back a move during the game.
gomoku-losing-thresholdThreshold score beyond which a human move is winning.
gomoku-mode-abbrev-tableAbbrev table for ‘gomoku-mode’.
gomoku-mode-hookIf non-nil, its value is called on entry to Gomoku mode.
gomoku-mode-mapLocal keymap to use in Gomoku mode.
gomoku-mode-syntax-tableSyntax table for ‘gomoku-mode’.
gomoku-nil-scoreScore of an empty qtuple.
gomoku-number-of-drawsNumber of games already drawn in this session.
gomoku-number-of-emacs-winsNumber of games Emacs won in this session.
gomoku-number-of-human-movesNumber of moves already played by human in current game.
gomoku-number-of-human-winsNumber of games you won in this session.
gomoku-number-of-movesNumber of moves already played in current game.
gomoku-saved-board-heightRecorded value of previous board height.
gomoku-saved-board-widthRecorded value of previous board width.
gomoku-saved-score-tableRecorded initial value of previous score table.
gomoku-score-tableVector recording the actual score of the free squares.
gomoku-score-trans-tableVector associating qtuple contents to their score.
gomoku-square-heightVertical spacing between squares on the Gomoku board.
gomoku-square-widthHorizontal spacing between squares on the Gomoku board.
gomoku-vector-lengthLength of ‘gomoku-board’ vector.
gomoku-winning-thresholdThreshold score beyond which an Emacs move is winning.
gomoku-x-offsetNumber of columns between the Gomoku board and the side of the window.
gomoku-y-offsetNumber of lines between the Gomoku board and the top of the window.

Defined functions (50)

gomoku(&optional N M)
gomoku-beginning-of-line()
gomoku-check-filled-qtuple(SQUARE VALUE DX DY)
gomoku-click(CLICK)
gomoku-crash-game()
gomoku-cross-qtuple(SQUARE1 SQUARE2 DX DY)
gomoku-display-statistics()
gomoku-emacs-plays()
gomoku-end-of-line()
gomoku-find-filled-qtuple(SQUARE VALUE)
gomoku-goto-square(INDEX)
gomoku-goto-xy(X Y)
gomoku-human-plays()
gomoku-human-resigns()
gomoku-human-takes-back()
gomoku-index-to-x(INDEX)
gomoku-index-to-y(INDEX)
gomoku-init-board()
gomoku-init-display(N M)
gomoku-init-score-table()
gomoku-init-square-score(I J)
gomoku-max-height()
gomoku-max-width()
gomoku-mode()
gomoku-mouse-play(CLICK)
gomoku-move-down()
gomoku-move-left()
gomoku-move-ne()
gomoku-move-nw()
gomoku-move-right()
gomoku-move-se()
gomoku-move-sw()
gomoku-move-up()
gomoku-nb-qtuples(I J)
gomoku-offer-a-draw()
gomoku-play-move(SQUARE VAL &optional DONT-UPDATE-SCORE)
gomoku-plot-square(SQUARE VALUE)
gomoku-point-square()
gomoku-point-x()
gomoku-point-y()
gomoku-prompt-for-move()
gomoku-prompt-for-other-game()
gomoku-start-game(N M)
gomoku-strongest-square()
gomoku-switch-to-window()
gomoku-take-back()
gomoku-terminate-game(RESULT)
gomoku-update-score-in-direction(LEFT RIGHT SQUARE DX DY DVAL)
gomoku-update-score-table(SQUARE DVAL)
gomoku-xy-to-index(X Y)

Defined faces (2)

gomoku-OFace to use for Emacs's O.
gomoku-XFace to use for your X.