3 ! Release 7 / Serial number 130320 / Inform v6.33
5 ! [-] |\_/| http://www.robotfindskitten.org
6 ! (+)=C |o o|__ Leonard Richardson (C) 1997, 2000
7 ! | | --*--__\ David Griffith (C) 2002-2013 (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.
29 ! 1) More than half of the code is taken up by non kitten items
30 ! (NKIs). When I compiled the code with just five messages and
31 ! no debugging code, the resulting binary was less than 10k bytes.
33 ! 2) If it wasn't already abundantly obvious, this program won't
34 ! compile to Glulx because of copious use of Z-machine assembly
37 ! 3) Compiling for V5 or higher is required due to "style" calls.
38 ! Is there a reason why someone would want to compile this for V4
46 Constant Nonkitten_Default 20;
48 ! Maxmimum possible number of non-kitten items on the playfield at once.
49 ! For whatever reason, this cannot be set dynamically.
51 Constant Nonkitten_Max 589;
56 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
58 Constant Story "robotfindskitten";
59 Constant Headline "^A Zen Simulation^";
61 ! NKIs are generated with nki2inf.pl and put into nki.inf
64 Constant Anim_Meet 10; ! Number of spaces from the left where
65 ! Robot and Kitten meet during animation.
67 Global Height = 0; ! These are set at runtime.
70 Global Back_def = 2; ! Black.
71 Global Fore_def = 9; ! White.
73 Global TopBar = 5; ! Lines from the top.
75 Global player_x = 0; ! Keeping track of where the player was
76 Global player_y = 0; ! 1 move ago allows us to keep the
77 Global player_x_last = 0; ! player from walking through obstacles.
78 Global player_y_last = 0;
82 Global kitten_char = 0;
83 Global kitten_color = 0;
85 Global last_message = ""; ! Always show the last-encountered message.
87 Global nonkitten_count;
89 Array nonkitten_x --> Nonkitten_Max;
90 Array nonkitten_y --> Nonkitten_Max;
91 Array nonkitten_color --> Nonkitten_Max;
92 Array nonkitten_char --> Nonkitten_Max;
93 Array nonkitten_msg --> Nonkitten_Max;
95 Global already_msg_count = 0;
96 Global already_count = 0;
97 Array already_x --> Nonkitten_Max + 2;
98 Array already_y --> Nonkitten_Max + 2;
99 Array already_msg --> Nonkitten_Max;
101 ! If a key is held down while the found_kitten animation is playing,
102 ! (0-->1) & $03ff gets corrupted. Seems like it might be a bug
103 ! somewhere in Unix Frotz.
105 Global Real_Release = 0;
108 @set_colour Fore_def Back_def;
110 if (MESSAGE_NUM < Nonkitten_Default) {
111 nonkitten_count = MESSAGE_NUM;
113 nonkitten_count = Nonkitten_Default;
116 Real_Release = (0-->1)&$03ff;
125 'F': already_count = 0;
131 'D': set_nonkitten_count();
132 'I': print_instructions();
134 'T': print_thoughts();
136 if (key == 'Q' || key == $1b) ! $1b == ESC
146 ! There's a 1:50 chance that the kitten in the title screen
147 ! will have a "psycho" appearance.
162 draw_big_robot(3, 7);
165 draw_big_kitten_psycho(14, 7);
167 draw_big_kitten(15, 7);
170 print "http://www.robotfindskitten.org";
172 print "Leonard Richardson (C) 1997, 2000";
174 print "David Griffith (C) 2002-2013 (Inform Edition)";
176 print " ", MESSAGE_NUM, " different nonkittens!";
180 print " F) Find Kitten^",
181 " D) Difficulty (", nonkitten_count, ")^",
190 ! Copied from module/verblibm.h of the Inform 6.21.3 standard library.
195 print (string) Story;
199 print (string) Headline;
201 print "Release ", Real_Release, " / Serial number ";
202 for (i=18:i<24:i++) print (char) 0->i;
203 print " / Inform v"; inversion; print "";
208 Constant INBUFSIZE 80;
209 Array inbuf -> INBUFSIZE;
211 [ set_nonkitten_count maxnum val;
220 if (MESSAGE_NUM < Nonkitten_Max) {
221 maxnum = MESSAGE_NUM;
223 maxnum = Nonkitten_Max;
226 print "^Please enter the number of nonkittens you
227 wish to search through.^(1 to ", maxnum, " only)^^> ";
230 val = get_number(1, maxnum, nonkitten_count);
234 nonkitten_count = val;
242 [ get_number min max init inbufvar ix cx len val;
244 inbuf->0 = (INBUFSIZE-3);
252 while (cx < len && inbuf->(2+cx) == ' ')
254 if (cx < len && inbuf->(2+cx) == '.')
257 ! If user just hits return, use what we have already.
260 if (cx == len || inbuf->(2+cx) < '0' || inbuf->(2+cx) > '9') {
261 print "Please enter a value from ", min, " to ", max,
262 ", or Enter by itself to exit.^
263 [Press any key to continue.] ";
268 while (cx < len && inbuf->(2+cx) >= '0' && inbuf->(2+cx) <= '9') {
269 val = val * 10 + (inbuf->(2+cx) - '0');
272 if (val < min || val > max) {
273 print "Please enter a value from ", min, " to ", max,
274 ", or Enter by itself to exit.^
275 [Press any key to continue.] ";
286 @split_window TopBar;
293 This Zen simulation is based on the C version v1600003.248b^
294 by Leonard Richardson (C) 1997, 2000.^
295 Written originally for the Nerth Pork robotfindskitten contest.^
296 Reimplemented in Inform by David Griffith (C) 2002.^
298 This code is freely redistributable. Do with it what you will, but
299 don't go about claiming you wrote it. I, David Griffith, retain
300 copyright on this program except for the NKIs imported from the master
303 Lots more information on robotfindskitten is available at
304 http://www.robotfindskitten.org.^
306 To submit new NKI's, please go to the above URL.^
311 Release 1 / Serial number 0211xx to 021214 or so^
312 Initial private release. Limited distribution for beta testing and
315 Release 2 / Serial Number 021216^
316 First public release.^
318 Release 3 / Serial Number 021221^
320 - Movement keys 'J' and 'K' were swapped by mistake. Fixed.^
321 - Special PalmOS movement key support added.^
322 - More NKIs added (401 total).^
324 Release 4 / Serial Number 030131^
325 Light overhaul release.^
326 - Now an official port of robotfindskitten.^
327 - Typos in NKIs fixed.^
328 - Fixed diagonal collision-detection strangeness.^
329 - Added color support.^
330 - Added an easter egg. Can you find it?^
331 - Removed PalmOS movement key support (superfluous and ugly).^
332 - Removed playfield resizing code (superfluous and ugly).^
333 - It's ~robotfindskitten~, not ~Robot Finds Kitten~.^
334 - Merged in new NKIs from the new POSIX release of robotfindskitten.^
335 - More NKIs added (561 total).^
337 Release 5 / Serial Number 030524^
338 Even more NKIs release.^
339 - Idiotic typos fixed.^
340 - More NKIs added (602 total).^
342 Release 6 / Serial Number 031116^
344 - More NKIs added (764 total).^
345 - Increased maximum difficulty to 589.^
346 - Lots more comments in the source code.^
347 - Assorted cleanups in the source code.^
349 Release 7 / Serial Number 130320^
351 - Synchronized NKIs and removed redundancies with the POSIX port.^
352 - NKIs now generated from an external file using nki2inf.pl.^
353 - NKIs reduced to 723 because of redundancies and recommended deletions.^
358 1) I still don't know why already_seen_xy() occasionally causes Robot to
359 get placed on top of another object when a game is started. Fortunately
360 this seems to happen only very rarely and typically only if the
361 difficulty is set to more than 200. This bug also seems to very
362 occasionally put Kitten underneath an NKI.^
364 2) Under earlier versions of Windows Frotz, Robot used to appear as a
365 solid block. This was because of a bug in Windows Frotz which
366 incorrectly makes the cursor opaque. The cursor is now moved off to
367 the upper-right corner so that the game looks okay on terminals that use
368 something other than reverse for the cursor. I still can't figure out
369 how to make Inform hide the cursor completely. At least on xterm and
370 NetBSD's console, @@64set_cursor -1 doesn't work.^
372 3) Under Windows Frotz, an annoying [MORE] prompt might appear at the
373 main menu. This is another bug in Windows Frotz which causes the
374 interpreter to follow Windows' suggestion that something less than 24 or
377 [Press any key to continue.] ";
382 [ print_instructions;
384 @split_window TopBar;
390 In this game, you are Robot ( ";
391 style reverse; print "#"; style roman;
392 print " ). Your job is to find Kitten. This task is complicated by the
393 existance of various things which are not Kitten. Robot must touch
394 items to determine if they are Kitten or not. Move Robot with the
395 cursor keys, the numeric keypad (make sure numlock is on), or using the
396 vi/rogue/nethack movement keys. The game ends when robotfindskitten.
397 Alternatively, you may end the game by hitting the Esc or Q keys.^
399 [Press any key to continue.] ";
406 @split_window TopBar;
414 Day and night I feverishly worked upon the machine, creating both a soul
415 which could desire its goal, and a body with which it could realize
416 it. Many who saw my creation called it an abomination, and denied me
417 grant money. But they could not dissuade me from my impossible
418 task. It was a spectre that tormented me always, a ghost I had to give
419 a form and a life, lest it consume me from the inside. And when at last
420 my task was done, when the grey box on wheels was complete and when it,
421 as well as I, knew what had to be done, I felt deep sympathy for the
422 machine. For I had not destroyed the phantom, but merely exorcized it
423 into another body. The robot knew not why this task had to be
424 performed, for I could not imbue it with knowledge I did not myself
425 posess. And at the same time, I felt a sweeping sense of relief sweep
426 over me, that somehow, the dream that had driven me for my entire life
427 had come one step closer to fruition.^
429 ~Gort, Klaatu Verada Nikto~^
431 As I vocally activated the robot, I realized that it was following my
432 instructions, but not out of any desire to obey me. Had I remained
433 silent, it would have performed exactly the same operations. We were
434 two beings controlled by the same force now. And yet, seeking vainly to
435 hold some illusion of control over the machine I thought I had created,
436 I gave my final command.^
438 ~GO!~ I told the box as it began to roll out of my workshop into the
439 frozen desert beyond. ~FIND KITTEN!~^
441 -- The Book of Found Kittens, pages 43-4, author unknown.^
443 [Press any key to continue.] ";
448 [ draw_big_robot x y;
454 @set_colour 6 Back_def;
456 @set_colour 4 Back_def;
458 @set_colour 6 Back_def;
463 @set_colour 6 Back_def;
465 @set_colour 3 Back_def;
467 @set_colour 6 Back_def;
469 @set_colour 8 Back_def;
474 @set_colour 6 Back_def;
479 @set_colour 8 Back_def;
482 @set_colour Fore_def Back_def;
486 [ draw_big_kitten x y;
493 @set_colour 5 Back_def;
494 print "|", (char) 92, "_/|";
498 @set_colour 4 Back_def;
500 @set_colour 5 Back_def;
504 @set_colour 9 Back_def;
506 @set_colour 3 Back_def;
508 @set_colour 9 Back_def;
510 @set_colour 5 Back_def;
511 print "__", (char) 92;
516 @set_colour Fore_def Back_def;
520 [ draw_big_kitten_psycho x y;
527 @set_colour 5 Back_def;
528 print " |", (char) 92, "_/|";
531 @set_colour 4 Back_def;
533 @set_colour 5 Back_def;
537 @set_colour 9 Back_def;
539 @set_colour 3 Back_def;
541 @set_colour 9 Back_def;
543 @set_colour 5 Back_def;
544 print "__", (char) 92;
549 @set_colour Fore_def Back_def;
553 ! Something gets messed up if I make this local to findkitten()
554 ! When going right or left, then up or down to hit the Kitten, the
555 ! animation gets reversed.
557 Global last_right = false;
561 @split_window TopBar;
566 print (string) last_message;
569 draw_object(kitten_x, kitten_y, kitten_char, kitten_color);
573 draw_object(player_x, player_y, '#');
584 player_x_last = player_x;
585 player_y_last = player_y;
587 'Q', $1b: rfalse; ! exit game ($1b == Esc)
588 '8', 'K', 129: player_y--; ! up
589 '2', 'J', 130: player_y++; ! down
590 '4', 'H', 131: player_x--; ! left
592 '6', 'L', 132: player_x++; ! right
595 '7', 'Y': player_y--; player_x--; ! up-left
597 '9', 'U': player_y--; player_x++; ! up-right
599 '1', 'B': player_y++; player_x--; ! down-left
601 '3', 'N': player_y++; player_x++; ! down-right
605 ! Keep Robot from falling off edges of playfield.
607 if (player_y == TopBar || player_y > Height) {
608 player_y = player_y_last;
610 if (player_x < 1 || player_x > Width) {
611 player_x = player_x_last;
614 ! Detect and handle collisions.
616 if (player_x == kitten_x && player_y == kitten_y) {
617 animate_kitten(key, last_right);
621 for (i = 0: i < nonkitten_count: i++) {
622 if (player_x == nonkitten_x-->i
623 && player_y == nonkitten_y-->i) {
625 last_message = lookup_msg(nonkitten_msg-->i);
626 player_x = player_x_last;
627 player_y = player_y_last;
634 [ animate_kitten key my_last_right i j junk robot_x anim_finished;
636 '8', 'J', 129: player_y++;
637 '2', 'K', 130: player_y--;
638 '4', 'H', 131: player_x++;
639 '6', 'L', 132: player_x--;
640 '7', 'Y': player_y++; player_x++;
641 '9', 'U': player_y++; player_x--;
642 '1', 'B': player_y--; player_x++;
643 '3', 'N': player_y--; player_x--;
646 anim_finished = false;
647 for (i = 4: i >= 0: i--) {
649 @split_window TopBar;
658 robot_x = Anim_Meet - i;
660 draw_object(robot_x, TopBar - 1, '#');
662 draw_object(Anim_Meet - 1 + i, TopBar - 1,
663 kitten_char, kitten_color);
665 robot_x = Anim_Meet - 1 + i;
667 draw_object(robot_x, TopBar - 1, '#');
669 draw_object(Anim_Meet - i, TopBar - 1,
670 kitten_char, kitten_color);
675 print "You found Kitten! Way to go, Robot!";
676 anim_finished = true;
679 draw_object(kitten_x, kitten_y, kitten_char, kitten_color);
682 draw_object(player_x, player_y, '#');
686 if (anim_finished == false) {
689 @aread junk 0 10 pause -> junk;
692 draw_object(player_x, player_y, '#');
700 [ already_seen_xy x y i;
701 for (i = 0: i < already_count: i++) {
702 if (already_x-->already_count == x &&
703 already_y-->already_count ==y) {
707 already_x-->already_count = x;
708 already_y-->already_count = y;
720 kitten_x = get_random_x();
721 kitten_y = get_random_y();
722 kitten_color = get_random_color();
723 while (already_seen_xy(kitten_x, kitten_y) == true) {
724 kitten_x = get_random_x();
725 kitten_y = get_random_y();
727 kitten_char = get_random_char();
732 player_x = get_random_x();
733 player_y = get_random_y();
734 while (already_seen_xy(player_x, player_y) == true) {
735 player_x = get_random_x();
736 player_y = get_random_y();
742 already_msg_count = 0;
744 for (i = 0: i < nonkitten_count: i++) {
745 nonkitten_x-->i = get_random_x();
746 nonkitten_y-->i = get_random_y();
747 nonkitten_color-->i = get_random_color();
748 while (already_seen_xy(nonkitten_x-->i,
749 nonkitten_y-->i) == true) {
750 nonkitten_x-->i = get_random_x();
751 nonkitten_y-->i = get_random_y();
753 nonkitten_char-->i = get_random_char();
754 nonkitten_msg-->i = get_random_msg();
760 for (i = 0: i < nonkitten_count: i++) {
761 draw_object(nonkitten_x-->i,
764 nonkitten_color-->i);
769 [ draw_object x y character fore back;
777 @set_colour fore Back_def;
779 print (char) character;
781 @set_colour Fore_def Back_def;
787 for (i = 0 : i < Width : i++)
794 if (x >= 'a' && x <= 'z')
800 [ get_random_char num;
803 while (num == 35) { ! avoid choosing '#'
811 [ get_random_msg num;
812 num = random(MESSAGE_NUM);
813 while (is_duplicate_msg(num) == true) {
814 num = random(MESSAGE_NUM);
820 [ get_random_color num;
822 ! 0 and 1 are default color and current color
823 ! and we want to avoid picking the default color explicitly
824 while (num == $2c-->0) {
831 [ is_duplicate_msg num i;
832 for (i = 0: i < already_msg_count: i++) {
833 if (already_msg-->i==num) {
837 already_msg-->already_msg_count = num;
844 ! Maybe this will need to do something more in the future.
845 return random(Width);
850 ! Make sure we don't draw in the status bar.
852 num = random(Height);