Commits

Cat's Eye Technologies  committed 2930f9f

Import of Hunter version 1.0 revision 2007.1123 sources.

  • Participants
  • Parent commits a64c89e
  • Tags rel_1_0_2007_1123

Comments (0)

Files changed (4)

File doc/hunter.html

 </head>
 <body>
 
-<h1>HUNTER</h1>
+<h2 style="text-align: center">Concurrent Maze Space Transformation<br>
+(with Authentic Interrodent Communication)<br>
+in the HUNTER Programming Language</h2>
 
-<p><font size=-1>&nbsp;<img src="/images/icons/copyright.gif"
-   align=absmiddle width=12 height=12 alt="(c)" border=0>2002-2004 <a href="/">Cat's Eye Technologies</a>.  All rights reserved.<br>
-    This software is OSI Certified Open Source Software.<br>
-    OSI Certified is a certification mark of the <a href="http://www.opensource.org/"><img
-    src="/images/icons/webicon.gif" alt="[WWW]" border=0 width=12 height=12>Open Source Initiative</a>.<br>
-    See the file <a href="license.txt">license.txt</a> for license information.</font>
-
-<h3>Introduction</h3>
-
-<p>To quote <a href="hunter.txt">hunter.txt</a>:
-
-<blockquote>
-<p>"It is perceived that one of the biggest problems in maintaining
+<p>It is perceived that one of the biggest problems in maintaining
 interest in programming is the above linear growth of boredom
 compared to the usefulness of the program, resulting in an
 acute loss of enthusiasm on the part of the programmers and
 ultimately the abandonment of the software.</p>
 
-<p>"This document intends to address that by introducing a language
+<p>This document intends to address that by introducing a language
 with new models for sharing, flow control, and data manipulation,
 which make all dependencies in a program globally accessible and
 radically oblique at the language level.</p>
 
-<p>"We introduce the language, which is a deterministic particle
+<p>We introduce the language, which is a deterministic particle
 automaton based on mazespace-rewriting and critter-style message
-passing and, being ASCII art, is inherently graphical in notation..."</p>
-</blockquote>
+passing and, being ASCII art, is inherently graphical in notation...</p>
 
-<h3>Implementation</h3>
 
