The Bridge of Death (Source Code)

  • Release 1 (2016-02-12)
    • Initial release.
  • Release 2 (2016-02-17)
    • Added a routine to choose the final question.
    • Re-arranged questions so the always wrong question has the least chance of being chosen.
    • Added a PANIC and DON’T PANIC command for some additional comic effect.
    • Added end the game routines, and changed Eternal Peril so the game doesn’t end immediately.
    • Fixed the ultimate question so the answer can be 42 or forty-two.
  • Release 3
    • Eliminated the setting of variables when play beings.
    • Changed question answer checking from choosing a table row to repeating through the table.
  • Release 4
    • Added prologue.
    • Fixed bug concerning matching in lower case vs. case insensitively with Xyzzy and Text Fiction Android apps.
    • Added bridgekeeper photo for Glulx version.
  • Release 5 (2018-10-26)
    • Revised and updated final question content and frequency.
    • Fixed reference to bridgekeeper’s picture.
    • Added support for HELP command.
    • Made minor improvements to some commands and responses.
    • Added a knight to the list of knights you can name.
  • Release 6 (2019-11-22)
    • Reorganized source code.
    • Made minor improvements.
    • Added a coconut.
  • Release 7 (2023-11-25)
    • Rebuilt project using latest Inform 7.
    • Added an action for banging two halves of a coconut together.
    • Replaced one final question and re-arranged a couple questions.
"The Bridge of Death" by "A. J. Mako"

The story headline is "Do you have what it takes to cross the 
    Bridge of Death?".
The story genre is "Comedy".
The story creation year is 2016.
The release number is 7. 
The story description is "This is an adaptation of the scene from 
    Monty Python and the Holly Grail, used exclusively as a learning 
    exercise."

Release along with cover art, a solution, the source text, the library 
    card, and the "Quixe" interpreter.

Figure of BridgeKeeper is the file "bridgekeeper.png".

Include Basic Screen Effects by Emily Short.
Include Glulx Image Centering by Emily Short.

Volume 1 - Globals

flagQuestContinues is initially false.
countQuestionsAnswered is initially 0.
countInPeril is initially 0.
numFinalQuestion is initially 0.

The description of the player is "As resplendent as ever in [our] regalia 
    as one of the famous Knights of the Round Table."

Volume 2 - Start Up

When play begins:
	say "[bold type]England 932 A. D.[roman type][paragraph break]
[bold type]The story so far...[roman type][paragraph break]Arthur, son of 
Urthur Pendragon, King of the Britons has ridden the width and breadth of 
the land in search of knights who would join him in his court at Camelot. 
After repressing a bloody peasant, dismembering an invincible Black 
Knight, and helping to erroneously convict and therefore cause the burning
of an alleged witch, Arthur was tasked by God to find the Holy Grail.
[paragraph break]The quest began ominously with Arthur and his Knights of 
the Round Table being taunted by some Frenchmen. Defeat at the French 
castle utterly disheartened King Arthur. The ferocity of the French 
taunting took him completely by surprise.[paragraph break]Please press 
SPACE to continue.[paragraph break]";
	wait for the SPACE key;
	say "So, the Knights separated and searched for the Grail 
individually. Sir Robin rode north where he bravely ran away from the 
dreaded Three-Headed Knight. Sir Galahad was rescued from almost certain 
temptation at the hands of the sisters of the Castle Anthrax. Sir 
Lancelot, having saved Sir Galahad, continued his search by single-
handedly sacking Swamp Castle.[paragraph break]Meanwhile, Arthur 
discovered a vital clue from the old man from Scene 24. He learned of Tim 
the Enchanter, the Cave of Caerbannog, the Gorge of Eternal Peril, and the
Bridge of Death. To continue the quest, Arthur was forced to say 'Ni' to 
an old crone in order to defeat the Knights Who Say Ni.[paragraph break]
Please press SPACE to continue.[paragraph break]";
	wait for the SPACE key;
	say "Arthur's Knights reassemble while searching for Tim the 
