]> code.delx.au - gnu-emacs/blobdiff - lisp/play/landmark.el
Merge unicode branch
[gnu-emacs] / lisp / play / landmark.el
index b4779a4e8ab67dd2f851c89e5f19bf8b5e50abc1..55ad6017885e3e7fcc3001fc8d1d70b6fdcf25c6 100644 (file)
@@ -1,14 +1,15 @@
 ;;; landmark.el --- neural-network robot that learns landmarks
 
-;; Copyright (c) 1996, 1997, 2000, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Terrence Brannon (was: <brannon@rana.usc.edu>)
 ;; Created: December 16, 1996 - first release to usenet
-;; Keywords: gomoku neural network adaptive search chemotaxis
+;; Keywords: gomoku, neural network, adaptive search, chemotaxis
 
 ;;;_* Usage
 ;;; Just type
-;;;   M-x eval-current-buffer
+;;;   M-x eval-buffer
 ;;;   M-x lm-test-run
 
 
@@ -16,7 +17,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -26,8 +27,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 
 ;;; Commentary:
@@ -74,7 +75,7 @@
 ;; The board is a rectangular grid. We code empty squares with 0, X's with 1
 ;; and O's with 6. The rectangle is recorded in a one dimensional vector
 ;; containing padding squares (coded with -1). These squares allow us to
-;; detect when we are trying to move out of the board. We denote a square by
+;; detect when we are trying to move out of the board.  We denote a square by
 ;; its (X,Y) coords, or by the INDEX corresponding to them in the vector.  The
 ;; leftmost topmost square has coords (1,1) and index lm-board-width + 2.
 ;; Similarly, vectors between squares may be given by two DX, DY coords or by
 (defvar lm-emacs-won ()
   "*For making font-lock use the winner's face for the line.")
 
