git @ Cat's Eye Technologies noit-o-mnain-worb / eebc215
Import of worb sources, version 1.1 revision 2007.1123. Cat's Eye Technologies 12 years ago
3 changed file(s) with 123 addition(s) and 117 deletion(s). Raw diff Collapse all Expand all
+0
-32
doc/license.txt less more
0 Copyright (c)2000, Cat's Eye Technologies.
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6
7 Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9
10 Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in
12 the documentation and/or other materials provided with the
13 distribution.
14
15 Neither the name of Cat's Eye Technologies nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20 CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
27 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 POSSIBILITY OF SUCH DAMAGE.
00 <html><head>
11 <meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1">
2 <meta name="Description" content="Cat's Eye Technologies: The "noit o' mnain worb" Language">
2 <meta name="Description" content="Cat's Eye Technologies: The 'noit o' mnain worb' Language">
33 <title>Cat's Eye Technologies: The "noit o' mnain worb" Language</title>
44 <meta name="Keywords" content=" Cat's Eye Technologies Language
55 Programming computational computation non-deterministic
77 nondeterminstic fungeoid funge befunge experimental ">
88 </head>
99 <body>
10 <center>
1110 <h1>noit o' mnain worb</h1>
12 </center><p><font size=-1>Version 1.1</font> <font size=-1>&nbsp;<img src="/images/icons/copyright.gif"
13 align=absmiddle width=12 height=12 alt="(c)" border=0>2000-2004 <a href="/">Cat's Eye Technologies</a>. All rights reserved.<br>
14 This software is OSI Certified Open Source Software.<br>
15 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>
16 See the file <a href="license.txt">license.txt</a> for license information.</font>
17 <hr>
1811
19 <h3>What is <u>noit o' mnain worb</u>?</h3>
12 <p>Language version 1.1. Distribution version 2007.1123.<br>
13 Copyright &copy;2000-2007, Cat's Eye Technologies. All rights reserved.</p>
14
15 <h2>What is <u>noit o' mnain worb</u>?</h2>
2016
2117 <p>The <u>noit o' mnain worb</u> language is a
2218 non-deterministic particle automaton based on brownian motion (or entropy).
4743 <li> <tt>!</tt> <i>loads</i> which represent something that the bobules can 'do'.
4844 </ul></p>
4945
50 <h3>Notes</h3>
46 <h2>Notes</h2>
5147
5248 <p>[Historical note: In version 1.0 (Jul 5 2000) of the language, which was released only
5349 on the Cat's Eye Technologies Mailing List,
0 #/usr/local/bin/perl -w
0 #!/usr/bin/perl -w
11
22 # noit o' mnain worb - fungeoid language based on brownian motion
3 # v1.1 Jul 19 2000 Chris Pressey, Cat's Eye Technologies
4
5 # Copyright (c)2000, Cat's Eye Technologies.
3 # v2007.1123 Chris Pressey, Cat's Eye Technologies
4
5 # Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
66 # All rights reserved.
7 #
7 #
88 # Redistribution and use in source and binary forms, with or without
99 # modification, are permitted provided that the following conditions
1010 # are met:
11 #
12 # Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 #
15 # Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in
17 # the documentation and/or other materials provided with the
18 # distribution.
19 #
20 # Neither the name of Cat's Eye Technologies nor the names of its
21 # contributors may be used to endorse or promote products derived
22 # from this software without specific prior written permission.
23 #
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25 # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
26 # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 # DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
29 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
32 # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
33 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 # POSSIBILITY OF SUCH DAMAGE.
37
38 # usage: [perl] worb[.pl] worb-playfield-file
11 #
12 # 1. Redistributions of source code must retain the above copyright
13 # notices, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notices, this list of conditions, and the following disclaimer in
16 # the documentation and/or other materials provided with the
17 # distribution.
18 # 3. Neither the names of the copyright holders nor the names of their
19 # contributors may be used to endorse or promote products derived
20 # from this software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34
35 # usage: [perl] worb[.pl] [-delay ms] worb-playfield-file
3936 # requirements: ANSI terminal emulation, for animation.
4037
4138 # history: v1.0 Jul 5 2000 - original release.
4340 # optimized display routine for ANSI
4441 # optimized is_bobule_at (cached)
4542 # relicensed & released on web site
43 # v2007.1123 - adapted to use Console::Virtual
44 # - added strict qw(vars refs subs)
45 # - added delay in ms cmdline option
46 # - fixed hashbang line
47 # - updated BSD license (no "REGENTS")
48
49 use strict qw(vars refs subs);
50
51 # This allows us to keep Console::Virtual in same directory as script
52 BEGIN { use File::Basename; push @INC, dirname($0); }
53
54 # Uncomment these lines to use specific display/input/color drivers.
55 # BEGIN { $Console::Virtual::setup{display} = 'ANSI'; }
56 # BEGIN { $Console::Virtual::setup{input} = 'Teletype'; }
57 # BEGIN { $Console::Virtual::setup{color} = 'ANSI16'; }
58
59 use Console::Virtual 2007.1122
60 qw(getkey display gotoxy clrscr clreol
61 normal inverse bold update_display color);
62
63 # This lets us do sub-second sleeps, if Time::HiRes is available.
64 my $sleep = sub($) { sleep(shift); };
65 my $found_time_hires = 0;
66 foreach my $c (@INC)
67 {
68 $found_time_hires = 1 if -r "$c/Time/HiRes.pm";
69 }
70 if ($found_time_hires) {
71 require Time::HiRes;
72 $sleep = sub($) { Time::HiRes::sleep(shift); };
73 }
4674
4775 ### GLOBALS ###
4876
49 @bobule = ();
50 @source = ();
51 @sink = ();
52 @playfield = ();
53
54 @bobule_at_cache = ();
55
56 $x = 0; $y = 0;
77 my @bobule = ();
78 my @source = ();
79 my @sink = ();
80 my @playfield = ();
81
82 my @bobule_at_cache = ();
83
84 my $x = 0;
85 my $y = 0;
86
87 my $maxx = 1;
88 my $maxy = 1;
89
90 my $delay = 100;
5791
5892 ### SUBS ###
5993
6094 sub draw_playfield
6195 {
62 printf "%c[1;1H", 27; # gotoxy 1,1
6396 my $i; my $j; my $p;
6497 for($j = 0; $j <= $maxy; $j++)
6598 {
99 gotoxy(1, $j+1);
66100 for($i = 0; $i <= $maxx; $i++)
67101 {
68102 if ($p = is_bobule_at($i,$j))
69103 {
70 if ($p == 1) { print '.'; }
71 elsif ($p >= 2 and $p <= 3) { print 'o'; }
72 elsif ($p >= 4 and $p <= 6) { print 'O'; }
73 elsif ($p >= 7 and $p <= 10) { print '0'; }
74 else { print '@'; }
104 if ($p == 1) { display '.'; }
105 elsif ($p >= 2 and $p <= 3) { display 'o'; }
106 elsif ($p >= 4 and $p <= 6) { display 'O'; }
107 elsif ($p >= 7 and $p <= 10) { display '0'; }
108 else { display '@'; }
75109 } else
76110 {
77 print $playfield[$i][$j];
111 display($playfield[$i][$j] or ' ');
78112 }
79113 }
80 print "\n";
81114 }
82115 }
83116
108141
109142 ### MAIN ###
110143
144 while ($ARGV[0] =~ /^\-\-?(.*?)$/)
145 {
146 my $opt = $1;
147 shift @ARGV;
148 if ($opt eq 'delay')
149 {
150 $delay = 0+shift @ARGV;
151 }
152 else
153 {
154 die "Unknown command-line option --$opt";
155 }
156 }
157
158 my $line;
159
111160 open PLAYFIELD, $ARGV[0];
112161 while(defined($line = <PLAYFIELD>))
113162 {
138187 }
139188 close PLAYFIELD;
140189
141 printf "%c[2J", 27; # clear screen
142
190 clrscr();
191 color('white', 'black');
143192 draw_playfield();
144
145 $start_time = time();
146 $tick = 1;
147 while(1)
193 update_display();
194
195 my $new_x;
196 my $new_y;
197
198 while (1)
148199 {
149200 my $bobule; my $pole;
150201 foreach $bobule (@bobule)
153204 if ($bobule->[2] == 2 or $bobule->[2] == 4 or $bobule->[2] == 7 or $bobule->[2] == 11)
154205 {
155206 my $p = $bobule->[2];
156 printf "%c[%d;%dH", 27, $bobule->[1]+1, $bobule->[0]+1;
157 if ($p == 2) { print 'o'; }
158 elsif ($p == 4) { print 'O'; }
159 elsif ($p == 7) { print '0'; }
160 elsif ($p == 11) { print '@'; }
207 gotoxy($bobule->[0]+1, $bobule->[1]+1);
208 if ($p == 2) { display 'o'; }
209 elsif ($p == 4) { display 'O'; }
210 elsif ($p == 7) { display '0'; }
211 elsif ($p == 11) { display '@'; }
161212 }
162213 $new_x = $bobule->[0] + int(rand(1) * 3)-1;
163214 $new_y = $bobule->[1] + int(rand(1) * 3)-1;
168219 next if $playfield[$new_x][$new_y] eq 'v' and $bobule->[1] > $new_y;
169220 next if $new_x == $bobule->[0] and $new_y == $bobule->[1];
170221 print chr(7) if $playfield[$new_x][$new_y] eq '!';
171 printf "%c[%d;%dH%s", 27, $bobule->[1]+1, $bobule->[0]+1,
172 $playfield[$bobule->[0]][$bobule->[1]];
222 gotoxy($bobule->[0]+1, $bobule->[1]+1);
223 display $playfield[$bobule->[0]][$bobule->[1]];
173224 $bobule_at_cache[$bobule->[0]][$bobule->[1]] = 0;
174225 $bobule->[0] = $new_x;
175226 $bobule->[1] = $new_y;
176227 $bobule_at_cache[$bobule->[0]][$bobule->[1]] = 1;
177 printf "%c[%d;%dH.", 27, $bobule->[1]+1, $bobule->[0]+1;
228 gotoxy($bobule->[0]+1, $bobule->[1]+1);
229 display '.';
178230 $bobule->[2] = 1;
179231 }
180232 foreach $pole (@source)
194246 $bobule[$q] = $bobule[$#bobule]; pop @bobule;
195247 }
196248 }
197 # track_time();
198 }
199
200 sub track_time
201 {
202 $tick++;
203 if ($tick > 1000)
204 {
205 $total_time = time() - $start_time;
206 $fps = int(1000 / $total_time);
207 die "Total time: $total_time seconds, approx fps: $fps\n";
208 }
249 update_display();
250 &$sleep($delay / 1000);
209251 }
210252
211253 ### END ###