-<p>The Perl 5 implementation of HUNTER requires the
-<a href="/projects/virtcons/">_Console::Virtual
-module</a>.</p>
+<h1>The HUNTER Programming Language</h1>
+
+<p>&copy;2000-2007 Cat's Eye Technologies.  All rights reserved.</p>
+
+<p>Each HUNTER program consists of a two-dimensional Cartesian-grid
+playfield of any reasonable arbitrary size.  Each square in this
+grid is called a cell.  Each cell may contain one of several
+things, or be considered 'empty'.  It may also contain a mouse,
+which is a particularly special kind of thing.  However, a mouse
+must start in an otherwise empty square.</p>
+
+<p>Mice are particularly special because they have agency.  Unlike
+walls and pieces of cheese, they do things.  Primarily, they move
+around.  They do so at runtime.</p>
+
+<p>The deterministic fashion a mouse moves around - always checking
+east, then north, then west, then south, in each cell - and its
+memory (each mouse keeps a 'map' of where it's been in it's head
+and tries not to backtrack unless there is nowhere else new to
+go) ensures that, given some time, and all other things being
+equal, a mouse will traverse it's entire environment and will
+return to where it started.  The process then repeats, holding
+the mouse in a state of perpetual live lock.</p>
+
+<p>However, not all other things may be equal.  Indeed, the mouse
+may nibble on a bit of strychnine and die.  Or, other mice may
+be concurrently tranversing the same maze, and two mice may not
+share the same space, so they may block each other's progress.</p>
+
+<p>Mice may not move through walls but they may move through empty
+space and on top of items found in the playfield, possibly
+altering them (see below.)</p>
+
+<p>Execution ends when all mice are dead.</p>
+
+<p>An example HUNTER program might be:</p>
+
+<pre>
+########
+#   1#2#
+# #### #
+#      #
+# ######
+#     m#
+#+######
+#     !#
+########
+</pre>
+
+<p>where</p>
+
+<ul>
+  <li><code># indicates a wall</li>
+  <li><code>m indicates a mouse</li>
+  <li>the digits <code>0 to 9 represent types of cheese:
+  <ul>
+  <li><code>0</code> = cheddar</li>
+  <li><code>1</code> = american</li>
+  <li><code>2</code> = swiss</li>
+  <li><code>3</code> = gouda</li>
+  <li><code>4</code> = mozzarella</li>
+  <li><code>5</code> = farmer</li>
+  <li><code>6</code> = blue</li>
+  <li><code>7</code> = gorgonzola</li>
+  <li><code>8</code> = feta</li>
+  <li><code>9</code> = bat's-milk</li>
+  </ul></li>
+  <li><code>!</code> indicates a bit of strychnine</li>
+  <li><code>+</code> indicates a pinwheel</li>
+  <li><code>.</code> indicates a mouse turd</li>
+  <li><code>w</code> indicates a dead mouse carcass</li>
+</ul>
+
+<p>All other characters indicate other miscellaneous objects
+  apropos to being in a maze, with undefined semantics,
+  so they should be considered reserved.</p>
+
+<p>Intermouse communication is done by mouse droppings.  A mouse
+can leave a message to some other mouse by creating a mouse
+dropping where it currently is (assuming it has previously
+eaten a piece of cheese.)  Other mice can detect mouse
+droppings and change their behaviour based on them.</p>
+
+<p>How mice create droppings is defined by how each mouse is
+trained.  These mice are somewhat magical in that they can
+be trained to perform physically improbable tasks, such as
+turning one kind of cheese into another.</p>
+
+<p>Mice are trained globally by the mazespace-rewriting
+rules.  These are the guidelines by which rodents live their
+lives.  Each rule must be on a line by itself and has the
+following form:</p>
+
+<pre>
+*things&gt;droppings
+</pre>
+
+<p>For example,</p>
+
+<pre>
+*12&gt;21
+</pre>
+
+<p>Then, when a mouse encounters a piece of American cheese,
+followed by a piece of Swiss cheese, it will eat them and
+excrete a bit of Swiss cheese followed by a bit of American
+cheese.  This is just an example.</p>
+
+<p>Mice will eat cheese but will not eat mouse droppings,
+pinwheels, or other inedible items.</p>
+
+<p>Specifying strychnine, walls, or mice on the left-hand side
+of a rewriting rule is not guaranteed to be able to produce
+a match.  The behaviour of specifing mice on the right-hand
+side of a rewriting rule is undefined.</p>
+
+<h2>Implementation</h2>
+
+<p>There is an implementation of HUNTER in Perl 5.  It requires
+the <a href="/projects/cons_virt/">Console::Virtual</a> module
+to run.</p>
+
+<p>Chris Pressey<br>
+Winnipeg, Manitoba, Canada<br>
+Original Oct 24 2000<br>
+Revised for clarity Jan 26 2002<br>
+HTML'ized Nov 23 2997</p>
 
 </body></html>

File doc/hunter.txt