-(defvar lm-font-lock-face-O
-  (if (display-color-p)
-      (list (facemenu-get-face 'fg:red) 'bold))
-  "*Face to use for Emacs' O.")
+(defface lm-font-lock-face-O '((((class color)) :foreground "red")
+                              (t :weight bold))
+  "*Face to use for Emacs' O."
+  :version "22.1"
+  :group 'lm)
 
-(defvar lm-font-lock-face-X
-  (if (display-color-p)
-      (list (facemenu-get-face 'fg:green) 'bold))
-  "*Face to use for your X.")
+(defface lm-font-lock-face-X '((((class color)) :foreground "green")
+                              (t :weight bold))
+  "*Face to use for your X."
+  :version "22.1"
+  :group 'lm)
 
 (defvar lm-font-lock-keywords
-  '(("O" . lm-font-lock-face-O)
-    ("X" . lm-font-lock-face-X)
+  '(("O" . 'lm-font-lock-face-O)
+    ("X" . 'lm-font-lock-face-X)
     ("[-|/\\]" 0 (if lm-emacs-won
-                    lm-font-lock-face-O
-                  lm-font-lock-face-X)))
+                    'lm-font-lock-face-O
+                  'lm-font-lock-face-X)))
   "*Font lock rules for Lm.")
 
 (put 'lm-mode 'front-sticky
@@ -248,6 +251,7 @@ Other useful commands:
 Entry to this mode calls the value of `lm-mode-hook' if that value
 is non-nil.  One interesting value is `turn-on-font-lock'."
   (interactive)
+  (kill-all-local-variables)
   (setq major-mode 'lm-mode
        mode-name "Lm")
   (lm-display-statistics)
@@ -255,7 +259,7 @@ is non-nil.  One interesting value is `turn-on-font-lock'."
   (make-local-variable 'font-lock-defaults)
   (setq font-lock-defaults '(lm-font-lock-keywords t))
   (toggle-read-only t)
-  (run-hooks 'lm-mode-hook))
+  (run-mode-hooks 'lm-mode-hook))
 
 
 ;;;_ +  THE SCORE TABLE.
@@ -761,9 +765,9 @@ If the game is finished, this command requests for another game."
     (let (square score)
       (setq square (lm-point-square))
       (cond ((null square)
-            (error "Your point is not on a square. Retry !"))
+            (error "Your point is not on a square. Retry!"))
            ((not (zerop (aref lm-board square)))
-            (error "Your point is not on a free square. Retry !"))
+            (error "Your point is not on a free square. Retry!"))
            (t
             (setq score (aref lm-score-table square))
             (lm-play-move square 1)
@@ -788,7 +792,7 @@ If the game is finished, this command requests for another game."
     (sit-for 4)
     (lm-prompt-for-other-game))
    ((zerop lm-number-of-human-moves)
-    (message "You have not played yet... Your move ?"))
+    (message "You have not played yet... Your move?"))
    (t
     (message "One moment, please...")
     ;; It is possible for the user to let Emacs play several consecutive
@@ -809,9 +813,9 @@ If the game is finished, this command requests for another game."
     (lm-crash-game))
    ((not lm-game-in-progress)
     (message "There is no game in progress"))
-   ((y-or-n-p "You mean, you resign ")
+   ((y-or-n-p "You mean, you resign? ")
     (lm-terminate-game 'human-resigned))
-   ((y-or-n-p "You mean, we continue ")
+   ((y-or-n-p "You mean, we continue? ")
     (lm-prompt-for-move))
    (t
     (lm-terminate-game 'human-resigned)))) ; OK. Accept it
@@ -821,23 +825,23 @@ If the game is finished, this command requests for another game."
 (defun lm-prompt-for-move ()
   "Display a message asking for Human's move."
   (message (if (zerop lm-number-of-human-moves)
-              "Your move ? (move to a free square and hit X, RET ...)"
-              "Your move ?"))
+              "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.
   (save-excursion (set-buffer (other-buffer))))
 
 (defun lm-prompt-for-other-game ()
   "Ask for another game, and start it."
-  (if (y-or-n-p "Another game ")
+  (if (y-or-n-p "Another game? ")
       (if (y-or-n-p "Retain learned weights ")
          (lm 2)
        (lm 1))
-    (message "Chicken !")))
+    (message "Chicken!")))
 
 (defun lm-offer-a-draw ()
   "Offer a draw and return t if Human accepted it."
-  (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? ")
       (not (setq lm-human-refused-draw t))))
 
 
@@ -1048,13 +1052,13 @@ mouse-1: get robot moving, mouse-2: play on this square")))
   "Move point down one row on the Lm board."
   (interactive)
   (if (< (lm-point-y) lm-board-height)
-      (next-line 1)));;; lm-square-height)))
+      (forward-line 1)));;; lm-square-height)))
 
 (defun lm-move-up ()
   "Move point up one row on the Lm board."
   (interactive)
   (if (> (lm-point-y) 1)
-      (previous-line lm-square-height)))
+      (forward-line (- lm-square-height))))
 
 (defun lm-move-ne ()
   "Move point North East on the Lm board."
@@ -1471,7 +1475,7 @@ After this limit is reached, lm-random-move is called to push him out of it."
   (lm-plot-square (lm-point-square) 1)
   (incf lm-number-of-moves)
   (if lm-output-moves
-      (message (format "Moves made: %d" lm-number-of-moves))))
+      (message "Moves made: %d" lm-number-of-moves)))
 
 
 (defun lm-random-move ()
@@ -1521,9 +1525,9 @@ If the game is finished, this command requests for another game."
     (let (square score)
       (setq square (lm-point-square))
       (cond ((null square)
-            (error "Your point is not on a square. Retry !"))
+            (error "Your point is not on a square. Retry!"))
            ((not (zerop (aref lm-board square)))
-            (error "Your point is not on a free square. Retry !"))
+            (error "Your point is not on a free square. Retry!"))
            (t
             (progn
               (lm-plot-square square 1)
@@ -1676,7 +1680,7 @@ Use \\[describe-mode] for more info."
       (if (and (> lm-m max-height)
               (not (eq lm-m lm-saved-board-height))
               ;; Use EQ because SAVED-BOARD-HEIGHT may be nil
-              (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))))
          (setq lm-m max-height)))
     (if lm-one-moment-please
        (message "One moment, please..."))
@@ -1692,15 +1696,18 @@ Use \\[describe-mode] for more info."
 
 ;;;_ + Local variables
 
-;;; The following `outline-layout' local variable setting:
+;;; The following `allout-layout' local variable setting:
 ;;;  - closes all topics from the first topic to just before the third-to-last,
 ;;;  - shows the children of the third to last (config vars)
 ;;;  - and the second to last (code section),
 ;;;  - and closes the last topic (this local-variables section).
 ;;;Local variables:
-;;;outline-layout: (0 : -1 -1 0)
+;;;allout-layout: (0 : -1 -1 0)
 ;;;End:
 
+(random t)
+
 (provide 'landmark)
 
+;;; arch-tag: ae5031be-96e6-459e-a3df-1df53117d3f2
 ;;; landmark.el ends here