Anonymous avatar Anonymous committed c04e092 Draft

Initial import of Hunter version 1.0 revision 2002.0126 sources.

Comments (0)

Files changed (11)

+<html><head>
+    <meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1">
+    <title>Cat's Eye Technologies: The HUNTER Programming Language</title>
+</head>
+<body>
+
+<h1>HUNTER</h1>
+
+<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
+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
+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
+automaton based on mazespace-rewriting and critter-style message
+passing and, being ASCII art, is inherently graphical in notation..."</p>
+</blockquote>
+
+<h3>Implementation</h3>
+
+<p>The Perl 5 implementation of HUNTER requires the
+<a href="/projects/virtcons/">_Console::Virtual
+module</a>.</p>
+
+</body></html>
+                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
+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. 
+####################################
+##1  #1  #0  #1  #0  #0  #1  #13m#!#
+# 0#  0#  1#  1#  0#  1#  1#  0### #
+# ################################ #
+#                                  #
+####################################
+*3>+0
+*00>0    0
+*01>1    0
+*10>1    0
+*11>0    1
+
+

eg/massive.hunter

+#########################
+#M  # M #  M#M  # M #  M#
+#   #   #   #   #   #   #
+#   #   #   #   #   #   #
+#############   #   #   #
+#   #   #   #   #   #   #
+#M  # M #  M#   #   #   #
+#   #   #   #   #   #   #
+#############   #   #   #
+#M  #   #M  #   #   #   #
+#   # M #   # ! # ! # ! #
+#  M#   #  M#   #   #   #
+#############   #   #   #
+#   #   #   #   #   #   #
+#M  # M #  M#   #   #   #
+#   #   #   #   #   #   #
+#############   #   #   #
+#   #   #   #   #   #   #
+#   #   #   #   #   #   #
+#M  # M #  M#M  # M #  M#
+#########################

eg/small-cell.hunter

