3 ! Release 8 / Serial number 220120 / Inform v6.35
5 ! [-] |\_/| http://www.robotfindskitten.org
6 ! (+)=C |o o|__ Leonard Richardson (C) 1997, 2000
7 ! | | --*--__\ David Griffith (C) 2002-2022 (Inform Edition)
11 ! This Zen simulation is based on the C version v1600003.248b
12 ! by Leonard Richardson (C) 1997, 2000.
13 ! Written originally for the Nerth Pork robotfindskitten contest.
14 ! Reimplemented in Inform by David Griffith (C) 2002.
16 ! Lots more information on robotfindskitten is available at
17 ! http://www.robotfindskitten.org.
19 ! This rendition of robotfindskitten is distributed under the Artistic
20 ! License 2.0. See the file LICENSE in the robotfindskitten repository
21 ! or https://opensource.org/licenses/Artistic-2.0 for more information.
23 ! In this game, you are Robot (#). Your job is to find Kitten. This
24 ! task is complicated by the existance of various things which are not
25 ! kitten. Robot must touch items to determine if they are Kitten or
26 ! not. Move Robot with the cursor keys, the numeric keypad, or
27 ! using the vi/rogue movement keys. The game ends when robotfindskitten.
28 ! Alternatively, you may end the game by hitting the Esc or Q keys.
31 ! 1) More than half of the code is taken up by non kitten items
32 ! (NKIs). When I compiled the code with just five messages and
33 ! no debugging code, the resulting binary was less than 10k bytes.
35 ! 2) If it wasn't already abundantly obvious, this program won't
36 ! compile to Glulx because of copious use of Z-machine assembly
39 ! 3) Compiling for V5 or higher is required due to "style" calls.
40 ! Is there a reason why someone would want to compile this for V4
48 Constant Nonkitten_Default 20;
50 ! Maxmimum possible number of non-kitten items on the playfield at once.
51 ! For whatever reason, this cannot be set dynamically.
53 Constant Nonkitten_Max 589;
58 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
60 Constant Story "robotfindskitten";
61 Constant Headline "^A Zen Simulation^";
63 ! NKIs are generated with nki2inf.pl and put into nki.inf
66 Constant Anim_Meet 10; ! Number of spaces from the left where
67 ! Robot and Kitten meet during animation.
69 Global Height = 0; ! These are set at runtime.
72 Global Back_def = 2; ! Black.
73 Global Fore_def = 9; ! White.
75 Global TopBar = 5; ! Lines from the top.
77 Global player_x = 0; ! Keeping track of where the player was
78 Global player_y = 0; ! 1 move ago allows us to keep the
79 Global player_x_last = 0; ! player from walking through obstacles.
80 Global player_y_last = 0;
84 Global kitten_char = 0;
85 Global kitten_color = 0;
87 Global last_message = ""; ! Always show the last-encountered message.
89 Global nonkitten_count;
91 Array nonkitten_x --> Nonkitten_Max;
92 Array nonkitten_y --> Nonkitten_Max;
93 Array nonkitten_color --> Nonkitten_Max;
94 Array nonkitten_char --> Nonkitten_Max;
95 Array nonkitten_msg --> Nonkitten_Max;
97 Global already_msg_count = 0;
98 Global already_count = 0;
99 Array already_x --> Nonkitten_Max + 2;
100 Array already_y --> Nonkitten_Max + 2;
101 Array already_msg --> Nonkitten_Max;
103 ! If a key is held down while the found_kitten animation is playing,
104 ! (0-->1) & $03ff gets corrupted. Seems like it might be a bug
105 ! somewhere in Unix Frotz.
107 Global Real_Release = 0;
110 @set_colour Fore_def Back_def;
112 if (MESSAGE_NUM < Nonkitten_Default) {
113 nonkitten_count = MESSAGE_NUM;
115 nonkitten_count = Nonkitten_Default;
118 Real_Release = (0-->1)&$03ff;
127 'F': already_count = 0;
133 'D': set_nonkitten_count();
134 'I': print_instructions();
136 'T': print_thoughts();
138 if (key == 'Q' || key == $1b) ! $1b == ESC
148 ! There's a 1:50 chance that the kitten in the title screen
149 ! will have a "psycho" appearance.
164 draw_big_robot(3, 7);
167 draw_big_kitten_psycho(14, 7);
169 draw_big_kitten(15, 7);
172 print "http://www.robotfindskitten.org";
174 print "Leonard Richardson (C) 1997, 2000";
176 print "David Griffith (C) 2002-2022 (Inform Edition)";
178 print " ", MESSAGE_NUM, " different nonkittens!";
182 print " F) Find Kitten^",
183 " D) Difficulty (", nonkitten_count, ")^",
192 ! Copied from module/verblibm.h of the Inform 6.21.3 standard library.
197 print (string) Story;
201 print (string) Headline;
203 print "Release ", Real_Release, " / Serial number ";
204 for (i=18:i<24:i++) print (char) 0->i;
205 print " / Inform v"; inversion; print "";
210 Constant INBUFSIZE 80;
211 Array inbuf -> INBUFSIZE;
213 [ set_nonkitten_count maxnum val;
222 if (MESSAGE_NUM < Nonkitten_Max) {
223 maxnum = MESSAGE_NUM;
225 maxnum = Nonkitten_Max;
228 print "^Please enter the number of nonkittens you
229 wish to search through.^(1 to ", maxnum, " only)^^> ";
232 val = get_number(1, maxnum, nonkitten_count);
236 nonkitten_count = val;
244 [ get_number min max init inbufvar ix cx len val;
246 inbuf->0 = (INBUFSIZE-3);
254 while (cx < len && inbuf->(2+cx) == ' ')
256 if (cx < len && inbuf->(2+cx) == '.')
259 ! If user just hits return, use what we have already.
262 if (cx == len || inbuf->(2+cx) < '0' || inbuf->(2+cx) > '9') {
263 print "Please enter a value from ", min, " to ", max,
264 ", or Enter by itself to exit.^
265 [Press any key to continue.] ";
270 while (cx < len && inbuf->(2+cx) >= '0' && inbuf->(2+cx) <= '9') {
271 val = val * 10 + (inbuf->(2+cx) - '0');
274 if (val < min || val > max) {
275 print "Please enter a value from ", min, " to ", max,
276 ", or Enter by itself to exit.^
277 [Press any key to continue.] ";
288 @split_window TopBar;
295 This Zen simulation is based on the C version v1600003.248b^
296 by Leonard Richardson (C) 1997, 2000.^
297 Written originally for the Nerth Pork robotfindskitten contest.^
298 Reimplemented in Inform by David Griffith (C) 2002.^
300 This code is distributed according to the Artistic License 2.0. See
301 https://opensource.org/licenses/Artistic-2.0 for more information. I,
302 David Griffith, retain copyright on this program except for the NKIs
303 imported from the master (aka POSIX) port.^
305 Lots more information on robotfindskitten is available at
306 http://www.robotfindskitten.org.^
308 To submit new NKI's, please go to the above URL.^
313 Release 1 / Serial number 0211xx to 021214 or so^
314 Initial private release. Limited distribution for beta testing and
317 Release 2 / Serial Number 021216^
318 First public release.^
320 Release 3 / Serial Number 021221^
322 - Movement keys 'J' and 'K' were swapped by mistake. Fixed.^
323 - Special PalmOS movement key support added.^
324 - More NKIs added (401 total).^
326 Release 4 / Serial Number 030131^
327 Light overhaul release.^
328 - Now an official port of robotfindskitten.^
329 - Typos in NKIs fixed.^
330 - Fixed diagonal collision-detection strangeness.^
331 - Added color support.^
332 - Added an easter egg. Can you find it?^
333 - Removed PalmOS movement key support (superfluous and ugly).^
334 - Removed playfield resizing code (superfluous and ugly).^
335 - It's ~robotfindskitten~, not ~Robot Finds Kitten~.^
336 - Merged in new NKIs from the new POSIX release of robotfindskitten.^
337 - More NKIs added (561 total).^
339 Release 5 / Serial Number 030524^
340 Even more NKIs release.^
341 - Idiotic typos fixed.^
342 - More NKIs added (602 total).^
344 Release 6 / Serial Number 031116^
346 - More NKIs added (764 total).^
347 - Increased maximum difficulty to 589.^
348 - Lots more comments in the source code.^
349 - Assorted cleanups in the source code.^
351 Release 7 / Serial Number 130320^
353 - Synchronized NKIs and removed redundancies with the POSIX port.^
354 - NKIs now generated from an external file using nki2inf.pl.^
355 - NKIs reduced to 723 because of redundancies and recommended deletions.^
357 Release 8 / Serial Number 220120^
358 - Twenty Year Anniversary release.^
359 - Fixed a problem that crashed some interpreters when robotfindskitten.^
360 - Fixed a potential problem of wrongly determining screen size.^
361 - Now distributed under the Artistic License 2.0.^
366 1) I still don't know why already_seen_xy() occasionally causes Robot to
367 get placed on top of another object when a game is started. Fortunately
368 this seems to happen only very rarely and typically only if the
369 difficulty is set to more than 200. This bug also seems to very
370 occasionally put Kitten underneath an NKI.^
372 2) Under earlier versions of Windows Frotz, Robot used to appear as a
373 solid block. This was because of a bug in Windows Frotz which
374 incorrectly makes the cursor opaque. The cursor is now moved off to
375 the upper-right corner so that the game looks okay on terminals that use
376 something other than reverse for the cursor. I still can't figure out
377 how to make Inform hide the cursor completely. At least on xterm and
378 NetBSD's console, @@64set_cursor -1 doesn't work.^
380 3) Under Windows Frotz, an annoying [MORE] prompt might appear at the
381 main menu. This is another bug in Windows Frotz which causes the
382 interpreter to follow Windows' suggestion that something less than 24 or
385 [Press any key to continue.] ";
390 [ print_instructions;
392 @split_window TopBar;
398 In this game, you are Robot ( ";
399 style reverse; print "#"; style roman;
400 print " ). Your job is to find Kitten. This task is complicated by the
401 existance of various things which are not Kitten. Robot must touch
402 items to determine if they are Kitten or not. Move Robot with the
403 cursor keys, the numeric keypad (make sure numlock is on), or using the
404 vi/rogue/nethack movement keys. The game ends when robotfindskitten.
405 Alternatively, you may end the game by hitting the Esc or Q keys.^
407 [Press any key to continue.] ";
414 @split_window TopBar;
422 Day and night I feverishly worked upon the machine, creating both a soul
423 which could desire its goal, and a body with which it could realize
424 it. Many who saw my creation called it an abomination, and denied me
425 grant money. But they could not dissuade me from my impossible
426 task. It was a spectre that tormented me always, a ghost I had to give
427 a form and a life, lest it consume me from the inside. And when at last
428 my task was done, when the grey box on wheels was complete and when it,
429 as well as I, knew what had to be done, I felt deep sympathy for the
430 machine. For I had not destroyed the phantom, but merely exorcized it
431 into another body. The robot knew not why this task had to be
432 performed, for I could not imbue it with knowledge I did not myself
433 posess. And at the same time, I felt a sweeping sense of relief sweep
434 over me, that somehow, the dream that had driven me for my entire life
435 had come one step closer to fruition.^
437 ~Gort, Klaatu Verada Nikto~^
439 As I vocally activated the robot, I realized that it was following my
440 instructions, but not out of any desire to obey me. Had I remained
441 silent, it would have performed exactly the same operations. We were
442 two beings controlled by the same force now. And yet, seeking vainly to
443 hold some illusion of control over the machine I thought I had created,
444 I gave my final command.^
446 ~GO!~ I told the box as it began to roll out of my workshop into the
447 frozen desert beyond. ~FIND KITTEN!~^
449 -- The Book of Found Kittens, pages 43-4, author unknown.^
451 [Press any key to continue.] ";
456 [ draw_big_robot x y;
462 @set_colour 6 Back_def;
464 @set_colour 4 Back_def;
466 @set_colour 6 Back_def;
471 @set_colour 6 Back_def;
473 @set_colour 3 Back_def;
475 @set_colour 6 Back_def;
477 @set_colour 8 Back_def;
482 @set_colour 6 Back_def;
487 @set_colour 8 Back_def;
490 @set_colour Fore_def Back_def;
494 [ draw_big_kitten x y;
501 @set_colour 5 Back_def;
502 print "|", (char) 92, "_/|";
506 @set_colour 4 Back_def;
508 @set_colour 5 Back_def;
512 @set_colour 9 Back_def;
514 @set_colour 3 Back_def;
516 @set_colour 9 Back_def;
518 @set_colour 5 Back_def;
519 print "__", (char) 92;
524 @set_colour Fore_def Back_def;
528 [ draw_big_kitten_psycho x y;
535 @set_colour 5 Back_def;
536 print " |", (char) 92, "_/|";
539 @set_colour 4 Back_def;
541 @set_colour 5 Back_def;
545 @set_colour 9 Back_def;
547 @set_colour 3 Back_def;
549 @set_colour 9 Back_def;
551 @set_colour 5 Back_def;
552 print "__", (char) 92;
557 @set_colour Fore_def Back_def;
561 ! Something gets messed up if I make this local to findkitten()
562 ! When going right or left, then up or down to hit the Kitten, the
563 ! animation gets reversed.
565 Global last_right = false;
569 @split_window TopBar;
574 print (string) last_message;
577 draw_object(kitten_x, kitten_y, kitten_char, kitten_color);
581 draw_object(player_x, player_y, '#');
592 player_x_last = player_x;
593 player_y_last = player_y;
595 'Q', $1b: rfalse; ! exit game ($1b == Esc)
596 '8', 'K', 129: player_y--; ! up
597 '2', 'J', 130: player_y++; ! down
598 '4', 'H', 131: player_x--; ! left
600 '6', 'L', 132: player_x++; ! right
603 '7', 'Y': player_y--; player_x--; ! up-left
605 '9', 'U': player_y--; player_x++; ! up-right
607 '1', 'B': player_y++; player_x--; ! down-left
609 '3', 'N': player_y++; player_x++; ! down-right
613 ! Keep Robot from falling off edges of playfield.
615 if (player_y == TopBar || player_y > Height) {
616 player_y = player_y_last;
618 if (player_x < 1 || player_x > Width) {
619 player_x = player_x_last;
622 ! Detect and handle collisions.
624 if (player_x == kitten_x && player_y == kitten_y) {
625 animate_kitten(key, last_right);
629 for (i = 0: i < nonkitten_count: i++) {
630 if (player_x == nonkitten_x-->i
631 && player_y == nonkitten_y-->i) {
633 last_message = lookup_msg(nonkitten_msg-->i);
634 player_x = player_x_last;
635 player_y = player_y_last;
642 [ animate_kitten key my_last_right i j junk robot_x anim_finished;
644 '8', 'J', 129: player_y++;
645 '2', 'K', 130: player_y--;
646 '4', 'H', 131: player_x++;
647 '6', 'L', 132: player_x--;
648 '7', 'Y': player_y++; player_x++;
649 '9', 'U': player_y++; player_x--;
650 '1', 'B': player_y--; player_x++;
651 '3', 'N': player_y--; player_x--;
654 anim_finished = false;
655 for (i = 4: i >= 0: i--) {
657 @split_window TopBar;
666 robot_x = Anim_Meet - i;
668 draw_object(robot_x, TopBar - 1, '#');
670 draw_object(Anim_Meet - 1 + i, TopBar - 1,
671 kitten_char, kitten_color);
673 robot_x = Anim_Meet - 1 + i;
675 draw_object(robot_x, TopBar - 1, '#');
677 draw_object(Anim_Meet - i, TopBar - 1,
678 kitten_char, kitten_color);
683 print "You found Kitten! Way to go, Robot!";
684 anim_finished = true;
687 draw_object(kitten_x, kitten_y, kitten_char, kitten_color);
690 draw_object(player_x, player_y, '#');
694 if (anim_finished == false) {
697 @read_char 1 10 pause -> junk;
698 @nop; ! This is for padding.
701 draw_object(player_x, player_y, '#');
709 [ already_seen_xy x y i;
710 for (i = 0: i < already_count: i++) {
711 if (already_x-->already_count == x &&
712 already_y-->already_count ==y) {
716 already_x-->already_count = x;
717 already_y-->already_count = y;
729 kitten_x = get_random_x();
730 kitten_y = get_random_y();
731 kitten_color = get_random_color();
732 while (already_seen_xy(kitten_x, kitten_y) == true) {
733 kitten_x = get_random_x();
734 kitten_y = get_random_y();
736 kitten_char = get_random_char();
741 player_x = get_random_x();
742 player_y = get_random_y();
743 while (already_seen_xy(player_x, player_y) == true) {
744 player_x = get_random_x();
745 player_y = get_random_y();
751 already_msg_count = 0;
753 for (i = 0: i < nonkitten_count: i++) {
754 nonkitten_x-->i = get_random_x();
755 nonkitten_y-->i = get_random_y();
756 nonkitten_color-->i = get_random_color();
757 while (already_seen_xy(nonkitten_x-->i,
758 nonkitten_y-->i) == true) {
759 nonkitten_x-->i = get_random_x();
760 nonkitten_y-->i = get_random_y();
762 nonkitten_char-->i = get_random_char();
763 nonkitten_msg-->i = get_random_msg();
769 for (i = 0: i < nonkitten_count: i++) {
770 draw_object(nonkitten_x-->i,
773 nonkitten_color-->i);
778 [ draw_object x y character fore back;
786 @set_colour fore Back_def;
788 print (char) character;
790 @set_colour Fore_def Back_def;
796 for (i = 0 : i < Width : i++)
803 if (x >= 'a' && x <= 'z')
809 [ get_random_char num;
812 while (num == 35) { ! avoid choosing '#'
820 [ get_random_msg num;
821 num = random(MESSAGE_NUM);
822 while (is_duplicate_msg(num) == true || num > MESSAGE_NUM || num < 1) {
823 num = random(MESSAGE_NUM);
829 [ get_random_color num;
831 ! 0 and 1 are default color and current color
832 ! and we want to avoid picking the default color explicitly
833 while (num == $2c-->0) {
840 [ is_duplicate_msg num i;
841 for (i = 0: i < already_msg_count: i++) {
842 if (already_msg-->i==num) {
846 already_msg-->already_msg_count = num;
853 ! Maybe this will need to do something more in the future.
854 return random(Width);
859 ! Make sure we don't draw in the status bar.
861 num = random(Height);