diff --git a/examples/.distr b/examples/.distr new file mode 100644 index 000000000..74f4a71b6 --- /dev/null +++ b/examples/.distr @@ -0,0 +1,7 @@ +hilo.b +hilo.c +hilo.mod +hilo.ocm +hilo.p +paranoia.c +README diff --git a/examples/README b/examples/README new file mode 100644 index 000000000..e74aadea2 --- /dev/null +++ b/examples/README @@ -0,0 +1,26 @@ +# $Source$ +# $State$ +# $Revision$ + +A few notes on the examples +--------------------------- + +This directory contains a handful of working example programs that can be +built with the ACK. They're intended as a convention source of test code +and as a starting point when writing your own programs. + +They consist of: + +hilo.c ANSI C version of the Hi/Lo game +hilo.b Basic version of the Hi/Lo game +hilo.mod Modula-2 version of the Hi/Lo game +hilo.ocm Occam 1 version of the Hi/Lo game +hilo.p Pascal version of the Hi/Lo game + +paranoia.c An ancient public domain K&R C adventure game + +Enjoy. + +David Given +dg@cowlark.com +2007-02-25 diff --git a/examples/hilo.b b/examples/hilo.b new file mode 100644 index 000000000..7493b971b --- /dev/null +++ b/examples/hilo.b @@ -0,0 +1,39 @@ +1 ' $Source$ +2 ' $State$ +3 ' $Revision$ + +10 print "Hi there! Before we start, what is your name?" +20 input "> ", PlayerName$ +30 print +40 print "Hello, "; PlayerName$; "!" + +100 gosub 1000 +110 print +120 print "Would you like another go?" +130 input "> ", s$ +140 s$ = left$(s$, 1) +150 if s$ = "n" or s$ = "N" then goto 200 +160 print +170 print "Excellent! "; +180 goto 100 +200 print +210 print "Thanks for playing --- goodbye!" +220 end + +1000 print "See if you can guess my number." +1010 Number% = rnd(1) mod 100 +1020 Attempts% = 1 + +1030 print +1040 input "> ", guess% +1050 if guess% < Number% then print: print "Try a bit higher." +1060 if guess% > Number% then print: print "Try a bit lower." +1070 if guess% = Number% then goto 1100 +1080 Attempts% = Attempts% + 1 +1090 goto 1030 +1100 print +1110 print "You got it right in only"; Attempts%; +1120 if Attempts% = 1 then print "go"; else print "goes"; +1130 print "!" +1140 return + diff --git a/examples/hilo.c b/examples/hilo.c new file mode 100644 index 000000000..21b407335 --- /dev/null +++ b/examples/hilo.c @@ -0,0 +1,83 @@ +/* $Source$ + * $State$ + * $Revision$ + */ + +#include +#include +#include + +char buffer[32]; +char PlayerName[32]; + +int Number; +int Attempts; + +void reads(void) +{ + char* p; + + printf("> "); + fflush(stdout); + + fgets(buffer, sizeof(buffer), stdin); + + p = strchr(buffer, '\n'); + if (p != NULL) + *p = '\0'; +} + +void game(void) +{ + printf("See if you can guess my number.\n"); + + Number = rand() % 100; + Attempts = 1; + + for (;;) + { + int guess; + + printf("\n"); + reads(); + guess = atoi(buffer); + + if (guess == Number) + { + printf("\nYou got it right in only %d %s!\n", Attempts, + (Attempts == 1) ? "go" : "goes"); + return; + } + + if (guess < Number) + printf("\nTry a bit higher.\n"); + if (guess > Number) + printf("\nTry a bit lower.\n"); + Attempts++; + } +} + +int main(int argc, char* argv[]) +{ + printf("\nHi there! Before we start, what is your name?\n"); + reads(); + strcpy(PlayerName, buffer); + printf("\nHello, %s! ", PlayerName); + + for (;;) + { + game(); + printf("\nWould you like another go?\n"); + reads(); + + if ((buffer[0] == 'n') || (buffer[0] == 'N')) + { + printf("\nThanks for playing --- goodbye!\n"); + exit(0); + } + + printf("\nExcellent! "); + } + + return 0; +} diff --git a/examples/hilo.mod b/examples/hilo.mod new file mode 100644 index 000000000..7711f738b --- /dev/null +++ b/examples/hilo.mod @@ -0,0 +1,95 @@ +(* $Source$ + * $State$ + * $Revision$ + *) + +MODULE HiLo; +FROM InOut IMPORT WriteInt, WriteLn, WriteString, ReadString, ReadInt; +FROM random IMPORT Uniform; + +VAR + buffer : ARRAY [0..32] OF CHAR; + +PROCEDURE reads; +BEGIN + WriteString("> "); + ReadString(buffer); +END reads; + +PROCEDURE game; +VAR + Number : INTEGER; + Attempts : INTEGER; + guess : INTEGER; + finished : BOOLEAN; +BEGIN + WriteString("See if you can guess my number."); + WriteLn; + + Number := Uniform(0, 99); + Attempts := 1; + finished := FALSE; + + WHILE NOT finished DO + WriteLn; + WriteString("> "); + ReadInt(guess); + + IF guess = Number THEN + WriteLn; + WriteString("You got it right in only "); + WriteInt(Attempts, 0); + WriteString(" "); + IF Attempts = 1 THEN + WriteString("go"); + ELSE + WriteString("goes"); + END; + WriteString("!"); + WriteLn; + finished := TRUE; + ELSIF guess < Number THEN + WriteLn; + WriteString("Try a bit higher."); + WriteLn; + ELSIF guess > Number THEN + WriteLn; + WriteString("Try a bit lower."); + WriteLn; + END; + + Attempts := Attempts + 1; + END; +END game; + +VAR + finished : BOOLEAN; +BEGIN + WriteLn; + WriteString("Hi there! Before we start, what is your name?"); + WriteLn; + reads; + WriteLn; + WriteString("Hello, "); + WriteString(buffer); + WriteString("! "); + + finished := FALSE; + WHILE NOT finished DO + game; + WriteLn; + WriteString("Would you like another go?"); + WriteLn; + reads; + + IF (buffer[0] = 'n') OR (buffer[0] = 'N') THEN + finished := TRUE; + WriteLn; + WriteString("Thanks for playing --- goodbye!"); + WriteLn; + ELSE + WriteLn; + WriteString("Excellent! "); + END; + END; +END HiLo. diff --git a/examples/hilo.ocm b/examples/hilo.ocm new file mode 100644 index 000000000..85bafaa20 --- /dev/null +++ b/examples/hilo.ocm @@ -0,0 +1,131 @@ +# +-- $Source$ +-- $State$ +-- $Revision$ + +#include "dec.ocm" + +-- General utilities: read and write strings. + +proc puts(value s[]) = + seq i = [1 for s[byte 0]] + output ! s[byte i] +: + +proc gets(var s[]) = + var length, finished, c: + seq + finished := false + length := 0 + + while not finished + seq + input ? c + if + c = 10 + finished := true + true + seq + length := length + 1 + s[byte length] := c + + s[byte 0] := length +: + +-- Our random number generator. + +var seed: +proc randomise(value s) = + seq + seed := s +: + +proc random(value range, var result) = + seq + seed := (20077 * seed) + 12345 + if + seed < 0 + seed := -seed + true + skip + result := seed \ range +: + +-- Does the reading-in-the-name thing. + +proc getname = + var seed, buffer[128]: + seq + puts("*nHi there! Before we start, what is your name?*n") + puts("> ") + gets(buffer) + + seed := 0 + seq i = [1 for buffer[byte 0]] + seed := seed + buffer[byte i] + randomise(seed) + + puts("*nHello, ") + puts(buffer) + puts("! ") +: + +-- Plays a single game. + +proc game = + var Number, Attempts, finished, guess: + seq + puts("See if you can guess my number.*n") + random(100, Number) + Attempts := 1 + finished := false + while not finished + seq + puts("*n> ") + var c: + seq + c := '*s' + decin(input, guess, c) + + if + guess = Number + seq + puts("*nYou got it right in only ") + decout(output, Attempts, 0) + puts(" ") + if + Attempts = 1 + puts("go") + true + puts("goes") + puts("!*n") + finished := true + + guess < Number + puts("*nTry a bit higher.*n") + guess > Number + puts("*nTry a bit lower.*n") + Attempts := Attempts + 1 +: + +var finished, buffer[128]: +seq + output ! TEXT + getname + + finished := false + while not finished + seq + game + + puts("*nWould you like another go?*n") + puts("> ") + gets(buffer) + if + (buffer[byte 1] = 'n') or (buffer[byte 1] = 'N') + seq + finished := true + puts("*nThanks for playing --- goodbye!*n") + true + puts("*nExcellent! ") + diff --git a/examples/hilo.p b/examples/hilo.p new file mode 100644 index 000000000..e316b46c5 --- /dev/null +++ b/examples/hilo.p @@ -0,0 +1,167 @@ +(* $Source$ + * $State$ + * $Revision$ + *) + +(*$U+ --- enables underscores in identifiers *) + +program hilo(input, output); + +type + string = array [0..255] of char; + +var + playing : Boolean; + seed : integer; + +{ This version of Pascal seems to have no random number generator I can find, + so we have to implement our own here. This is a hacked up and probably + broken version of the C library generator. } + +procedure randomise(s : integer); + begin + seed := s; + end; + +function random(range : integer) : integer; + begin + seed := (20077 * seed + 12345); + random := seed mod range; + end; + +{ Pascal doesn't provide string input, so we interface to the _read() syscall + and do it manually. } + +function _read(fd : integer; var buffer : char; count : integer) : integer; + extern; + +function readchar : char; + var + c : char; + dummy : integer; + + begin + c := chr(0); + dummy := _read(0, c, 1); + readchar := c; + end; + +procedure readstring(var buffer : string; var length : integer); + var + finished : Boolean; + c : char; + + begin + write('> '); + + length := 0; + finished := FALSE; + seed := 0; + while not finished do + begin + c := readchar; + if (ord(c) = 10) then + finished := true + else + begin + buffer[length] := c; + length := length + 1; + end + end; + end; + +procedure getname; + var + name : string; + namelen : integer; + i : integer; + seed : integer; + + begin + writeln; + writeln('Hi there! Before we start, what is your name?'); + writeln; + readstring(name, namelen); + writeln; + write('Hello, '); + + seed := 0; + for i := 0 to (namelen-1) do + begin + write(name[i]); + seed := seed + ord(name[i]); + end; + + randomise(seed); + write('! '); + end; + +procedure game; + var + Number : integer; + Attempts : integer; + guess : integer; + + begin + writeln('See if you can guess my number.'); + Number := random(100); + Attempts := 0; + + guess := -1; + while guess <> Number do + begin + Attempts := Attempts + 1; + write('> '); + readln(guess); + + if guess < Number then + begin + writeln; + writeln('Try a bit higher.'); + end; + + if guess > Number then + begin + writeln; + writeln('Try a bit lower.'); + end; + end; + + writeln; + write('You got it right in only ', Attempts:0, ' '); + if Attempts = 1 then + write('go') + else + write('goes'); + writeln('!'); + end; + +function question: Boolean; + var + response: char; + + begin + write('> '); + readln(response); + + question := not ((response = 'n') or (response = 'N')); + end; + +begin + getname; + + playing := TRUE; + while playing do + begin + game; + writeln; + writeln('Would you like another go?'); + playing := question; + + writeln; + if playing then + write('Excellent! ') + else + writeln('Thanks for playing --- goodbye!'); + end; +end. diff --git a/examples/paranoia.c b/examples/paranoia.c new file mode 100644 index 000000000..f7020f71e --- /dev/null +++ b/examples/paranoia.c @@ -0,0 +1,1047 @@ +/* $Source$ + * $State$ + * $Revision$ + */ + +/* This is a solo paranoia game taken from the Jan/Feb issue (No 77) of + "SpaceGamer/FantasyGamer" magazine. + + Article by Sam Shirley. + + Implemented in C on Vax 11/780 under UNIX by Tim Lister + + Very slightly modernised to run on 2007-era (!) compilers by + David Given. + + This is a public domain adventure and may not be sold for profit */ + +#include + +#define MOXIE 13 +#define AGILITY 15 +#define MAXKILL 7 /* The maximum number of UV's you can kill */ + +int clone=1; +int page=1; +int computer_request=0; +int ultra_violet=0; +int action_doll=0; +int hit_points=10; +int read_letter=0; +int plato_clone=3; +int blast_door=0; +int killer_count=0; + +char get_char() +{ + char c; + fflush(stdout); + c=getchar(); + if (c!='\n') while(getchar()!='\n'); + return c; +} + +more() +{ + printf("---------- More ----------"); +#ifdef DEBUG + printf("(page %d)",page); +#endif + if (get_char()=='p') + { + character(); + printf("---------- More ----------"); + (void)get_char(); + }; +} + +new_clone(resume) +int resume; +{ + printf("\nClone %d just died.\n",clone); + if (++clone>6) + { + printf("\n*** You Lose ***\n\nAll your clones are dead. Your name has been stricken from the records.\n\n THE END\n"); + return 0; + } + else + { + printf("Clone %d now activated.\n",clone); + ultra_violet=0; + action_doll=0; + hit_points=10; + killer_count=0; + return resume; + } +} + +dice_roll(number,faces) +int number, faces; +{ + int i,total=0; + for(i=number;i>0;i--) total+= rand()%faces+1; + return total; +} + +instructions() +{ + printf("\n\n\n\nWelcome to Paranoia!\n\n"); + printf("HOW TO PLAY:\n\n"); + printf(" Just press until you are asked to make a choice.\n"); + printf(" Select 'a' or 'b' or whatever for your choice, then press .\n"); + printf(" You may select 'p' at any time to get a display of your statistics.\n"); + printf(" Always choose the least dangerous option. Continue doing this until you win.\n"); + printf(" At times you will use a skill or engage in combat and and will be informed of\n"); + printf(" the outcome. These sections will be self explanatory.\n\n"); + printf("HOW TO DIE:\n\n"); + printf(" As Philo-R-DMD you will die at times during the adventure.\n"); + printf(" When this happens you will be given an new clone at a particular location.\n"); + printf(" The new Philo-R will usually have to retrace some of the old Philo-R\'s path;\n"); + printf(" hopefully he won\'t make the same mistake as his predecessor.\n\n"); + printf("HOW TO WIN:\n\n"); + printf(" Simply complete the mission before you expend all six clones.\n"); + printf(" If you make it, congratulations.\n"); + printf(" If not, you can try again later.\n"); +} + +character() +{ + printf("===============================================================================\n"); + printf("The Character : Philo-R-DMD %d\n", clone); + printf("Primary Attributes Secondary Attributes\n"); + printf("===============================================================================\n"); + printf("Strength ..................... 13 Carrying Capacity ................. 30\n"); + printf("Endurance .................... 13 Damage Bonus ....................... 0\n"); + printf("Agility ...................... 15 Macho Bonus ....................... -1\n"); + printf("Manual Dexterity ............. 15 Melee Bonus ...................... +5%%\n"); + printf("Moxie ........................ 13 Aimed Weapon Bonus .............. +10%%\n"); + printf("Chutzpah ...................... 8 Comprehension Bonus .............. +4%%\n"); + printf("Mechanical Aptitude .......... 14 Believability Bonus .............. +5%%\n"); + printf("Power Index .................. 10 Repair Bonus ..................... +5%%\n"); + printf("===============================================================================\n"); + printf("Credits: 160 Secret Society: Illuminati Secret Society Rank: 1\n"); + printf("Service Group: Power Services Mutant Power: Precognition\n"); + printf("Weapon: laser pistol; to hit, 40%%; type, L; Range, 50m; Reload, 6r; Malfnt, 00\n"); + printf("Skills: Basics 1(20%%), Aimed Weapon Combat 2(35%%), Laser 3(40%%),\n Personal Development 1(20%%), Communications 2(29%%), Intimidation 3(34%%)\n"); + printf("Equipment: Red Reflec Armour, Laser Pistol, Laser Barrel (red),\n"); + printf(" Notebook & Stylus, Knife, Com Unit 1, Jump suit,\n"); + printf(" Secret Illuminati Eye-In-The-Pyramid(tm) Decoder ring,\n"); + printf(" Utility Belt & Pouches\n"); + printf("===============================================================================\n"); +} + +choose(a,aptr,b,bptr) +int a,b; +char *aptr, *bptr; +{ + printf("\nSelect \'a\' or \'b\' :\n"); + printf(" a - %s.\n b - %s.\n", aptr, bptr); + if (get_char()=='a') return a; + else return b; +} + +page1() +{ + printf(" You wake up face down on the red and pink checked E-Z-Kleen linoleum floor.\n"); + printf(" You recognise the pattern, it\'s the type preferred in the internal security\nbriefing cells. When you finally look around you, you see that you are alone\n"); + printf("in a large mission briefing room.\n"); + return 57; +} + +page2() +{ + printf("\"Greetings,\" says the kindly Internal Security self incrimination expert who\n"); + printf("meets you at the door, \"How are we doing today?\" He offers you a doughnut\n"); + printf("and coffee and asks what brings you here. This doesn\'t seem so bad, so you\n"); + printf("tell him that you have come to confess some possible security lapses. He\n"); + printf("smiles knowingly, deftly catching your coffee as you slump to the floor.\n"); + printf("\"Nothing to be alarmed about; it\'s just the truth serum,\" he says,\n"); + printf("dragging you back into a discussion room.\n"); + printf("The next five hours are a dim haze, but you can recall snatches of conversation\n"); + printf("about your secret society, your mutant power, and your somewhat paranoid\n"); + printf("distrust of The Computer. This should explain why you are hogtied and moving\n"); + printf("slowly down the conveyer belt towards the meat processing unit in Food\n"); + printf("Services.\n"); + if (computer_request==1) return new_clone(45); + else return new_clone(32); +} + +page3() +{ + printf("You walk to the nearest Computer terminal and request more information about\n"); + printf("Christmas. The Computer says, \"That is an A-1 ULTRAVIOLET ONLY IMMEDIATE\n"); + printf("TERMINATION classified topic. What is your clearance please, Troubleshooter?\"\n"); + return choose(4,"You give your correct clearance",5,"You lie and claim Ultraviolet clearance"); +} + +page4() +{ + printf("\"That is classified information, Troubleshooter, thank you for your inquiry.\n"); + printf(" Please report to an Internal Security self incrimination station as soon as\n"); + printf(" possible.\"\n"); + return 9; +} + +page5() +{ + printf("The computer says, \"Troubleshooter, you are not wearing the correct colour\n"); + printf("uniform. You must put on an Ultraviolet uniform immediately. I have seen to\n"); + printf("your needs and ordered one already; it will be here shortly. Please wait with\n"); + printf("your back to the wall until it arrives.\" In less than a minute an infrared\n"); + printf("arrives carrying a white bundle. He asks you to sign for it, then hands it to\n"); + printf("you and stands back, well outside of a fragmentation grenade\'s blast radius.\n"); + return choose(6, "You open the package and put on the uniform", 7, "You finally come to your senses and run for it"); +} + +page6() +{ + printf("The uniform definitely makes you look snappy and pert. It really looks\n"); + printf("impressive, and even has the new lopsided lapel fashion that you admire so\n"); + printf("much. What\'s more, citizens of all ranks come to obsequious attention as you\n"); + printf("walk past. This isn\'t so bad being an Ultraviolet. You could probably come\n"); + printf("to like it, given time.\n"); + printf("The beeping computer terminal interrupts your musings.\n"); + ultra_violet=1; + return 8; +} + +page7() +{ + printf("The corridor lights dim and are replaced by red battle lamps as the Security\n"); + printf("Breach alarms howl all around you. You run headlong down the corridor and\n"); + printf("desperately windmill around a corner, only to collide with a squad of 12 Blue\n"); + printf("clearance Vulture squadron soldiers. \"Stop, Slime Face,\" shouts the\n"); + printf("commander, \"or there won\'t be enough of you left for a tissue sample.\"\n"); + printf("\"All right, soldiers, stuff the greasy traitor into the uniform,\" he orders,\n"); + printf("waving the business end of his blue laser scant inches from your nose.\n"); + printf("With his other hand he shakes open a white bundle to reveal a pristine new\n"); + printf("Ultraviolet citizen's uniform.\n"); + printf("One of the Vulture squadron Troubleshooters grabs you by the neck in the\n"); + printf("exotic and very painful Vulture Clamp(tm) death grip (you saw a special about\n"); + printf("it on the Teela O\'Malley show), while the rest tear off your clothes and\n"); + printf("force you into the Ultraviolet uniform. The moment you are dressed they step\n"); + printf("clear and stand at attention.\n"); + printf("\"Thank you for your cooperation, sir,\" says the steely eyed leader of the\n"); + printf("Vulture Squad. \"We will be going about our business now.\" With perfect\n"); + printf("timing the Vultures wheel smartly and goosestep down the corridor.\n"); + printf("Special Note: don\'t make the mistake of assuming that your skills have\n"); + printf("improved any because of the uniform; you\'re only a Red Troubleshooter\n"); + printf("traitorously posing as an Ultraviolet, and don\'t you forget it!\n"); + printf("Suddenly, a computer terminal comes to life beside you.\n"); + ultra_violet=1; + return 8; +} + +page8() +{ + printf("\"Now, about your question, citizen. Christmas was an old world marketing ploy\n"); + printf("to induce lower clearance citizens to purchase vast quantities of goods, thus\n"); + printf("accumulation a large amount of credit under the control of a single class of\n"); + printf("citizen known as Retailers. The strategy used is to imply that all good\n"); + printf("citizens give gifts during Christmas, thus if one wishes to be a valuable\n"); + printf("member of society one must also give gifts during Christmas. More valuable\n"); + printf("gifts make one a more valuable member, and thus did the Retailers come to\n"); + printf("control a disproportionate amount of the currency. In this way Christmas\n"); + printf("eventually caused the collapse of the old world. Understandably, Christmas\n"); + printf("has been declared a treasonable practice in Alpha Complex.\n"); + printf("Thank you for your inquiry.\"\n"); + printf("You continue on your way to GDH7-beta.\n"); + return 10; +} + +page9() +{ + int choice; + printf("As you walk toward the tubecar that will take you to GDH7-beta, you pass one\n"); + printf("of the bright blue and orange Internal Security self incrimination stations.\n"); + printf("Inside, you can see an IS agent cheerfully greet an infrared citizen and then\n"); + printf("lead him at gunpoint into one of the rubber lined discussion rooms.\n"); + choice=choose(2,"You decide to stop here and chat, as ordered by The Computer",10,"You just continue blithely on past"); + if (choice==2) computer_request = 1; + else computer_request = 0; + return choice; +} + +page10() +{ + int choice; + printf("You stroll briskly down the corridor, up a ladder, across an unrailed catwalk,\n"); + printf("under a perilously swinging blast door in urgent need of repair, and into\n"); + printf("tubecar grand central. This is the bustling hub of Alpha Complex tubecar\n"); + printf("transportation. Before you spreads a spaghetti maze of magnalift tube tracks\n"); + printf("and linear accelerators. You bravely study the specially enhanced 3-D tube\n"); + printf("route map; you wouldn\'t be the first Troubleshooter to take a fast tube ride\n"); + printf("to nowhere.\n"); + if (ultra_violet==0) + { + choice=choose(3,"You decide to ask The Computer about Christmas using a nearby terminal",10,"You think you have the route worked out, so you\'ll board a tube train"); + if (choice==3) return choice; + }; + printf("You nervously select a tubecar and step aboard.\n"); + if (dice_roll(2,10)(MAXKILL-clone)) return 21; + if (read_letter==1) return 22; + return choose(34,"You search the body, keeping an eye open for Internal Security",22,"You run away like the cowardly dog you are"); +} + +page20() +{ + printf("Oh no! you can\'t keep your balance. You\'re falling, falling head first into\n"); + printf("the Christmas beast\'s gaping maw. It\'s a valiant struggle; you think you are\n"); + printf("gone when its poisonous needles dig into your flesh, but with a heroic effort\n"); + printf("you jerk a string of lights free and jam the live wires into the creature\'s\n"); + printf("spine. The Christmas beast topples to the ground and begins to burn, filling\n"); + printf("the area with a thick acrid smoke. It takes only a moment to compose yourself,\n"); + printf("and then you are ready to continue your search for the Master Retailer.\n"); + return 22; +} + +page21() +{ + printf("You have been wasting the leading citizens of Alpha Complex at a prodigious\n"); + printf("rate. This has not gone unnoticed by the Internal Security squad at GDH7-beta.\n"); + printf("Suddenly, a net of laser beams spear out of the gloomy corners of the hall,\n"); + printf("chopping you into teeny, weeny bite size pieces.\n"); + return new_clone(45); +} + +page22() +{ + printf("You are searching Goods Distribution Hall 7-beta.\n"); + switch(dice_roll(1,4)) + { + case 1: return 18; + case 2: return 15; + case 3: return 18; + case 4: return 29; + } +} + +page23() +{ + printf("You go to the nearest computer terminal and declare yourself a mutant.\n"); + printf("\"A mutant, he\'s a mutant,\" yells a previously unnoticed infrared who had\n"); + printf("been looking over your shoulder. You easily gun him down, but not before a\n"); + printf("dozen more citizens take notice and aim their weapons at you.\n"); + return choose(28,"You tell them that it was really only a bad joke",24,"You want to fight it out, one against twelve"); +} + +page24() +{ + printf("Golly, I never expected someone to pick this. I haven\'t even designed\n"); + printf("the 12 citizens who are going to make a sponge out of you. Tell you what,\n"); + printf("I\'ll give you a second chance.\n"); + return choose(28,"You change your mind and say it was only a bad joke",25,"You REALLY want to shoot it out"); +} + +page25() +{ + printf("Boy, you really can\'t take a hint!\n"); + printf("They\'re closing in. Their trigger fingers are twitching, they\'re about to\n"); + printf("shoot. This is your last chance.\n"); + return choose(28,"You tell them it was all just a bad joke",26,"You are going to shoot"); +} + +page26() +{ + printf("You can read the cold, sober hatred in their eyes (They really didn\'t think\n"); + printf("it was funny), as they tighten the circle around you. One of them shoves a\n"); + printf("blaster up your nose, but that doesn\'t hurt as much as the multi-gigawatt\n"); + printf("carbonium tipped food drill in the small of your back.\n"); + printf("You spend the remaining micro-seconds of your life wondering what you did wrong\n"); + return new_clone(32); +} + +page27() +{ + /* doesn't exist. Can't happen with computer version. + designed to catch dice cheats */ +} + +page28() +{ + printf("They don\'t think it\'s funny.\n"); + return 26; +} + +page29() +{ + printf("\"Psst, hey citizen, come here. Pssfft,\" you hear. When you peer around\n"); + printf("you can see someone\'s dim outline in the shadows. \"I got some information\n"); + printf("on the Master Retailer. It\'ll only cost you 30 psst credits.\"\n"); + printf("\nSelect \'a\', \'b\' or \'c\' :\n"); + printf(" a - You pay the 30 credits for the info.\n"); + printf(" b - You would rather threaten him for the information.\n"); + printf(" c - You ignore him and walk away.\n"); + switch(get_char()) + { + case 'a' : return 30; + case 'b' : return 31; + case 'c' : + default : return 22; + } +} + +page30() +{ + printf("You step into the shadows and offer the man a thirty credit bill. \"Just drop\n"); + printf("it on the floor,\" he says. \"So you\'re looking for the Master Retailer, pssfft?\n"); + printf("I\'ve seen him, he\'s a fat man in a fuzzy red and white jump suit. They say\n"); + printf("he\'s a high programmer with no respect for proper security. If you want to\n"); + printf("find him then pssfft step behind me and go through the door.\"\n"); + printf("Behind the man is a reinforced plasteel blast door. The centre of it has been\n"); + printf("buckled toward you in a manner you only saw once before when you were field\n"); + printf("testing the rocket assist plasma slingshot (you found it easily portable but\n"); + printf("prone to misfire). Luckily it isn\'t buckled too far for you to make out the\n"); + printf("warning sign. WARNING!! Don\'t open this door or the same thing will happen to\n"); + printf("you. Opening this door is a capital offense. Do not do it. Not at all. This\n"); + printf("is not a joke.\n"); + printf("\nSelect \'a\', \'b\' or \'c\' :\n"); + printf(" a - You use your Precognition mutant power on opening the door.\n"); + printf(" b - You just go through the door anyway.\n"); + printf(" c - You decide it\'s too dangerous and walk away.\n"); + switch(get_char()) + { + case 'a' : return 56; + case 'b' : return 33; + case 'c' : + default : return 22; + } +} + +page31() +{ + printf("Like any good troubleshooter you make the least expensive decision and threaten\n"); + printf("him for information. With lightning like reflexes you whip out your laser and\n"); + printf("stick it up his nose. \"Talk, you traitorous Christmas celebrator, or who nose\n"); + printf("what will happen to you, yuk yuk,\" you pun menacingly, and then you notice\n"); + printf("something is very wrong. He doesn\'t have a nose. As a matter of fact he\'s\n"); + printf("made of one eighth inch cardboard and your laser is sticking through the other\n"); + printf("side of his head. \"Are you going to pay?\" says his mouth speaker,\n"); + printf("\"or are you going to pssfft go away stupid?\"\n"); + return choose(30,"You pay the 30 credits",22,"You pssfft go away stupid"); +} + +page32() +{ + printf("Finally it\'s your big chance to prove that you\'re as good a troubleshooter\n"); + printf("as your previous clone. You walk briskly to mission briefing and pick up your\n"); + printf("previous clone\'s personal effects and notepad. After reviewing the notes you\n"); + printf("know what has to be done. You catch the purple line to Goods Distribution Hall\n"); + printf("7-beta and begin to search for the blast door.\n"); + return 22; +} + +page33() +{ + blast_door=1; + printf("You release the megabolts on the blast door, then strain against it with your\n"); + printf("awesome strength. Slowly the door creaks open. You bravely leap through the\n"); + printf("opening and smack your head into the barrel of a 300 mm \'ultra shock\' class\n"); + printf("plasma cannon. It\'s dark in the barrel now, but just before your head got\n"); + printf("stuck you can remember seeing a group of technicians anxiously watch you leap\n"); + printf("into the room.\n"); + if (ultra_violet==1) return 35; + else return 36; +} + +page34() +{ + printf("You have found a sealed envelope on the body. You open it and read:\n"); + printf("\"WARNING: Ultraviolet Clearance ONLY. DO NOT READ.\n"); + printf("Memo from Chico-U-MRX4 to Harpo-U-MRX5.\n"); + printf("The planned takeover of the Troubleshooter Training Course goes well, Comrade.\n"); + printf("Once we have trained the unwitting bourgeois troubleshooters to work as\n"); + printf("communist dupes, the overthrow of Alpha Complex will be unstoppable. My survey\n"); + printf("of the complex has convinced me that no one suspects a thing; soon it will be\n"); + printf("too late for them to oppose the revolution. The only thing that could possibly\n"); + printf("impede the people\'s revolution would be someone alerting The Computer to our\n"); + printf("plans (for instance, some enterprising Troubleshooter could tell The Computer\n"); + printf("that the communists have liberated the Troubleshooter Training Course and plan\n"); + printf("to use it as a jumping off point from which to undermine the stability of all\n"); + printf("Alpha Complex), but as we both know, the capitalistic Troubleshooters would\n"); + printf("never serve the interests of the proletariat above their own bourgeois desires.\n"); + printf("P.S. I\'m doing some Christmas shopping later today. Would you like me to pick\n"); + printf("you up something?\"\n"); + more(); + printf("When you put down the memo you are overcome by that strange deja\'vu again.\n"); + printf("You see yourself talking privately with The Computer. You are telling it all\n"); + printf("about the communists\' plan, and then the scene shifts and you see yourself\n"); + printf("showered with awards for foiling the insidious communist plot to take over the\n"); + printf("complex.\n"); + read_letter=1; + return choose(46,"You rush off to the nearest computer terminal to expose the commies",22,"You wander off to look for more evidence"); +} + +page35() +{ + printf("\"Oh master,\" you hear through the gun barrel, \"where have you been? It is\n"); + printf("time for the great Christmas gifting ceremony. You had better hurry and get\n"); + printf("the costume on or the trainee may begin to suspect.\" For the second time\n"); + printf("today you are forced to wear attire not of your own choosing. They zip the\n"); + printf("suit to your chin just as you hear gunfire erupt behind you.\n"); + printf("\"Oh no! Who left the door open? The commies will get in. Quick, fire the\n"); + printf("laser cannon or we\'re all doomed.\"\n"); + printf("\"Too late you capitalist swine, the people\'s revolutionary strike force claims\n"); + printf("this cannon for the proletariat\'s valiant struggle against oppression. Take\n"); + printf("that, you running dog imperialist lackey. ZAP, KAPOW\"\n"); + printf("Just when you think that things couldn\'t get worse, \"Aha, look what we have\n"); + printf("here, the Master Retailer himself with his head caught in his own cannon. His\n"); + printf("death will serve as a symbol of freedom for all Alpha Complex.\n"); + printf("Fire the cannon.\"\n"); + return new_clone(32); +} + +page36() +{ + printf("\"Congratulations, troubleshooter, you have successfully found the lair of the\n"); + printf("Master Retailer and completed the Troubleshooter Training Course test mission,\"\n"); + printf("a muffled voice tells you through the barrel. \"Once we dislodge your head\n"); + printf("from the barrel of the \'Ultra Shock\' plasma cannon you can begin with the\n"); + printf("training seminars, the first of which will concern the 100%% accurate\n"); + printf("identification and elimination of unregistered mutants. If you have any\n"); + printf("objections please voice them now.\"\n"); + printf("\nSelect \'a\', \'b\' or \'c\' :\n"); + printf(" a - You appreciate his courtesy and voice an objection.\n"); + printf(" b - After your head is removed from the cannon, you register as a mutant.\n"); + printf(" c - After your head is removed from the cannon, you go to the unregistered\n"); + printf(" mutant identification and elimination seminar.\n"); + switch(get_char()) + { + case 'a' : return new_clone(32); + case 'b' : return 23; + case 'c' : + default : return 37; + } +} + +page37() +{ + printf("\"Come with me please, Troubleshooter,\" says the Green clearance technician\n"); + printf("after he has dislodged your head from the cannon. \"You have been participating\n"); + printf("in the Troubleshooter Training Course since you got off the tube car in\n"); + printf("GDH7-beta,\" he explains as he leads you down a corridor. \"The entire\n"); + printf("Christmas assignment was a test mission to assess your current level of\n"); + printf("training. You didn\'t do so well. We\'re going to start at the beginning with\n"); + printf("the other student. Ah, here we are, the mutant identification and elimination\n"); + printf("lecture.\" He shows you into a vast lecture hall filled with empty seats.\n"); + printf("There is only one other student here, a Troubleshooter near the front row\n"); + printf("playing with his Action Troubleshooter(tm) figure. \"Find a seat and I will\n"); + printf("begin,\" says the instructor.\n"); + return 38; +} + +page38() +{ + printf("\"I am Plato-B-PHI%d, head of mutant propaganda here at the training course.\n",plato_clone); + printf("If you have any questions about mutants please come to me. Today I will be\n"); + printf("talking about mutant detection. Detecting mutants is very easy. One simply\n"); + printf("watches for certain tell tale signs, such as the green scaly skin, the third\n"); + printf("arm growing from the forehead, or other similar disfigurements so common with\n"); + printf("their kind. There are, however, a few rare specimens that show no outward sign\n"); + printf("of their treason. This has been a significant problem, so our researchers have\n"); + printf("been working on a solution. I would like a volunteer to test this device,\"\n"); + printf("he says, holding up a ray gun looking thing. \"It is a mutant detection ray.\n"); + printf("This little button detects for mutants, and this big button stuns them once\n"); + printf("they are discovered. Who would like to volunteer for a test?\"\n"); + printf("The Troubleshooter down the front squirms deeper into his chair.\n"); + return choose(39,"You volunteer for the test",40,"You duck behind a chair and hope the instructor doesn\'t notice you"); +} + +page39() +{ + printf("You bravely volunteer to test the mutant detection gun. You stand up and walk\n"); + printf("down the steps to the podium, passing a very relieved Troubleshooter along the\n"); + printf("way. When you reach the podium Plato-B-PHI hands you the mutant detection gun\n"); + printf("and says, \"Here, aim the gun at that Troubleshooter and push the small button.\n"); + printf("If you see a purple light, stun him.\" Grasping the opportunity to prove your\n"); + printf("worth to The Computer, you fire the mutant detection ray at the Troubleshooter.\n"); + printf("A brilliant purple nimbus instantly surrounds his body. You slip your finger\n"); + printf("to the large stun button and he falls writhing to the floor.\n"); + printf("\"Good shot,\" says the instructor as you hand him the mutant detection gun,\n"); + printf("\"I\'ll see that you get a commendation for this. It seems you have the hang\n"); + printf("of mutant detection and elimination. You can go on to the secret society\n"); + printf("infiltration class. I\'ll see that the little mutie gets packaged for\n"); + printf("tomorrow\'s mutant dissection class.\"\n"); + return 41; +} + +page40() +{ + printf("You breathe a sigh of relief as Plato-B-PHI picks on the other Troubleshooter.\n"); + printf("\"You down here in the front,\" says the instructor pointing at the other\n"); + printf("Troubleshooter, \"you\'ll make a good volunteer. Please step forward.\"\n"); + printf("The Troubleshooter looks around with a \`who me?\' expression on his face, but\n"); + printf("since he is the only one visible in the audience he figures his number is up.\n"); + printf("He walks down to the podium clutching his Action Troubleshooter(tm) doll before\n"); + printf("him like a weapon. \"Here,\" says Plato-B-PHI, \"take the mutant detection ray\n"); + printf("and point it at the audience. If there are any mutants out there we\'ll know\n"); + printf("soon enough.\" Suddenly your skin prickles with static electricity as a bright\n"); + printf("purple nimbus surrounds your body. \"Ha Ha, got one,\" says the instructor.\n"); + printf("\"Stun him before he gets away.\"\n"); + more(); + while(1) + { + if (dice_roll(1,100)<=30) + { + printf("His shot hits you. You feel numb all over.\n"); + return 49; + } + else printf("His shot just missed.\n"); + + if (dice_roll(1,100)<=40) + { + printf("You just blew his head off. His lifeless hand drops the mutant detector ray.\n"); + return 50; + } + else printf("You burnt a hole in the podium. He sights the mutant detector ray on you.\n"); + } +} + +page41() +{ + printf("You stumble down the hallway of the Troubleshooter Training Course looking for\n"); + printf("your next class. Up ahead you see one of the instructors waving to you. When\n"); + printf("you get there he shakes your hand and says, \"I am Jung-I-PSY. Welcome to the\n"); + printf("secret society infiltration seminar. I hope you ...\" You don\'t catch the\n"); + printf("rest of his greeting because you\'re paying too much attention to his handshake;\n"); + printf("it is the strangest thing that has ever been done to your hand, sort of how it\n"); + printf("would feel if you put a neuro whip in a high energy palm massage unit.\n"); + printf("It doesn\'t take you long to learn what he is up to; you feel him briefly shake\n"); + printf("your hand with the secret Illuminati handshake.\n"); + return choose(42,"You respond with the proper Illuminati code phrase, \"Ewige Blumenkraft\"",43,"You ignore this secret society contact"); +} + +page42() +{ + printf("\"Aha, so you are a member of the elitist Illuminati secret society,\" he says\n"); + printf("loudly, \"that is most interesting.\" He turns to the large class already\n"); + printf("seated in the auditorium and says, \"You see, class, by simply using the correct\n"); + printf("hand shake you can identify the member of any secret society. Please keep your\n"); + printf("weapons trained on him while I call a guard.\n"); + return choose(51,"You run for it",52,"You wait for the guard"); +} + +page43() +{ + printf("You sit through a long lecture on how to recognise and infiltrate secret\n"); + printf("societies, with an emphasis on mimicking secret handshakes. The basic theory,\n"); + printf("which you realise to be sound from your Iluminati training, is that with the\n"); + printf("proper handshake you can pass unnoticed in any secret society gathering.\n"); + printf("What\'s more, the proper handshake will open doors faster than an \'ultra shock\'\n"); + printf("plasma cannon. You are certain that with the information you learn here you\n"); + printf("will easily be promoted to the next level of your Illuminati secret society.\n"); + printf("The lecture continues for three hours, during which you have the opportunity\n"); + printf("to practice many different handshakes. Afterwards everyone is directed to\n"); + printf("attend the graduation ceremony. Before you must go you have a little time to\n"); + printf("talk to The Computer about, you know, certain topics.\n"); + return choose(44,"You go looking for a computer terminal",55,"You go to the graduation ceremony immediately"); +} + +page44() +{ + printf("You walk down to a semi-secluded part of the training course complex and\n"); + printf("activate a computer terminal. \"AT YOUR SERVICE\" reads the computer screen.\n"); + if (read_letter==0) return choose(23,"You register yourself as a mutant",55,"You change your mind and go to the graduation ceremony"); + printf("\nSelect \'a\', \'b\' or \'c\' :\n"); + printf(" a - You register yourself as a mutant.\n"); + printf(" b - You want to chat about the commies.\n"); + printf(" c - You change your mind and go to the graduation ceremony.\n"); + switch(get_char()) + { + case 'a' : return 23; + case 'b' : return 46; + case 'c' : + default : return 55; + } +} + +page45() +{ + printf("\"Hrank Hrank,\" snorts the alarm in your living quarters. Something is up.\n"); + printf("You look at the monitor above the bathroom mirror and see the message you have\n"); + printf("been waiting for all these years. \"ATTENTION TROUBLESHOOTER, YOU ARE BEING\n"); + printf("ACTIVATED. PLEASE REPORT IMMEDIATELY TO MISSION ASSIGNMENT ROOM A17/GAMMA/LB22.\n"); + printf("THANK YOU. THE COMPUTER IS YOUR FRIEND.\" When you arrive at mission\n"); + printf("assignment room A17-gamma/LB22 you are given your previous clone\'s\n"); + printf("remaining possessions and notebook. You puzzle through your predecessor\'s\n"); + printf("cryptic notes, managing to decipher enough to lead you to the tube station and\n"); + printf("the tube car to GDH7-beta.\n"); + return 10; +} + +page46() +{ + printf("\"Why do you ask about the communists, Troubleshooter? It is not in the\n"); + printf("interest of your continued survival to be asking about such topics,\" says\n"); + printf("The Computer.\n"); + return choose(53,"You insist on talking about the communists",54,"You change the subject"); +} + +page47() +{ + printf("The Computer orders the entire Vulture squadron to terminate the Troubleshooter\n"); + printf("Training Course. Unfortunately you too are terminated for possessing\n"); + printf("classified information.\n\n"); + printf("Don\'t act so innocent, we both know that you are an Illuminatus which is in\n"); + printf("itself an act of treason.\n\n"); + printf("Don\'t look to me for sympathy.\n\n"); + printf(" THE END\n"); + return 0; +} + +page48() +{ + printf("The tubecar shoots forward as you enter, slamming you back into a pile of\n"); + printf("garbage. The front end rotates upward and you, the garbage and the garbage\n"); + printf("disposal car shoot straight up out of Alpha Complex. One of the last things\n"); + printf("you see is a small blue sphere slowly dwindling behind you. After you fail to\n"); + printf("report in, you will be assumed dead.\n"); + return new_clone(45); +} + +page49() +{ + printf("The instructor drags your inert body into a specimen detainment cage.\n"); + printf("\"He\'ll make a good subject for tomorrow\'s mutant dissection class,\" you hear.\n"); + return new_clone(32); +} + +page50() +{ + printf("You put down the other Troubleshooter, and then wisely decide to drill a few\n"); + printf("holes in the instructor as well; the only good witness is a dead witness.\n"); + printf("You continue with the training course.\n"); + plato_clone++; + return 41; +} + +page51() +{ + printf("You run for it, but you don\'t run far. Three hundred strange and exotic\n"); + printf("weapons turn you into a freeze dried cloud of soot.\n"); + return new_clone(32); +} + +page52() +{ + printf("You wisely wait until the instructor returns with a Blue Internal Security\n"); + printf("guard. The guard leads you to an Internal Security self incrimination station.\n"); + return 2; +} + +page53() +{ + printf("You tell The Computer about:\n"); + return choose(47,"The commies who have infiltrated the Troubleshooter Training Course\n and the impending People\'s Revolution",54,"Something less dangerous"); +} + +page54() +{ + printf("\"Do not try to change the subject, Troubleshooter,\" says The Computer.\n"); + printf("\"It is a serious crime to ask about the communists. You will be terminated\n"); + printf("immediately. Thank you for your inquiry. The Computer is your friend.\"\n"); + printf("Steel bars drop to your left and right, trapping you here in the hallway.\n"); + printf("A spotlight beams from the computer console to brilliantly iiluminate you while\n"); + printf("the speaker above your head rapidly repeats \"Traitor, Traitor, Traitor.\"\n"); + printf("It doesn\'t take long for a few guards to notice your predicament and come to\n"); + printf("finish you off.\n"); + if (blast_door==0) return new_clone(45); + else return new_clone(32); +} + +page55() +{ + printf("You and 300 other excited graduates are marched from the lecture hall and into\n"); + printf("a large auditorium for the graduation exercise. The auditorium is\n"); + printf("extravagantly decorated in the colours of the graduating class. Great red and\n"); + printf("green plasti-paper ribbons drape from the walls, while a huge sign reading\n"); + printf("\"Congratulations class of GDH7-beta-203.44/A\" hangs from the raised stage down\n"); + printf("front. Once everyone finds a seat the ceremony begins. Jung-I-PSY is the\n"); + printf("first to speak, \"Congratulations students, you have successfully survived the\n"); + printf("Troubleshooter Training Course. It always brings me great pride to address\n"); + printf("the graduating class, for I know, as I am sure you do too, that you are now\n"); + printf("qualified for the most perilous missions The Computer may select for you. The\n"); + printf("thanks is not owed to us of the teaching staff, but to all of you, who have\n"); + printf("persevered and graduated. Good luck and die trying.\" Then the instructor\n"); + printf("begins reading the names of the students who one by one walk to the front of\n"); + printf("the auditorium and receive their diplomas. Soon it is your turn,\n"); + printf("\"Philo-R-DMD, graduating a master of mutant identification and secret society\n"); + printf("infiltration.\" You walk up and receive your diploma from Plato-B-PHI%d, then\n",plato_clone); + printf("return to your seat. There is another speech after the diplomas are handed\n"); + printf("out, but it is cut short by by rapid fire laser bursts from the high spirited\n"); + printf("graduating class. You are free to return to your barracks to wait, trained\n"); + printf("and fully qualified, for your next mission. You also get that cherished\n"); + printf("promotion from the Illuminati secret society. In a week you receive a\n"); + printf("detailed Training Course bill totalling 1,523 credits.\n"); + printf(" THE END\n"); + return 0; +} + +page56() +{ + printf("That familiar strange feeling of deja\'vu envelops you again. It is hard to\n"); + printf("say, but whatever is on the other side of the door does not seem to be intended\n"); + printf("for you.\n"); + return choose(33,"You open the door and step through",22,"You go looking for more information"); +} + +page57() +{ + printf("In the centre of the room is a table and a single chair. There is an Orange\n"); + printf("folder on the table top, but you can\'t make out the lettering on it.\n"); + return choose(11,"You sit down and read the folder",12,"You leave the room"); +} + +next_page(this_page) +int this_page; +{ + printf("\n"); + switch (this_page) + { + case 0 : return 0; + case 1 : return page1(); + case 2 : return page2(); + case 3 : return page3(); + case 4 : return page4(); + case 5 : return page5(); + case 6 : return page6(); + case 7 : return page7(); + case 8 : return page8(); + case 9 : return page9(); + case 10 : return page10(); + case 11 : return page11(); + case 12 : return page12(); + case 13 : return page13(); + case 14 : return page14(); + case 15 : return page15(); + case 16 : return page16(); + case 17 : return page17(); + case 18 : return page18(); + case 19 : return page19(); + case 20 : return page20(); + case 21 : return page21(); + case 22 : return page22(); + case 23 : return page23(); + case 24 : return page24(); + case 25 : return page25(); + case 26 : return page26(); + case 27 : return page27(); + case 28 : return page28(); + case 29 : return page29(); + case 30 : return page30(); + case 31 : return page31(); + case 32 : return page32(); + case 33 : return page33(); + case 34 : return page34(); + case 35 : return page35(); + case 36 : return page36(); + case 37 : return page37(); + case 38 : return page38(); + case 39 : return page39(); + case 40 : return page40(); + case 41 : return page41(); + case 42 : return page42(); + case 43 : return page43(); + case 44 : return page44(); + case 45 : return page45(); + case 46 : return page46(); + case 47 : return page47(); + case 48 : return page48(); + case 49 : return page49(); + case 50 : return page50(); + case 51 : return page51(); + case 52 : return page52(); + case 53 : return page53(); + case 54 : return page54(); + case 55 : return page55(); + case 56 : return page56(); + case 57 : return page57(); + default : break; + } +} + +main() +{ + /* srand(time(0)); */ + instructions(); more(); + character(); more(); + while((page=next_page(page))!=0) more(); +}