Enchanter. Many knights were defeated by the rabbit who guards the 
entrance to the Cave of Caerbannog, but Arthur proved finally victorious 
after using the Holy Hand Grenade of Antioch. Within the cave, Arthur 
discovered the last words of Joseph of Arimathea, which told of the final 
resting place of the Grail.[paragraph break]Now, having escaped the 
attack of the Legendary Black Beast of Arrrghhh, Arthur and his remaining 
knights approach the Bridge of Death...";
	pause the game.

Volume 3 - The Map

Book 1 - Rooms

Chapter 1 - The Edge of the Abyss

Edge_of_the_Abyss is a room. "The narrow path leads [us] to the edge of 
the Bridge of Death, which provides the only way across the Gorge of 
Eternal Peril. An eerie mist wanders up from the gorge and surrounds you 
eerily." The printed name is "The Edge of the Abyss".

Chapter 2 - Beyond the Abyss (The Far Beyond)

Far_Beyond is a room. "The narrow path leads [us] away from the edge of 
the Gorge of Eternal Peril. The Bridge of Death provides the only way 
back across the gorge. An eerie mist wanders up from the gorge and 
surrounds you eerily." The printed name is "Beyond the Abyss".

Chapter 3 - Eternal Peril

Eternal_Peril is a room. "All around [us] the mist swirls, obscuring the 
sky, the sides of the gorge, and even the ground. [We] continue to fall as
the peril engulfs [us] perilously." The printed name is "Eternal Peril".

Index map with Eternal_Peril mapped north of Edge_of_the_Abyss.
Index map with Far_Beyond mapped north of Eternal_Peril.

Book 2 - Scenery

Chapter 1 - The Bridge of Death

The BridgeOfDeath is a door. It is north of Edge_of_the_Abyss and south of
Far_Beyond. It is scenery. The description is "[bridge described]." The 
printed name is "bridge". The BridgeOfDeath is open and unopenable. 
Understand "bridge" as the BridgeOfDeath.

To say bridge described:
	if the location is Edge_of_the_Abyss:
		say "A rotting and dangerous looking bridge across a 
		    perilous, mist-filled gorge appears to be the only way
		    to continue [our] quest";
	otherwise if the location is Far_Beyond:
		say "A rotting and dangerous looking bridge across a 
		    perilous, mist-filled gorge [we] have just crossed. 
		    It no longer prevents [us] from continuing [our] 
		    quest"

Chapter 2 - The Gorge

The perilGorge is a backdrop. "An eerie mist billows forth, obscuring the 
bottomless gorge below." The printed name is "gorge". It is everywhere. 
Understand "mist", "gorge", "eternal", or "peril" as the perilGorge. 
Understand "edge" or "abyss" as the perilGorge.

Chapter 3 - The Path

The narrowPath is a backdrop. "[path described]." The printed name is 
"path". It is in Edge_of_the_Abyss and Far_Beyond. Understand "path" as 
the narrowPath.

To say path described:
	if the location is Edge_of_the_Abyss:
		say "The narrow, treacherous path leads back south into 
		    the Cave of Caerbannog, away from the bridge";
	otherwise if the location is Far_Beyond:
		say "The narrow, treacherous path leads north into the 
		    mist and away from the bridge".

Chapter 4 - The Cavern

The cavernCave is a backdrop in Edge_of_the_Abyss. "The steep, sharp sides
of the cavern disappear into the darkness from whence [we] came." The 
printed name is "cavern". Understand "cave" or "cavern" as the cavernCave.

Book 3 - Characters

Chapter 1 - The Bridge Keeper

The bridgeKeeper is a man in Edge_of_the_Abyss. The printed name is 
"Bridgekeeper". The initial appearance is "[We] can see the old man from 
Scene 24 here." The description is "The man is a broken-down example of a 
human being, with wild hair and blind eyes that peer in different 
directions and never at [us]." Understand "old man" or "bridge keeper" or 
"old man from scene 24" as the bridgeKeeper.

Book 4 - Things

Chapter 1 - The Coconut (Actually Two-Halves)

The coconutHalves is a thing. The printed name is "coconut". 
The description is "There are two halves to this coconut." The player 
carries it. Understand "coconut" or "coconuts" or "two halves" or "two 
halves of coconut" as the coconutHalves.

Volume 4 - Routines

Book 1 - Quips

To say rockface block:
	say "There's a solid rock cavern wall blocking [our] path".