+#####
+#   #
+#   #
+#M  #
+#####
+##################
+#   1#2#         #
+# #### #         #
+#      #         #
+# ######    M    #
+#     M#         #
+#+######         #
+#     !#         #
+##################
+*12+>3
+*21+>3
+#######################
+#m   1111111111111    #
+#######################
+
+#######################
+#m   .............    #
+#######################
+
+*11>22
+*22>11
+*..>::
+*::>..
+#########
+#    M# #
+# ##### #
+#    M  #
+#       #
+#########
+####################
+#2#1+1#0+1#0+0#1+1##
+#!+0#0+1#1+0#1+1#0m#
+####################
+*00+>0
+*01+>1
+*10+>1
+*11+>0
+
+
+#!/usr/bin/perl
+
+# HUNTER - concurrent maze-space traversal language
+# v2002.01.26 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2002, 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. 
+
+# usage: [perl] hunter[.pl] [-no-eat] [-delay xxx] hunter-playfield-file
+# requirements: Curses, or ANSI terminal, or Win32 Console.
+
+# history: v2000.08.05 - started prototyping (from worb.pl).
+#          v2000.08.07 - added deterministic traversal.
+#                        mouse always tries: E, N, W, S.
+#          v2000.10.24 - cleaned up code, added rewriting.
+#          v2000.12.08 - added support for virtual console.
+#          v2000.12.15 - refined support for virtual console.
+#          v2001.01.24 - adapted to new virtual console modules.
+#          v2002.01.26 - fixed behaviour of eating of cheese
+#                        added command line options
+#                        does not rely on "\n" in screen driver
+
+# Uncomment this line to use a specific display driver.
+# BEGIN { $_Console::Virtual::setup{display} = 'ANSI'; }
+
+use _Console::Virtual 2001.0123
+     qw(getkey display gotoxy clrscr clreol
+        normal inverse bold update_display);
+
+### GLOBALS ###
+
+@mouse = ();
+@playfield = ();
+@mouse_at_cache = ();
+@rule = ();
+
+$x = 0; $y = 0;
+$no_eat = 0;     # compatibility flag
+$delay = 300;
+
+### SUBS ###
+
+sub draw_playfield
+{
+  gotoxy(1,1);
+  my $i; my $j; my $p;
+  for($j = 0; $j <= $maxy; $j++)
+  {
+    for($i = 0; $i <= $maxx; $i++)
+    {
+      if (is_mouse_at($i,$j))
+      {
+        display('m');
+      } else
+      {
+        display($playfield[$i][$j]);
+      }
+    }
+    gotoxy(1, $j+2);
+  }
+}
+
+sub is_mouse_at
+{
+  my $x = shift; my $y = shift;
+  return $mouse_at_cache[$x][$y] || 0;
+}
+
+sub vacant
+{
+  my $x = shift; my $y = shift;
+  return 0 if $playfield[$x][$y] eq '#';
+  return 0 if is_mouse_at($x,$y);
+  return 1;
+}
+
+### MAIN ###
+
+while ($ARGV[0] =~ /^\-\-?(.*?)$/)
+{
+  my $opt = $1;
+  shift @ARGV;
+  if ($opt eq 'no-eat')
+  {
+    $no_eat = 1;
+  }
+  elsif ($opt eq 'delay')
+  {
+    $delay = 0+shift @ARGV;
+  }
+  else
+  {
+    die "Unknown command-line option --$opt";
+  }
+}
+
+open PLAYFIELD, $ARGV[0];
+while(defined($line = <PLAYFIELD>))
+{
+  my $i;
+  chomp($line);
+  if ($line =~ /^\*(.*?)\>(.*?)$/)
+  {
+    push @rule, [$1, $2];
+  } else
+  {
+    for($i = 0; $i < length($line); $i++)
+    {
+      my $c = substr($line, $i, 1);
+      if (ucfirst($c) eq 'M')
+      {
+        $c = ' ';
+        push @mouse,
+        {
+          'x'     => $x,
+          'y'     => $y,
+          'been'  => [[]],
+          'seen'  => '',
+          'stack' => [ 1 ],
+          'dead'  => 0,
+          'out'   => '',
+        };
+        $mouse_at_cache[$x][$y] = 1;
+      }
+      $playfield[$x][$y] = $c;
+      $x++; if ($x > $maxx) { $maxx = $x; }
+    }
+    $x = 0;
+    $y++; if ($y > $maxy) { $maxy = $y; }
+  }
+}
+close PLAYFIELD;
+
+clrscr();
+
+draw_playfield();
+
+$start_time = time();
+$tick = 1;
+while(1)
+{
+  my $mouse;
+  my $pole;
+  my $deadmice = 0; # first time I've ever used THAT as a variable name! ;-)
+  foreach $mouse (@mouse)
+  {
+ResetMouse:
+
+    if ($mouse->{dead})
+    {
+      $deadmice++;
+      next;
+    }
+
+    my $tos = $mouse->{stack}[$#{$mouse->{stack}}];
+    my $new_x = 0; my $new_y = 0;
+
+    if ($tos < 5)
+    {
+      if ($tos == 1)
+      {
+        $new_x = $mouse->{x} + 1;
+        $new_y = $mouse->{y};
+      }
+      elsif ($tos == 2)
+      {
+        $new_x = $mouse->{x};
+        $new_y = $mouse->{y} - 1;
+      }
+      elsif ($tos == 3)
+      {
+        $new_x = $mouse->{x} - 1;
+        $new_y = $mouse->{y};
+      }
+      elsif ($tos == 4)
+      {
+        $new_x = $mouse->{x};
+        $new_y = $mouse->{y} + 1;
+      } else
+      {
+        die "Can't be!";
+      }
+
+      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}}]++;
+        next;
+      }
+
+      push @{$mouse->{stack}}, 1;
+      $mouse->{been}[$mouse->{x}][$mouse->{y}] = 1;
+    }
+    else
+    {
+      $tos = pop @{$mouse->{stack}};
+      if ($#{$mouse->{stack}} == -1)
+      {
+        $mouse->{been} = [[]];
+        push @{$mouse->{stack}}, 1;
+        goto ResetMouse;
+      }
+      $tos = $mouse->{stack}[$#{$mouse->{stack}}];
+      $mouse->{been}[$mouse->{x}][$mouse->{y}] = 0;
+      if ($tos == 1)
+      {
+        $new_x = $mouse->{x} - 1;
+        $new_y = $mouse->{y};
+      }
+      elsif ($tos == 2)
+      {
+        $new_x = $mouse->{x};
+        $new_y = $mouse->{y} + 1;
+      }
+      elsif ($tos == 3)
+      {
+        $new_x = $mouse->{x} + 1;
+        $new_y = $mouse->{y};
+      }
+      elsif ($tos == 4)
+      {
+        $new_x = $mouse->{x};
+        $new_y = $mouse->{y} - 1;
+      }
+      $mouse->{stack}[$#{$mouse->{stack}}]++;
+      if (not vacant($new_x, $new_y))
+      {
+        next;
+      }
+    }
+
+    if ($mouse->{out} =~ /^(.)/)
+    {
+      $playfield[$mouse->{x}][$mouse->{y}] = $1;
+      $mouse->{out} = $';
+    }
+
+    gotoxy($mouse->{x}+1, $mouse->{y}+1);
+    display($playfield[$mouse->{x}][$mouse->{y}]);
+    $mouse_at_cache[$mouse->{x}][$mouse->{y}] = 0;
+    $mouse->{x} = $new_x;
+    $mouse->{y} = $new_y;
+    $mouse_at_cache[$mouse->{x}][$mouse->{y}] = 1;
+    gotoxy($mouse->{x}+1, $mouse->{y}+1);
+    display('m');
+
+    my $item = $playfield[$mouse->{x}][$mouse->{y}];
+    if ($item eq '!')
+    {
+      $mouse->{dead} = 1;
+      $playfield[$mouse->{x}][$mouse->{y}] = 'w'; # mouse carcass
+      gotoxy($mouse->{x}+1, $mouse->{y}+1);
+      display($playfield[$mouse->{x}][$mouse->{y}]);
+    }
+    elsif ($item ne ' ')
+    {
+      $mouse->{seen} .= $item;
+      if ($item =~ /^\d$/)
+      {
+        $playfield[$mouse->{x}][$mouse->{y}] = ' ' unless $no_eat;
+      }
+    }
+
+    my $r; my $dr = 0;
+    while (not $dr)
+    {
+      $dr = 1;
+      foreach $r (@rule)
+      {
+        my $q = quotemeta($r->[0]);
+        if ($mouse->{seen} =~ /$q$/)
+        {
+          $mouse->{seen} = $`;
+          $mouse->{out} .= $r->[1];
+          $dr = 0;
+        }
+      }
+    }
+  }
+  if ($deadmice == $#mouse+1)
+  {
+    exit(0);
+  }
+  update_display();
+  for($i = 1; $i < $delay; $i++)
+  {
+    gotoxy(1,20);
+  }
+}
+
+### END of hunter.pl ###
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.