-                Concurrent Maze Space Transformation
-              (with Authentic Interrodent Communication)
-                 In The HUNTER Programming Language
-
-
-It is perceived that one of the biggest problems in maintaining
-interest in programming is the above linear growth of boredom
-compared to the usefulness of the program, resulting in an
-acute loss of enthusiasm on the part of the programmers and
-ultimately the abandonment of the software.
-
-This document intends to address that by introducing a language
-with new models for sharing, flow control, and data manipulation,
-which make all dependencies in a program globally accessible and
-radically oblique at the language level.
-
-We introduce the language, which is a deterministic particle
-automaton based on mazespace-rewriting and critter-style message
-passing and, being ASCII art, is inherently graphical in notation...
-
-
-The HUNTER Programming Language
-(c)2000-2002 Cat's Eye Technologies.  All rights reserved.
-
-Each HUNTER program consists of a two-dimensional Cartesian-grid
-playfield of any reasonable arbitrary size.  Each square in this
-grid is called a cell.  Each cell may contain one of several
-things, or be considered 'empty'.  It may also contain a mouse,
-which is a particularly special kind of thing.  However, a mouse
-must start in an otherwise empty square.
-
-Mice are particularly special because they have agency.  Unlike
-walls and pieces of cheese, they do things.  Primarily, they move
-around.  They do so at runtime.
-
-The deterministic fashion a mouse moves around - always checking
-east, then north, then west, then south, in each cell - and its
-memory (each mouse keeps a 'map' of where it's been in it's head
-and tries not to backtrack unless there is nowhere else new to
-go) ensures that, given some time, and all other things being
-equal, a mouse will traverse it's entire environment and will
-return to where it started.  The process then repeats, holding
-the mouse in a state of perpetual live lock.
-
-However, not all other things may be equal.  Indeed, the mouse
-may nibble on a bit of strychnine and die.  Or, other mice may
-be concurrently tranversing the same maze, and two mice may not
-share the same space, so they may block each other's progress.
-
-Mice may not move through walls but they may move through empty
-space and on top of items found in the playfield, possibly
-altering them (see below.)
-
-Execution ends when all mice are dead.
-
-An example HUNTER program might be:
-
-########
-#   1#2#
-# #### #
-#      #
-# ######
-#     m#
-#+######
-#     !#
-########
-
-where
-
-  # indicates a wall
-  m indicates a mouse
-  the digits 0 to 9 represent types of cheese
-  0 = cheddar
-  1 = american
-  2 = swiss
-  3 = gouda
-  4 = mozzarella
-  5 = farmer
-  6 = blue
-  7 = gorgonzola
-  8 = feta
-  9 = bat's-milk
-  ! indicates a bit of strychnine
-  + indicates a pinwheel
-  . indicates a mouse turd
-  w indicates a dead mouse carcass
-
-  other characters indicate other miscellaneous objects
-  apropos to being in a maze, with undefined semantics,
-  so they should be considered reserved
-
-Intermouse communication is done by mouse droppings.  A mouse
-can leave a message to some other mouse by creating a mouse
-dropping where it currently is (assuming it has previously
-eaten a piece of cheese.)  Other mice can detect mouse
-droppings and change their behaviour based on them.
-
-How mice create droppings is defined by how each mouse is
-trained.  These mice are somewhat magical in that they can
-be trained to perform physically improbable tasks, such as
-turning one kind of cheese into another.
-
-Mice are trained globally by the mazespace-rewriting
-rules.  These are the guidelines by which rodents live their
-lives.  Each rule must be on a line by itself and has the
-following form:
-
-  *things>droppings
-
-For example,
-
-  *12>21
-
-Then, when a mouse encounters a piece of American cheese,
-followed by a piece of Swiss cheese, it will eat them and
-excrete a bit of Swiss cheese followed by a bit of American
-cheese.  This is just an example.
-
-Mice will eat cheese but will not eat mouse droppings,
-pinwheels, or other inedible items.
-
-Specifying strychnine, walls, or mice on the left-hand side
-of a rewriting rule is not guaranteed to be able to produce
-a match.  The behaviour of specifing mice on the right-hand
-side of a rewriting rule is undefined.
-
-
-
-Chris Pressey
-Winnipeg, Manitoba, Canada
-Original Oct 24 2000
-Revised for clarity Jan 26 2002

File doc/license.txt

-Copyright (c)2001, Cat's Eye Technologies.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-  Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in
-  the documentation and/or other materials provided with the
-  distribution.
-
-  Neither the name of Cat's Eye Technologies nor the names of its
-  contributors may be used to endorse or promote products derived
-  from this software without specific prior written permission. 
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
-OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE. 

File script/hunter.pl

 #!/usr/bin/perl
 
 # HUNTER - concurrent maze-space traversal language
-# v2002.01.26 Chris Pressey, Cat's Eye Technologies
+# v2007.1123 Chris Pressey, Cat's Eye Technologies
 
-# Copyright (c)2002, Cat's Eye Technologies.
+# Copyright (c)2002-2007, Chris Pressey, Cat's Eye Technologies.
 # All rights reserved.
-# 
+#
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
-# 
-#   Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# 
-#   Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in
-#   the documentation and/or other materials provided with the
-#   distribution.
-# 
-#   Neither the name of Cat's Eye Technologies nor the names of its
-#   contributors may be used to endorse or promote products derived
-#   from this software without specific prior written permission. 
-# 
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
-# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE. 
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
 