To say gorge block:
	say "There are easier ways to get into the Gorge of Eternal Peril
	    than jumping down from here".

To say backup block:
	say "[We] could climb back up the cavern into the Cave of 
	    Caerbannog, but [our] quest is in the other direction".

To say crossing block:
	say "[We] successfully crossed the Bridge of Death. Crossing back 
	    is as useful as throwing [ourselves] into the Gorge of Eternal
	    Peril".

To say hillside block:
	say "The hill is rather steep and difficult to climb. If only 
	    there were a path [we] could follow to make travel easier".

Book 2 - Going Places

Chapter 1 - Retreating

Understand "go back" as retreating. Understand "back" or "return" or 
"retreat" as retreating. Retreating is an action applying to nothing.

Carry out retreating:
	if the location is Edge_of_the_Abyss, try going up instead;
	otherwise try going south instead.

Chapter 2 - Going Nowhere

instead of going nowhere:
	if the location is Edge_of_the_Abyss:
		if the noun is:
			-- south:
				say "[rockface block].";
			-- east:
				say "[rockface block].";
			-- west:
				say "[gorge block].";
			-- northeast:
				say "[gorge block].";
			-- northwest:
				say "[gorge block].";
			-- southeast:
				say "[rockface block].";
			-- southwest:
				say "[backup block].";
			-- up:
				say "[backup block].";
			-- down:
				say "[gorge block].";
	otherwise if the location is Far_Beyond:
		if the noun is:
			-- north:
				end the game victoriously;
			-- south:
				say "[crossing block].";
			-- east:
				say "[hillside block].";
			-- west:
				say "[hillside block].";
			-- northeast:
				say "[hillside block].";
			-- northwest:
				say "[hillside block].";
			-- southeast:
				say "[gorge block].";
			-- southwest:
				say "[gorge block].";
			-- up:
				end the game victoriously;
			-- down:
				say "[gorge block]."

Chapter 3 - Using the Bridge

Instead of going north from Edge_of_the_Abyss, try entering the 
BridgeOfDeath.

Instead of entering the BridgeOfDeath while flagQuestContinues is false:
	display the Figure of BridgeKeeper centered;
	say "'STOP![line break]Who would cross the bridge of death must 
	    answer me these questions three, ere the other side he see.' 
	    says the Bridgekeeper.";
	now the command prompt is "What is your name? >".

Instead of going south from Far_Beyond, try entering the BridgeOfDeath.

Instead of entering the BridgeOfDeath in Far_Beyond:
	say "[We] crossed that bridge already. Time to continue [our] 
	    quest.";
	stop the action.

Book 3 - Talking Operations

Instead of telling someone about something, try asking the noun about it. 
Instead of answering the noun that something, try asking the noun about 
it.

Instead of asking the bridgeKeeper about something:
	display the Figure of BridgeKeeper centered;
	if "[the topic understood]" matches the text "grail", case 
	insensitively:
		say "The bridgekeeper's blind eye stares blankly at [us] 
		    as he says 'Seek you the Bridge of Death.'";
	otherwise if "[the topic understood]" matches the text "cave", 
	case insensitively:
		say "The bridgekeeper's blind eye stares blankly at [us] 
		    as he says 'Heh, heh, heh, heh, heh. We know of a 
		    cave; a cave which no man has entered; the Cave of 
		    Caerbannog.'";
	otherwise if "[the topic understood]" matches the text "bridge", 
	case insensitively:
		say "The bridgekeeper's blind eye stares blankly at [us] 
		    as he says 'Who would cross the bridge of death must 
		    answer me these questions three, ere the other side he
		    see.'";
	otherwise if "[the topic understood]" matches the text "gorge", 
	case insensitively or "[the topic understood]" matches the text 
	"peril", case insensitively:
		say "The bridgekeeper's blind eye stares blankly at [us] 
		    as he says 'There is much danger, for beyond the cave 
		    lies the Gorge of Eternal Peril, which no man has ever 
		    crossed.'";
	otherwise if "[the topic understood]" matches the text "question",
	case insensitively:
		say "'STOP![line break]Who would cross the bridge of death
		    must answer me these questions three, ere the other 
		    side he see.' says the Bridgekeeper.";
		now the command prompt is "What is your name? >";
	otherwise:
		say "The bridgekeeper's blind eye stares blankly at [us] 
		    as he chuckles [one of]gleefully[or]colorfully[or]
		    laughingly[or]wickedly[or]naughtily[purely at random]."

