]> code.delx.au - gnu-emacs/blobdiff - lisp/play/gomoku.el
Merge from trunk.
[gnu-emacs] / lisp / play / gomoku.el
index c6d66bb1774de43dc9521cd1843e625d810e9948..6d73e2ccb65daa035bf51a814798a6be51b3e6aa 100644 (file)
@@ -1,7 +1,6 @@
 ;;; gomoku.el --- Gomoku game between you and Emacs
 
-;; Copyright (C) 1988, 1994, 1996, 2001, 2002, 2003, 2004, 2005, 2006,
-;;   2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 1996, 2001-2012 Free Software Foundation, Inc.
 
 ;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
 ;; Maintainer: FSF
@@ -90,16 +89,16 @@ One useful value to include is `turn-on-font-lock' to highlight the pieces."
 ;; look rectangular, but spacings SHOULD be at least 2 (MUST BE at least 1).
 
 (defconst gomoku-square-width 4
-  "*Horizontal spacing between squares on the Gomoku board.")
+  "Horizontal spacing between squares on the Gomoku board.")
 
 (defconst gomoku-square-height 2
-  "*Vertical spacing between squares on the Gomoku board.")
+  "Vertical spacing between squares on the Gomoku board.")
 
 (defconst gomoku-x-offset 3
-  "*Number of columns between the Gomoku board and the side of the window.")
+  "Number of columns between the Gomoku board and the side of the window.")
 
 (defconst gomoku-y-offset 1
-  "*Number of lines between the Gomoku board and the top of the window.")
+  "Number of lines between the Gomoku board and the top of the window.")
 
 
 (defvar gomoku-mode-map
@@ -162,7 +161,7 @@ One useful value to include is `turn-on-font-lock' to highlight the pieces."
 
 (defface gomoku-O
     '((((class color)) (:foreground "red" :weight bold)))
-  "Face to use for Emacs' O."
+  "Face to use for Emacs's O."
   :group 'gomoku)
 
 (defface gomoku-X
@@ -174,7 +173,7 @@ One useful value to include is `turn-on-font-lock' to highlight the pieces."
   '(("O" . 'gomoku-O)
     ("X" . 'gomoku-X)
     ("[-|/\\]" 0 (if gomoku-emacs-won 'gomoku-O 'gomoku-X)))
-  "*Font lock rules for Gomoku.")
+  "Font lock rules for Gomoku.")
 
 (put 'gomoku-mode 'front-sticky
      (put 'gomoku-mode 'rear-nonsticky '(intangible)))
@@ -278,7 +277,7 @@ Other useful commands:\n
 ;; its contents as a set, i.e. not considering the order of its elements. The
 ;; highest score is given to the "OOOO" qtuples because playing in such a
 ;; qtuple is winning the game. Just after this comes the "XXXX" qtuple because
-;; not playing in it is just loosing the game, and so on. Note that a
+;; not playing in it is just losing the game, and so on. Note that a
 ;; "polluted" qtuple, i.e. one containing at least one X and at least one O,
 ;; has score zero because there is no more any point in playing in it, from
 ;; both an attacking and a defending point of view.
@@ -348,12 +347,12 @@ Other useful commands:\n
 ;; qtuple, thus to be a winning move. Similarly, the only way for a square to
 ;; have a score between gomoku-XXXXscore and gomoku-OOOOscore is to belong to a "XXXX"
 ;; qtuple. We may use these considerations to detect when a given move is
-;; winning or loosing.
+;; winning or losing.
 
 (defconst gomoku-winning-threshold gomoku-OOOOscore
   "Threshold score beyond which an Emacs move is winning.")
 
-(defconst gomoku-loosing-threshold gomoku-XXXXscore
+(defconst gomoku-losing-threshold gomoku-XXXXscore
   "Threshold score beyond which a human move is winning.")
 
 
@@ -380,7 +379,7 @@ Other useful commands:\n
                  best-square square
                  score-max   score)
            (aset gomoku-score-table square -1))) ; no: kill it !
-       ;; If score is equally good, choose randomly. But first check freeness:
+       ;; If score is equally good, choose randomly. But first check freedom:
        ((not (zerop (aref gomoku-board square)))
        (aset gomoku-score-table square -1))
        ((zerop (random (setq count (1+ count))))
@@ -872,7 +871,7 @@ If the game is finished, this command requests for another game."
            (t
             (setq score (aref gomoku-score-table square))
             (gomoku-play-move square 1)
-            (cond ((and (>= score gomoku-loosing-threshold)
+            (cond ((and (>= score gomoku-losing-threshold)
                         ;; Just testing SCORE > THRESHOLD is not enough for
                         ;; detecting wins, it just gives an indication that
                         ;; we confirm with GOMOKU-FIND-FILLED-QTUPLE.
@@ -929,11 +928,7 @@ If the game is finished, this command requests for another game."
   "Display a message asking for Human's move."
   (message (if (zerop gomoku-number-of-human-moves)
               "Your move?  (Move to a free square and hit X, RET ...)"
-              "Your move?"))
-  ;; This may seem silly, but if one omits the following line (or a similar
-  ;; one), the cursor may very well go to some place where POINT is not.
-  ;; FIXME: this can't be right!!  --Stef
-  (save-excursion (set-buffer (other-buffer))))
+              "Your move?")))
 
 (defun gomoku-prompt-for-other-game ()
   "Ask for another game, and start it."
@@ -1048,11 +1043,11 @@ If the game is finished, this command requests for another game."
       (insert-char ?\n gomoku-square-height))
     (or (eq (char-after 1) ?.)
        (put-text-property 1 2 'point-entered
-                          (lambda (y) (if (bobp) (forward-char)))))
+                          (lambda (_x _y) (if (bobp) (forward-char)))))
     (or intangible
        (put-text-property point (point) 'intangible 2))
     (put-text-property point (point) 'point-entered
-                      (lambda (y) (if (eobp) (backward-char))))
+                      (lambda (_x _y) (if (eobp) (backward-char))))
     (put-text-property (point-min) (point) 'category 'gomoku-mode))
   (gomoku-goto-xy (/ (1+ n) 2) (/ (1+ m) 2)) ; center of the board
   (sit-for 0))                         ; Display NOW