-# usage: [perl] hunter[.pl] [-no-eat] [-delay xxx] hunter-playfield-file
-# requirements: Curses, or ANSI terminal, or Win32 Console.
+# usage: [perl] hunter[.pl] [-no-eat] [-delay ms] hunter-playfield-file
+# requirements: Console::Virtual.
 
 # history: v2000.08.05 - started prototyping (from worb.pl).
 #          v2000.08.07 - added deterministic traversal.
 #          v2002.01.26 - fixed behaviour of eating of cheese
 #                        added command line options
 #                        does not rely on "\n" in screen driver
+#          v2007.1123  - use latest version of Console::Virtual
+#                        use Time::HiRes if avail, delay in ms
+#                        use strict qw(vars refs subs)
+#                        updated BSD license (no "REGENTS")
 
-# Uncomment this line to use a specific display driver.
-# BEGIN { $_Console::Virtual::setup{display} = 'ANSI'; }
+use strict qw(vars refs subs);
 
-use _Console::Virtual 2001.0123
+# This allows us to keep Console::Virtual in same directory as script
+BEGIN { use File::Basename; push @INC, dirname($0); }
+
+# Uncomment these lines to use specific display/input/color drivers.
+# BEGIN { $Console::Virtual::setup{display} = 'ANSI'; }
+# BEGIN { $Console::Virtual::setup{input} = 'Teletype'; }
+# BEGIN { $Console::Virtual::setup{color} = 'ANSI16'; }
+
+use Console::Virtual 2007.1122
      qw(getkey display gotoxy clrscr clreol
-        normal inverse bold update_display);
+        normal inverse bold update_display color);
+
+# This lets us do sub-second sleeps, if Time::HiRes is available.
+my $sleep = sub($) { sleep(shift); };
+my $found_time_hires = 0;
+foreach my $c (@INC)
+{
+  $found_time_hires = 1 if -r "$c/Time/HiRes.pm";
+}
+if ($found_time_hires) {
+  require Time::HiRes;
+  $sleep = sub($) { Time::HiRes::sleep(shift); };
+}
 
 ### GLOBALS ###
 
-@mouse = ();
-@playfield = ();
-@mouse_at_cache = ();
-@rule = ();
+my @mouse = ();
+my @playfield = ();
+my @mouse_at_cache = ();
+my @rule = ();
 
-$x = 0; $y = 0;
-$no_eat = 0;     # compatibility flag
-$delay = 300;
+my $x = 0;
+my $y = 0;
+
+my $maxx = 1;
+my $maxy = 1;
+
+my $no_eat = 0;     # compatibility flag
+my $delay = 100;
 
 ### SUBS ###
 
 {
   gotoxy(1,1);
   my $i; my $j; my $p;
-  for($j = 0; $j <= $maxy; $j++)
+  for ($j = 0; $j <= $maxy; $j++)
   {
-    for($i = 0; $i <= $maxx; $i++)
+    for ($i = 0; $i <= $maxx; $i++)
     {
       if (is_mouse_at($i,$j))
       {
 }
 
 open PLAYFIELD, $ARGV[0];
-while(defined($line = <PLAYFIELD>))
+while (defined(my $line = <PLAYFIELD>))
 {
   my $i;
   chomp($line);
 close PLAYFIELD;
 
 clrscr();
+color('white', 'black');
 
 draw_playfield();
 
-$start_time = time();
-$tick = 1;
-while(1)
+while (1)
 {
   my $mouse;
   my $pole;
         die "Can't be!";
       }
 
-      if((defined($mouse->{been}[$new_x][$new_y]) and $mouse->{been}[$new_x][$new_y])
+      if ((defined($mouse->{been}[$new_x][$new_y]) and $mouse->{been}[$new_x][$new_y])
         or not vacant($new_x, $new_y))
       {
         $mouse->{stack}[$#{$mouse->{stack}}]++;
     exit(0);
   }
   update_display();
-  for($i = 1; $i < $delay; $i++)
-  {
-    gotoxy(1,20);
-  }
+  &$sleep($delay / 1000);
 }
 
 ### END of hunter.pl ###