Book 4 - Handling Questions

To decide whether collecting answers:
	if the command prompt is ">", no;
	yes.

To choose the final question:
	let N be a random number between 1 and 100;
	if N is less than 16:
		now numFinalQuestion is 1; 
	otherwise if N is less than 30:
		now numFinalQuestion is 2; 
	otherwise if N is less than 44:
		now numFinalQuestion is 3; 
	otherwise if N is less than 56:
		now numFinalQuestion is 4; 
	otherwise if N is less than 67:
		now numFinalQuestion is 5; 
	otherwise if N is less than 76:
		now numFinalQuestion is 6; 
	otherwise if N is less than 84:
		now numFinalQuestion is 7; 
	otherwise if N is less than 90:
		now numFinalQuestion is 8; 
	otherwise if N is less than 95:
		now numFinalQuestion is 9; 
	otherwise if N is less than 98:
		now numFinalQuestion is 10; 
	otherwise:
		now numFinalQuestion is 11. 

To complete failed questioning:
	now the command prompt is ">";
	say "The bridgekeeper chuckles gleefully and [we] are launched 
	    into the Gorge of Eternal Peril!";
	now the player is in Eternal_Peril.

To complete successful questioning:
	if the bridgeKeeper is in the location, say "The bridgekeeper says:
	    'Right, off you go.'";
	now the command prompt is ">".
	
To complete launching bridgekeeper:
	say "The bridgekeeper looks surprised and alarmed. 'What? I don't 
	    know that!' he says, before being launched into the Gorge of 
	    Eternal Peril.";
	now the bridgeKeeper is in Eternal_Peril;
	now flagQuestContinues is true;
	now countQuestionsAnswered is 3.

After reading a command when collecting answers:
	if countQuestionsAnswered is:
		-- 0:
			let txtLongName be some text;
			repeat through the Table of Allowed Names:
				if "[the player's command]" matches the 
				text "[shortname entry]", case 
				insensitively:
					now txtLongName is "[fullname 
					    entry]";
			if txtLongName is not empty:
				now countQuestionsAnswered is 1;
				say "The bridgekeeper says: 'Correct. Your
				    name is [txtLongName].'";
				now the command prompt is "What is your 
				    quest? >";
			otherwise:
				complete failed questioning;
				say "You might try remembering which 
				    knights appeared in the scene.";
		-- 1:
			if "[the player's command]" matches the text 
			"grail", case insensitively:
				choose the final question;
				choose row numFinalQuestion from the Table
				    of Final Questions;
				now countQuestionsAnswered is 2;
				say "The bridgekeeper says: 'Correct. Your 
				    quest is the Holy Grail.'";
				now the command prompt is "[query entry] >";
			otherwise:
				complete failed questioning;
				say "I would have thought the answer was 
				    obvious. Think 'Monty Python and...'";
		-- 2:
			repeat through the Table of Final Questions:
				if the id entry is the numFinalQuestion:
					if the numFinalQuestion is 1:
						now flagQuestContinues is 
						    true;
						now countQuestionsAnswered
						    is 3;
					otherwise if the numFinalQuestion 
					is 7:
						if "[the player's command]"
						matches the regular 
						expression "[answer entry]":
							complete launching
							    bridgekeeper;
					otherwise if the numFinalQuestion 
					is 2 or the numFinalQuestion is 3 
					or the numFinalQuestion is 4:
						if "[the player's command]" 
						matches the regular 
						expression "[answer entry]",
						case insensitively:
							now flagQuestContinues 
							    is true;
							now countQuestionsAnswered 
							    is 3;
					otherwise if the numFinalQuestion 
					is 11:
						now flagQuestContinues is 
						    false;
					otherwise if "[the player's command]" 
					matches the text "[answer entry]", 
					case insensitively:
						now flagQuestContinues is 
						    true;
						now countQuestionsAnswered 
						    is 3;
			if flagQuestContinues is false, complete failed 
			    questioning;
			otherwise complete successful questioning;
	reject the player's command.

