3 ! Release 7 / Serial number 121119 / Inform v6.32
5 ! [-] |\_/| http://www.robotfindskitten.org
6 ! (+)=C |o o|__ Leonard Richardson (C) 1997, 2000
7 ! | | --*--__\ David Griffith (C) 2002 (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.
20 ! In this game, you are Robot (#). Your job is to find Kitten. This
21 ! task is complicated by the existance of various things which are not
22 ! kitten. Robot must touch items to determine if they are Kitten or
23 ! not. Move Robot with the cursor keys, the numeric keypad, or
24 ! using the vi/rogue movement keys. The game ends when robotfindskitten.
25 ! Alternatively, you may end the game by hitting the Esc or Q keys.
27 ! Developed with Inform 6.21.4 as installed from NetBSD's pkgsrc tree
32 ! 1) More than half of the code is taken up by non kitten items
33 ! (NKIs). When I compiled the code with just five messages and
34 ! no debugging code, the resulting binary was less than 10k bytes.
36 ! 2) If it wasn't already abundantly obvious, this program won't
37 ! compile to Glulx because of copious use of Z-machine assembly
40 ! 3) Compiling for V5 or higher is required due to "style" calls.
41 ! Is there a reason why someone would want to compile this for V4
49 Constant Nonkitten_Default 20;
51 ! Maxmimum possible number of non-kitten items on the playfield at once.
52 ! For whatever reason, this cannot be set dynamically.
54 Constant Nonkitten_Max 589;
57 Serial "121119"; ! Presumed release date
59 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
61 Constant Story "robotfindskitten";
62 Constant Headline "^A Zen Simulation^";
64 ! NKIs are generated with nki2inf.pl and put into nki.inf
67 Constant Anim_Meet 10; ! Number of spaces from the left where
68 ! Robot and Kitten meet during animation.
70 Global Height = 0; ! These are set at runtime.
73 Global Back_def = 2; ! Black.
74 Global Fore_def = 9; ! White.
76 Global TopBar = 5; ! Lines from the top.
78 Global player_x = 0; ! Keeping track of where the player was
79 Global player_y = 0; ! 1 move ago allows us to keep the
80 Global player_x_last = 0; ! player from walking through obstacles.
81 Global player_y_last = 0;
85 Global kitten_char = 0;
86 Global kitten_color = 0;
88 Global last_message = ""; ! Always show the last-encountered message.
90 Global nonkitten_count = Nonkitten_Default;
92 Array nonkitten_x --> Nonkitten_Max;
93 Array nonkitten_y --> Nonkitten_Max;
94 Array nonkitten_color --> Nonkitten_Max;
95 Array nonkitten_char --> Nonkitten_Max;
96 Array nonkitten_msg --> Nonkitten_Max;
98 Global already_msg_count = 0;
99 Global already_count = 0;
100 Array already_x --> Nonkitten_Max + 2;
101 Array already_y --> Nonkitten_Max + 2;
102 Array already_msg --> Nonkitten_Max;
104 ! If a key is held down while the found_kitten animation is playing,
105 ! (0-->1) & $03ff gets corrupted. Seems like it might be a bug
106 ! somewhere in Unix Frotz.
108 Global Real_Release = 0;
112 @set_colour Fore_def Back_def;
114 if (MESSAGE_NUM < Nonkitten_Max) {
115 nonkitten_count = MESSAGE_NUM;
117 nonkitten_count = Nonkitten_Default;
120 Real_Release = (0-->1)&$03ff;
129 'F': already_count = 0;
135 'D': set_nonkitten_count();
136 'I': print_instructions();
138 'T': print_thoughts();
139 'P': print_all_nki(); ! See print_all_nki() below.
141 if (key == 'Q' || key == $1b) ! $1b == ESC
151 ! There's a 1:50 chance that the kitten in the title screen
152 ! will have a "psycho" appearance.
167 draw_big_robot(3, 7);
170 draw_big_kitten_psycho(14, 7);
172 draw_big_kitten(15, 7);
175 print "http://www.robotfindskitten.org";
177 print "Leonard Richardson (C) 1997, 2000";
179 print "David Griffith (C) 2002 (Inform Edition)";
181 print " ", MESSAGE_NUM, " different nonkittens!";
185 print " F) Find Kitten^",
186 " D) Difficulty (", nonkitten_count, ")^",
195 ! Copied from module/verblibm.h of the Inform 6.21.3 standard library.
200 print (string) Story;
204 print (string) Headline;
206 print "Release ", Real_Release, " / Serial number ";
207 for (i=18:i<24:i++) print (char) 0->i;
208 print " / Inform v"; inversion; print "";
213 Constant INBUFSIZE 80;
214 Array inbuf -> INBUFSIZE;
216 [ set_nonkitten_count maxnum val;
226 if (MESSAGE_NUM < Nonkitten_Max) {
227 maxnum = MESSAGE_NUM;
229 maxnum = Nonkitten_Max;
232 print "^Please enter the number of nonkittens you
233 wish to search through.^(1 to ", maxnum, " only)^^> ";
236 val = get_number(1, maxnum, nonkitten_count);
240 nonkitten_count = val;
248 [ get_number min max init inbufvar ix cx len val;
251 inbuf->0 = (INBUFSIZE-3);
259 while (cx < len && inbuf->(2+cx) == ' ')
261 if (cx < len && inbuf->(2+cx) == '.')
264 ! If user just hits return, use what we have already.
267 if (cx == len || inbuf->(2+cx) < '0' || inbuf->(2+cx) > '9') {
268 print "Please enter a value from ", min, " to ", max,
269 ", or Enter by itself to exit.^
270 [Press any key to continue.] ";
275 while (cx < len && inbuf->(2+cx) >= '0' && inbuf->(2+cx) <= '9') {
276 val = val * 10 + (inbuf->(2+cx) - '0');
279 if (val < min || val > max) {
280 print "Please enter a value from ", min, " to ", max,
281 ", or Enter by itself to exit.^
282 [Press any key to continue.] ";
294 @split_window TopBar;
301 This Zen simulation is based on the C version v1600003.248b^
302 by Leonard Richardson (C) 1997, 2000.^
303 Written originally for the Nerth Pork robotfindskitten contest.^
304 Reimplemented in Inform by David Griffith (C) 2002.^
306 This code is freely redistributable. Do with it what you will, but
307 don't go about claiming you wrote it. I, David Griffith, retain
308 copyright on this program except for the NKIs imported from the master
311 Lots more information on robotfindskitten is available at
312 http://www.robotfindskitten.org.^
314 To submit new NKI's, please go to the above URL.^
319 Release 1 / Serial number 0211xx to 021214 or so^
320 Initial private release. Limited distribution for beta testing and
323 Release 2 / Serial Number 021216^
324 First public release.^
326 Release 3 / Serial Number 021221^
328 - Movement keys 'J' and 'K' were swapped by mistake. Fixed.^
329 - Special PalmOS movement key support added.^
330 - More NKIs added (401 total).^
332 Release 4 / Serial Number 030131^
333 Light overhaul release.^
334 - Now an official port of robotfindskitten.^
335 - Typos in NKIs fixed.^
336 - Fixed diagonal collision-detection strangeness.^
337 - Added color support.^
338 - Added an easter egg. Can you find it?^
339 - Removed PalmOS movement key support (superfluous and ugly).^
340 - Removed playfield resizing code (superfluous and ugly).^
341 - It's ~robotfindskitten~, not ~Robot Finds Kitten~.^
342 - Merged in new NKIs from the new POSIX release of robotfindskitten.^
343 - More NKIs added (561 total).^
345 Release 5 / Serial Number 030524^
346 Even more NKIs release.^
347 - Idiotic typos fixed.^
348 - More NKIs added (602 total).^
350 Release 6 / Serial Number 031116^
352 - More NKIs added (764 total).^
353 - Increased maximum difficulty to 589.^
354 - Lots more comments in the source code.^
355 - Assorted cleanups in the source code.^
357 Release 7 / Serial Number 040523^
358 Grammatically correct release.^
359 - Grammar corrections from the POSIX port added.^
360 - More NKIs added (800 total).^
365 1) I still don't know why already_seen_xy() occasionally causes Robot to
366 get placed on top of another object when a game is started. Fortunately
367 this seems to happen only very rarely and typically only if the
368 difficulty is set to more than 200. This bug also seems to very
369 occasionally put Kitten underneath an NKI.^
371 2) Under earlier versions of Windows Frotz, Robot used to appear as a
372 solid block. This was because of a bug in Windows Frotz which
373 incorrectly makes the cursor opaque. The cursor is now moved off to
374 the upper-right corner so that the game looks okay on terminals that use
375 something other than reverse for the cursor. I still can't figure out
376 how to make Inform hide the cursor completely. At least on xterm and
377 NetBSD's console, @@64set_cursor -1 doesn't work.^
379 3) Under Windows Frotz, an annoying [MORE] prompt might appear at the
380 main menu. This is another bug in Windows Frotz which causes the
381 interpreter to follow Windows' suggestion that something less than 24 or
384 [Press any key to continue.] ";
389 [ print_instructions;
391 @split_window TopBar;
397 In this game, you are Robot ( ";
398 style reverse; print "#"; style roman;
399 print " ). Your job is to find Kitten. This task is complicated by the
400 existance of various things which are not Kitten. Robot must touch
401 items to determine if they are Kitten or not. Move Robot with the
402 cursor keys, the numeric keypad (make sure numlock is on), or using the
403 vi/rogue/nethack movement keys. The game ends when robotfindskitten.
404 Alternatively, you may end the game by hitting the Esc or Q keys.^
406 [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;
463 @set_colour 6 Back_def;
465 @set_colour 4 Back_def;
467 @set_colour 6 Back_def;
472 @set_colour 6 Back_def;
474 @set_colour 3 Back_def;
476 @set_colour 6 Back_def;
478 @set_colour 8 Back_def;
483 @set_colour 6 Back_def;
488 @set_colour 8 Back_def;
491 @set_colour Fore_def Back_def;
495 [ draw_big_kitten x y;
503 @set_colour 5 Back_def;
504 print "|", (char) 92, "_/|";
508 @set_colour 4 Back_def;
510 @set_colour 5 Back_def;
514 @set_colour 9 Back_def;
516 @set_colour 3 Back_def;
518 @set_colour 9 Back_def;
520 @set_colour 5 Back_def;
521 print "__", (char) 92;
526 @set_colour Fore_def Back_def;
530 [ draw_big_kitten_psycho x y;
538 @set_colour 5 Back_def;
539 print " |", (char) 92, "_/|";
542 @set_colour 4 Back_def;
544 @set_colour 5 Back_def;
548 @set_colour 9 Back_def;
550 @set_colour 3 Back_def;
552 @set_colour 9 Back_def;
554 @set_colour 5 Back_def;
555 print "__", (char) 92;
560 @set_colour Fore_def Back_def;
564 ! Something gets messed up if I make this local to findkitten()
565 ! When going right or left, then up or down to hit the Kitten, the
566 ! animation gets reversed.
568 Global last_right = false;
573 @split_window TopBar;
578 print (string) last_message;
581 draw_object(kitten_x, kitten_y, kitten_char, kitten_color);
585 draw_object(player_x, player_y, '#');
596 player_x_last = player_x;
597 player_y_last = player_y;
599 'Q', $1b: rfalse; ! exit game ($1b == Esc)
600 '8', 'K', 129: player_y--; ! up
601 '2', 'J', 130: player_y++; ! down
602 '4', 'H', 131: player_x--; ! left
604 '6', 'L', 132: player_x++; ! right
607 '7', 'Y': player_y--; player_x--; ! up-left
609 '9', 'U': player_y--; player_x++; ! up-right
611 '1', 'B': player_y++; player_x--; ! down-left
613 '3', 'N': player_y++; player_x++; ! down-right
617 ! Keep Robot from falling off edges of playfield.
619 if (player_y == TopBar || player_y > Height) {
620 player_y = player_y_last;
622 if (player_x < 1 || player_x > Width) {
623 player_x = player_x_last;
626 ! Detect and handle collisions.
628 if (player_x == kitten_x && player_y == kitten_y) {
629 animate_kitten(key, last_right);
633 for (i = 0: i < nonkitten_count: i++) {
634 if (player_x == nonkitten_x-->i
635 && player_y == nonkitten_y-->i) {
637 last_message = lookup_msg(nonkitten_msg-->i);
638 player_x = player_x_last;
639 player_y = player_y_last;
646 [ animate_kitten key my_last_right i j junk robot_x anim_finished;
649 '8', 'J', 129: player_y++;
650 '2', 'K', 130: player_y--;
651 '4', 'H', 131: player_x++;
652 '6', 'L', 132: player_x--;
653 '7', 'Y': player_y++; player_x++;
654 '9', 'U': player_y++; player_x--;
655 '1', 'B': player_y--; player_x++;
656 '3', 'N': player_y--; player_x--;
659 anim_finished = false;
660 for (i = 4: i >= 0: i--) {
662 @split_window TopBar;
671 robot_x = Anim_Meet - i;
673 draw_object(robot_x, TopBar - 1, '#');
675 draw_object(Anim_Meet - 1 + i, TopBar - 1,
676 kitten_char, kitten_color);
678 robot_x = Anim_Meet - 1 + i;
680 draw_object(robot_x, TopBar - 1, '#');
682 draw_object(Anim_Meet - i, TopBar - 1,
683 kitten_char, kitten_color);
688 print "You found Kitten! Way to go, Robot!";
689 anim_finished = true;
692 draw_object(kitten_x, kitten_y, kitten_char, kitten_color);
695 draw_object(player_x, player_y, '#');
699 if (anim_finished == false) {
702 @aread junk 0 10 pause -> junk;
705 draw_object(player_x, player_y, '#');
713 [ already_seen_xy x y i;
714 for (i = 0: i < already_count: i++) {
715 if (already_x-->already_count == x &&
716 already_y-->already_count ==y) {
720 already_x-->already_count = x;
721 already_y-->already_count = y;
733 kitten_x = get_random_x();
734 kitten_y = get_random_y();
735 kitten_color = get_random_color();
736 while (already_seen_xy(kitten_x, kitten_y) == true) {
737 kitten_x = get_random_x();
738 kitten_y = get_random_y();
740 kitten_char = get_random_char();
745 player_x = get_random_x();
746 player_y = get_random_y();
747 while (already_seen_xy(player_x, player_y) == true) {
748 player_x = get_random_x();
749 player_y = get_random_y();
755 already_msg_count = 0;
757 for (i = 0: i < nonkitten_count: i++) {
758 nonkitten_x-->i = get_random_x();
759 nonkitten_y-->i = get_random_y();
760 nonkitten_color-->i = get_random_color();
761 while (already_seen_xy(nonkitten_x-->i,
762 nonkitten_y-->i) == true) {
763 nonkitten_x-->i = get_random_x();
764 nonkitten_y-->i = get_random_y();
766 nonkitten_char-->i = get_random_char();
767 nonkitten_msg-->i = get_random_msg();
773 for (i = 0: i < nonkitten_count: i++) {
774 draw_object(nonkitten_x-->i,
777 nonkitten_color-->i);
782 [ draw_object x y character fore back;
790 @set_colour fore Back_def;
792 print (char) character;
794 @set_colour Fore_def Back_def;
800 for (i = 0 : i < Width : i++)
807 if (x >= 'a' && x <= 'z')
813 [ get_random_char num;
816 while (num == 35) { ! avoid choosing '#'
824 [ get_random_msg num;
825 num = random(MESSAGE_NUM);
826 while (is_duplicate_msg(num) == true) {
827 num = random(MESSAGE_NUM);
833 [ get_random_color num;
835 ! 0 and 1 are default color and current color
836 ! and we want to avoid picking the default color explicitly
837 while (num == $2c-->0) {
844 [ is_duplicate_msg num i;
845 for (i = 0: i < already_msg_count: i++) {
846 if (already_msg-->i==num) {
850 already_msg-->already_msg_count = num;
857 ! Maybe this will need to do something more in the future.
858 return random(Width);
863 ! Make sure we don't draw in the status bar.
865 num = random(Height);
872 ! This function is mainly of use to members of the robotfindskitten
875 ! When this function is uncommented and enabled in
876 ! the menu, this will cause a script file to be written which contains
877 ! all NKIs properly formatted.
879 [ print_all_nki num mystring;
880 @output_stream 2; @output_stream -1;
881 for (num = 1: num <= MESSAGE_NUM: num++) {
882 mystring = lookup_msg(num);
883 print (string)lookup_msg(num), "^";
885 @output_stream -2; @output_stream 1;