Commits

Anonymous committed bdd7d85

Initial import of noit o' mnain worb 1.1 revision 2000.0719.

  • Participants
  • Tags rel_1_1_2000_0719

Comments (0)

Files changed (14)

+Copyright (c)2000, 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. 
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1">
+    <meta name="Description" content="Cat's Eye Technologies: The "noit o' mnain worb" Language">
+    <title>Cat's Eye Technologies: The "noit o' mnain worb" Language</title>
+<meta name="Keywords" content=" Cat's Eye Technologies Language
+ Programming computational computation non-deterministic
+ bobule concurrency constraint-based physics mechanics electronics
+ nondeterminstic fungeoid funge befunge experimental ">
+</head>
+<body>
+<center>
+<h1>noit o' mnain worb</h1>
+</center><p><font size=-1>Version 1.1</font> <font size=-1>&nbsp;<img src="/images/icons/copyright.gif"
+   align=absmiddle width=12 height=12 alt="(c)" border=0>2000-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>
+<hr>
+
+<h3>What is <u>noit o' mnain worb</u>?</h3>
+
+<p>The <u>noit o' mnain worb</u> language is a
+non-deterministic particle automaton based on brownian motion (or entropy).
+
+<p>A <u>noit o' mnain worb</u> runtime has an orthogonal gridwork
+playfield (of any reasonable size or number of dimensions)
+which is populated by any number of <i>bobules</i>.  Bobules are <i>solid</i>
+elements in this grid - that is, no two bobules may occupy the same location.
+Bobules are also capable of motion - in fact they can hardly avoid it - and it is
+important to note that they are stateless.  As such, they have no idea which
+direction they are going, nor what they are going to do when they get there.</p>
+
+<p>Each time quantum, or <i>tick</i>, each bobule chooses an adjacent square
+to move to, at random (in two dimensions, that's 8 possibilities
+plus the possibility of not moving = 9 possibilities.)
+If, during some tick, this randomly-chosen new location does not allow entry -
+that is, if it is already occupied by a solid element (a bobule or a wall) - the
+bobule does not move during that tick.</p>
+
+<p>[Implementation note: each tick that a bobule is blocked from moving,
+its "pressure" increases, although this is merely for visual effect.]</p>
+
+<p>The playfield is made more interesting by the addition of:
+<ul>
+<li> <tt>#</tt> <i>walls</i> which are merely static solid elements that take up space and do not move;
+<li> <tt>^v&gt;&lt;</tt> <i>diodes</i> which disallow bobules from passing through them backwards;
+<li> <tt>+-</tt> <i>sources & sinks</i> which represent large repositories or vacancies of bobules; and
+<li> <tt>!</tt> <i>loads</i> which represent something that the bobules can 'do'.
+</ul></p>
+
+<h3>Notes</h3>
+
+<p>[Historical note: In version 1.0 (Jul 5 2000) of the language, which was released only
+on the Cat's Eye Technologies Mailing List,
+<tt>+-</tt> had much different (and much more myopic)
+semantics than they do in v1.1.]</p>
+
+<p>The sources and sinks are simply convenient 'macros', so that you can
+build something like:</p>
+
+<pre>
+  ###
+###+###
+</pre>
+
+<p>instead of saying something like:</p>
+
+<pre>
+#######
+#.....#
+#.....#
+#.....#
+###.###
+  #.#
+###v###
+</pre>
+
+<p>Using the <tt>+</tt> sources and <tt>-</tt> sinks simply saves you
+from specifying large chambers of bobules or emptiness explicitly.</p>
+
+<p>[Implementation note: It is not the intention of the <tt>+</tt> element
+to violate entropy, but the fact that, in the reference implementation, <tt>+</tt>
+keeps producing bobules indefinately at a uniform rate of 10% chance per tick
+does bend the rules a bit.  In a more "entropically correct" implementation, the
+chance per tick should decrease over time.  Note that the language proper
+does not specify any particular rate of bobule creation, but encourages
+implementations to be flexible on this point.]</p>
+
+<p>The <tt>!</tt> loads simply cause the implementation to react in some
+noticable way when a bobule enters into their location, so that the
+<u>noit o' mnain worb</u> programmer can pretend to themselves that their
+bobules are 'doing something' during program runs.</p>
+
+<p>[Implementation note: The reference interpreter simply outputs an ASCII
+BEL character when this happens.  On most terminals, this affects a beeping
+sound.]</p>
+
+<p>The idea is that the bobules, spaces, walls, and diodes alone constitute a (nearly)
+Turing-Complete system.</p>
+
+<p>I say "nearly" because it's actually missing a dimension in this form.  The
+<u>noit o' mnain worb</u> language isn't dimensionally-independent.
+Notably, it doesn't work in one dimension at all.</p>
+
+<p>It <i>almost</i> works in two dimensions, but the fact is that if you do not address
+the 'wire-crossing problem' (see <a href="/projects/befunge93/">Befunge-93</a>'s
+<tt>#</tt> instruction), you cannot
+guarantee being able to connect two arbitrarily-chosen paths in two dimensions.
+You need to have a way for coincident paths to cross, which is not strictly
+just two dimensions anymore.</p>
+
+<p>[Theoretical note: we suspect, but would surely have a hard time proving,
+that this limitation is somehow related to the four-colour map theorem.]</p>
+
+<p>So, it really only works in three dimensions and above.  For that reason,
+adding 'wormholes' to the <u>noit o' mnain worb</u> playfield is a possible
+extension in the near future, to simulate three dimensions a la 'wire crossing'.</p>
+
+</body></html>
+############
+#..........#
+#######v####
+      #    #
+      #v####
+      #    #
+      #v####
+      #    #
+      #v####
+      #    #
+      ######

eg/fast-loop.worb

+#######
+# < < #
+# ### #
+# >.> #
+#######
+######################
+#                    #
+#                    #
+#                    #
+#                    #
+#                    #
+#         +          #
+#                    #
+#                    #
+#                    #
+#                    #
+######################
+     #########
+     #! ! ! !#
+###### ! ! ! ######
+#+    ! ! ! !    -#
+###### ! ! ! ######
+     #! ! ! !#
+     #########

eg/magnetic-field.worb

+######################
+#                    #
+#                    #
+#                    #
+#                    #
+#         -          #
+#         +          #
+#                    #
+#                    #
+#                    #
+#                    #
+######################
+#####         #####
+#   ###########   #
+# . >         < . #
+#   #####v#####   #
+#####   #  ########
+        #       >!#
+        #v#########
+        # #
+        ###
+#######################
+#..........>          #
+#######################

eg/slow-loop.worb

+#####################
+#        <          #
+# ################# #
+# #               # #
+# #               #.#
+# #               # #
+# ################# #
+#         >         #
+#####################

eg/subtraction.worb

+###############
+#.............#
+#######v#######
+      #       #
+      #########
+

eg/theory-of-time.worb

+######################
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+#..........          #
+######################

eg/transistor.worb

+    ###
+### #+#
+#+# # #
+# ###v#
+#   < #
+### < #
+  # < #
+  ###v#
+    # #
+    #!#
+    #-#
+    ###
+
+#/usr/local/bin/perl -w
+
+# noit o' mnain worb - fungeoid language based on brownian motion
+# v1.1 Jul 19 2000 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2000, 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] worb[.pl] worb-playfield-file
+# requirements: ANSI terminal emulation, for animation.
+
+# history: v1.0 Jul  5 2000 - original release.
+#          v1.1 Jul 19 2000 - changed + and -
+#                             optimized display routine for ANSI
+#                             optimized is_bobule_at (cached)
+#                             relicensed & released on web site
+
+### GLOBALS ###
+
+@bobule = ();
+@source = ();
+@sink = ();
+@playfield = ();
+
+@bobule_at_cache = ();
+
+$x = 0; $y = 0;
+
+### SUBS ###
+
+sub draw_playfield
+{
+  printf "%c[1;1H", 27;  # gotoxy 1,1
+  my $i; my $j; my $p;
+  for($j = 0; $j <= $maxy; $j++)
+  {
+    for($i = 0; $i <= $maxx; $i++)
+    {
+      if ($p = is_bobule_at($i,$j))
+      {
+        if ($p == 1) { print '.'; }
+        elsif ($p >= 2 and $p <= 3) { print 'o'; }
+        elsif ($p >= 4 and $p <= 6) { print 'O'; }
+        elsif ($p >= 7 and $p <= 10) { print '0'; }
+        else { print '@'; }
+      } else
+      {
+        print $playfield[$i][$j];
+      }
+    }
+    print "\n";
+  }
+}
+
+sub is_bobule_at
+{
+  my $x = shift; my $y = shift;
+  return $bobule_at_cache[$x][$y] || 0;
+}
+
+sub get_bobule_number_at
+{
+  my $x = shift; my $y = shift;
+  my $i;
+  for ($i = 0; $i <= $#bobule; $i++)
+  {
+    return $i if $bobule[$i][0] == $x and $bobule[$i][1] == $y;
+  }
+  return undef;
+}
+
+sub vacant
+{
+  my $x = shift; my $y = shift;
+  return 0 if $playfield[$x][$y] eq '#';
+  return 0 if is_bobule_at($x,$y);
+  return 1;
+}
+
+### MAIN ###
+
+open PLAYFIELD, $ARGV[0];
+while(defined($line = <PLAYFIELD>))
+{
+  my $i;
+  chomp($line);
+  for($i = 0; $i < length($line); $i++)
+  {
+    my $c = substr($line, $i, 1);
+    if ($c eq '.')
+    {
+      $c = ' ';
+      push @bobule, [$x, $y, 1];
+      $bobule_at_cache[$x][$y] = 1;
+    }
+    elsif ($c eq '+')
+    {
+      push @source, [$x, $y];
+    }
+    elsif ($c eq '-')
+    {
+      push @sink, [$x, $y];
+    }
+    $playfield[$x][$y] = $c;
+    $x++; if ($x > $maxx) { $maxx = $x; }
+  }
+  $x = 0;
+  $y++; if ($y > $maxy) { $maxy = $y; }
+}
+close PLAYFIELD;
+
+printf "%c[2J", 27;  # clear screen
+
+draw_playfield();
+
+$start_time = time();
+$tick = 1;
+while(1)
+{
+  my $bobule; my $pole;
+  foreach $bobule (@bobule)
+  {
+    $bobule->[2]++;
+    if ($bobule->[2] == 2 or $bobule->[2] == 4 or $bobule->[2] == 7 or $bobule->[2] == 11)
+    {
+      my $p = $bobule->[2];
+      printf "%c[%d;%dH", 27, $bobule->[1]+1, $bobule->[0]+1;
+      if ($p == 2) { print 'o'; }
+      elsif ($p == 4) { print 'O'; }
+      elsif ($p == 7) { print '0'; }
+      elsif ($p == 11) { print '@'; }
+    }
+    $new_x = $bobule->[0] + int(rand(1) * 3)-1;
+    $new_y = $bobule->[1] + int(rand(1) * 3)-1;
+    next if not vacant($new_x, $new_y);
+    next if $playfield[$new_x][$new_y] eq '<' and $bobule->[0] < $new_x;
+    next if $playfield[$new_x][$new_y] eq '>' and $bobule->[0] > $new_x;
+    next if $playfield[$new_x][$new_y] eq '^' and $bobule->[1] < $new_y;
+    next if $playfield[$new_x][$new_y] eq 'v' and $bobule->[1] > $new_y;
+    next if $new_x == $bobule->[0] and $new_y == $bobule->[1];
+    print chr(7) if $playfield[$new_x][$new_y] eq '!';
+      printf "%c[%d;%dH%s", 27, $bobule->[1]+1, $bobule->[0]+1,
+        $playfield[$bobule->[0]][$bobule->[1]];
+    $bobule_at_cache[$bobule->[0]][$bobule->[1]] = 0;
+    $bobule->[0] = $new_x;
+    $bobule->[1] = $new_y;
+    $bobule_at_cache[$bobule->[0]][$bobule->[1]] = 1;
+    printf "%c[%d;%dH.", 27, $bobule->[1]+1, $bobule->[0]+1;
+    $bobule->[2] = 1;
+  }
+  foreach $pole (@source)
+  {
+    if (not is_bobule_at($pole->[0], $pole->[1]) and rand(1) < .1)
+    {
+      push @bobule, [$pole->[0], $pole->[1], 1];
+      $bobule_at_cache[$pole->[0]][$pole->[1]] = 1;
+    }
+  }
+  foreach $pole (@sink)
+  {
+    if (is_bobule_at($pole->[0], $pole->[1]) and rand(1) < .1)
+    {
+      my $q = get_bobule_number_at($pole->[0], $pole->[1]);
+      $bobule_at_cache[$pole->[0]][$pole->[1]] = 0;
+      $bobule[$q] = $bobule[$#bobule]; pop @bobule;
+    }
+  }
+  # track_time();
+}
+
+sub track_time
+{
+  $tick++;
+  if ($tick > 1000)
+  {
+    $total_time = time() - $start_time;
+    $fps = int(1000 / $total_time);
+    die "Total time: $total_time seconds, approx fps: $fps\n";
+  }
+}
+
+### END ###