Table of Final Questions
id	query							answer
1	"What is your favorite color?"	--
[NO CHEATING]

[The (revised) weighted list is used to select the third question. This 
list gives each question the following chance to be selected:
	
 1 =  15% (1-15)   = Source: Monty Python and the Holy Grail (1975)
 2 =  15% (16-30)  = Source: Monty Python and the Holy Grail (1975)
 3 =  14% (31-44)  = Source: The Hitchhiker's Guide to the Galaxy (1978)
 4 =  12% (45-56)  = Source: War Games (1983)
 5 =  11% (57-67)  = Source: Airplane! (1980)
 6 =   9% (68-76)  = Source: Star Trek: The Way to Eden (1969)
 7 =   8% (77-84)  = Source: Monty Python and the Holy Grail (1975)
 8 =   6% (85-90)  = Source: Ghostbusters (1984)
 9 =   5% (91-95)  = Source: The Wild One (1953)
10 =   3% (96-98)  = Source: 'The Last Question' by Isaac Asimov © 1956*
11 =   2% (99-100) = Source: Batman (1989)

* Full answer is: "INSUFFICIENT DATA FOR MEANINGFUL ANSWER"]

Table of Allowed Names
shortname		fullname
"arthur"		"Arthur, King of the Britons"
"lancelot"		"Sir Lancelot of Camelot"
"bedevere"		"Sir Bedevere of Camelot"
"galahad"		"Sir Galahad of Camelot"
"robin"			"Sir Robin of Camelot"
"not appearing"	"Sir Not-Appearing-In-This-Film"

Volume 5 - Actions

Chapter 1 - Panicking

Understand "panic" as panicking. Understand "scream for help" as 
panicking. Panicking is an action applying to nothing.

Carry out panicking:
	say "[one of]Not surprised.[or]No, no, no. DON'T panic![or]Would 
	    [we] like some toast?[at random]" instead.

Chapter 2 - Not Panicking

Understand "don't panic" as panicking anyway. 
Panicking anyway is an action applying to nothing.

Carry out panicking anyway:
	if the player is in Eternal_Peril:
		say "Very clever. It looks like there's a lot [we] should 
		    be panicking about." instead;
	otherwise:
		say "[one of]Why not? [Our] position appears quite 
		    hopeless[or][We] try [our] best. [We] fail[or]I always 
		    thought something was fundamentally wrong with the 
		    universe[at random]." instead.

Chapter 3 - Helping (Actually Not)

Understand "help" as summoning help. Summoning help is an action applying 
to nothing.

Carry out summoning help:
	if the player is in Eternal_Peril:
		say "There isn't much anyone can do for [us] now!" instead;
	otherwise:
		say "Why? Are [we] being repressed? [bracket]Bloody peasant.
		    [close bracket][paragraph break]" instead.

Chapter 4 - Clopping

Clopping is an action applying to one thing. Understand "bang [something]" 
as clopping. Understand "bang [something] together" as clopping.

Understand the commands "clap" and "clop" as "bang".

Check an actor clopping (this is the check clopping rule):
	if the noun is not the coconutHalves:
		say "I'm not sure how you could do that!";
		stop the action;
	otherwise if the player does not carry the noun:
		say "What [noun]?";
		stop the action.

Report an actor clopping (this is the report clopping rule):
	say "Clop, Clop. Clop, Clop."

Volume 6 - Ending the Game

Every turn when the location is Eternal_Peril:
	increase countInPeril by 1;
	if countInPeril is 3:
		end the game perilously.

Report an actor waiting when the location is Eternal_Peril (this is the 
eternal peril report waiting rule):
	if the actor is the player:
		if the action is not silent:
			now the prior named object is nothing;
			say "Time [pass] perilously." instead;
	otherwise:
		say "[The actor] [wait] perilously." instead.

Instead of doing anything other than examining, looking, waiting, summoning 
help, panicking, or panicking anyway when the location is Eternal_Peril:
	decrease countInPeril by 1;
	say "[We][']re in too much peril to think about doing that right 
	    now." instead.

To end the game perilously:
	end the story finally saying "[We] succumb to the peril".

To end the game victoriously:
	end the story finally saying "Congratulations! [Our] Quest for the 
	    Holy Grail Continues!"