branch: master
commit a5361bf4595b7c0136999e35b3ec32f7deb5aff9
Author: Nicolas Richard
Commit: Nicolas Richard
* packages/landmark/landmark.el: Move from Emacs master to ELPA
---
packages/landmark/landmark.el | 1684 +
1 files changed, 1684 insertions(+), 0 deletions(-)
diff --git a/packages/landmark/landmark.el b/packages/landmark/landmark.el
new file mode 100644
index 000..2a64cdf
--- /dev/null
+++ b/packages/landmark/landmark.el
@@ -0,0 +1,1684 @@
+;;; landmark.el --- Neural-network robot that learns landmarks -*-
lexical-binding:t -*-
+
+;; Copyright (C) 1996-1997, 2000-2015 Free Software Foundation, Inc.
+
+;; Author: Terrence Brannon (was: )
+;; Created: December 16, 1996 - first release to usenet
+;; Keywords: games, neural network, adaptive search, chemotaxis
+;; Version: 1.0
+
+;; This file is part of GNU Emacs.
+
+;; 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 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+
+;;; Commentary:
+
+;; To try this, just type: M-x landmark-test-run
+
+;; Landmark is a relatively non-participatory game in which a robot
+;; attempts to maneuver towards a tree at the center of the window
+;; based on unique olfactory cues from each of the 4 directions. If
+;; the smell of the tree increases, then the weights in the robot's
+;; brain are adjusted to encourage this odor-driven behavior in the
+;; future. If the smell of the tree decreases, the robots weights are
+;; adjusted to discourage a correct move.
+
+;; In laymen's terms, the search space is initially flat. The point
+;; of training is to "turn up the edges of the search space" so that
+;; the robot rolls toward the center.
+
+;; Further, do not become alarmed if the robot appears to oscillate
+;; back and forth between two or a few positions. This simply means
+;; it is currently caught in a local minimum and is doing its best to
+;; work its way out.
+
+;; The version of this program as described has a small problem. a
+;; move in a net direction can produce gross credit assignment. for
+;; example, if moving south will produce positive payoff, then, if in
+;; a single move, one moves east,west and south, then both east and
+;; west will be improved when they shouldn't
+
+;; Many thanks to Yuri Pryadkin for this
+;; concise problem description.
+
+;;;_* Require
+(eval-when-compile (require 'cl-lib))
+
+;;;_* From Gomoku
+
+;;; Code:
+
+(defgroup landmark nil
+ "Neural-network robot that learns landmarks."
+ :prefix "landmark-"
+ :group 'games)
+
+;;;_ + THE BOARD.
+
+;; 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
+;; its (X,Y) coords, or by the INDEX corresponding to them in the vector. The
+;; leftmost topmost square has coords (1,1) and index landmark-board-width + 2.
+;; Similarly, vectors between squares may be given by two DX, DY coords or by
+;; one DEPL (the difference between indexes).
+
+(defvar landmark-board-width nil
+ "Number of columns on the Landmark board.")
+(defvar landmark-board-height nil
+ "Number of lines on the Landmark board.")
+
+(defvar landmark-board nil
+ "Vector recording the actual state of the Landmark board.")
+
+(defvar landmark-vector-length nil
+ "Length of landmark-board vector.")
+
+(defvar landmark-draw-limit nil
+ ;; This is usually set to 70% of the number of squares.
+ "After how many moves will Emacs offer a draw?")
+
+(defvar landmark-cx 0
+ "This is the x coordinate of the center of the board.")
+
+(defvar landmark-cy 0
+ "This is the y coordinate of the center of the board.")
+
+(defvar landmark-m 0
+ "This is the x dimension of the playing board.")
+
+(defvar landmark-n 0
+ "This is the y dimension of the playing board.")
+
+
+(defun landmark-xy-to-index (x y)
+ "Translate X, Y cartesian coords into the corresponding board index."
+ (+ (* y landmark-board-width) x y))
+
+(defun landmark-index-to-x (index)
+ "Return corresponding x-coord of board INDEX."
+ (% index (1+ landmark-board-width)))
+
+(defun landmark-index-to-y (in