Creating a *very specific* riddle game with a "linear map".

Easy question for the Inform pros out there.
Hopefully, there is an equally easy answer. :slight_smile:

I am trying to create an IF that is ludicrously simple in terms of its game “world”. I want each room to be logically connected to the next in a linear fashion. By that, I mean the player follows a straight path from one room to the next. I won’t need N/E/S/W directional markers. And users can’t skip rooms along the path.

The reason behind such an (odd?) request is that I’m developing a sort of children’s riddle game. The primary objective is to solve one puzzle before you can proceed to the next room. Typically, the puzzles will have one-word answers. If, and only if, the player provides the correct answer to the current room’s puzzle, he may proceed to the next room.

If all of this is unclear, let me give an example:

Room 1:
“You are sitting in a room. You see nothing but the door and it’s locked. Keeping the door locked, is an electronic keypad which you have access to. The keypad display reads “2+2=”. What number do you punch on the keypad in order to unlock the door?”
(If, and only if, the player types “4” and presses Enter, he proceeds to Room 2)
(If the player enters anything but “4”, then some text may appear offering a hint, etc.)

Room 2:
<another puzzle. completely unrelated to the one that came before it. when correctly solved, player then moves to…>

Room 3:

You get the idea.

Any ideas on how I would get started?

I admit that I am new to Inform, but I have read the documentation and most of that is geared towards creating rooms with objects, and the interactions between objects. Indeed, I was able to create a simple adventure game just fine using some template examples.

I’m a little stuck on my “riddle” game, though. So any help would be GREATLY appreciated!

Thanks in advance,

  • Anthony

Maybe this can get you started:

The Manipularium is down from the Pullarium. The Pullarium is down from the Contactorium. 

Instead of going, say "There are no directions but up."

Instead of going up:
	if the riddle-solved of the location is true:
		say "Good luck up there...";
		move the player to a random room above the location;
		say "You can only go up when you 'say' the answer to the riddle.".

Instead of going up when in the Contactorium, say "You've solved all the riddles!"

a room has a truth state called riddle-solved. 
riddle-solved usually is false. 

The block answering rule is not listed in the report answering it that rulebook.

Instead of answering yourself that it when in The Manipularium:
	if the topic understood matches "manipulate":
		say "Correct!";
		now riddle-solved of the location is true;
		say "Gesundheit!"

Instead of answering yourself that it when in The Pullarium:
	if the topic understood matches "pull":
		say "Correct!";
		now riddle-solved of the location is true;
		say "Gesundheit!"

test me with "n / e / s / u / say xyzzy / say Manipulate / u / say pull / u / u"

The basic idea is to unlock the next room when you say the magic word. It doesn’t have to be a say – you could make a custom action, or match to the text exactly too. The awkward ‘answering yourself that it’ is due to the name of the answering action (whose rule gets triggered by the say command).

Other oddities (explained as best I can, I’m no Inform pro :slight_smile: ):

  • ‘to a random room’ is what you need to code when you’re thinking ‘to the room’ due to Inform syntax.
  • truth states are specialized properties which only can be true or false.
  • the ‘topic understood’ will match the text you enter, in this case the text entered for the answering it that action.
  • don’t forget to unlist the block answering rule if you use the answering it that action (i.e., the ‘say’ command).

Sounds like you’re making a choose-your-own-adventure. I believe there’s an extension or two on the Inform site that makes that easy. Er, it has Adventure Book or something in the title…?

Thanks George…

The logic here seems like it should work for my application. I suspect there is a more elegant way of doing it, but I’ll certainly use this as a starting point and streamline it as I go along.

Not quite. Remember that my story path is completely linear. There will be no forking or choosing of paths.

You appear in “Room 1”. The only way to get to “Room 2” is to solve Room 1’s riddle. For argument’s sake, let’s say there are 10 rooms until you end. To “win” the game, each and every room must be completed in order.

One refinement might be to take the topic matching code and abstract it, so from this:

Instead of answering yourself that it when in The Manipularium:
   if the topic understood matches "manipulate":
      say "Correct!";
      now riddle-solved of the location is true;
      say "Gesundheit!"

to something like this (not tested):

Instead of answering yourself that it:
    if the topic understood matches the magic word of the location:
        say the correct answer of the location;
        now riddle-solved of the location is true;
        say the wrong answer of the location.

And you would then define the appropriate properties on the rooms. Might be easier to manage once you had a bunch of rooms.

Eh? One path goes forward, the other loops back with a hint…

I’d probably approach this by finding the part in the manual that identifies how to define a new cardinal direction (I remember seeing it somewhere, probably next to the part where they explained how to cancel the old cardinal directions). Then you can name new exits anything you wish. You can name 13 new exits and definre each of those for each room as leading to the next in the sequence. In other words, one exit per room, named after the answer to its riddle. So for example if the answer to room 1’s riddle is ‘yes’ then you can use ‘Room 2 is yes of Room 1’ instead of, say, west of Room 1. But you would have to define yes as a new direction, first, which unfortunately I can’t give you code for off the top of my head, but I remember it seemed pretty simple. I still kinda think in MUD-brain, where defining any text you wish as an exit verb is a trivial operation; it’s more unusual in Inform but I think it’d work fine for a standalone quiz game unless you had hundreds of rooms or something.


It also seems like an IF language might not be the best choice of tool for this kind of game, unless you have some other reasons to use one. You could make a trivia game like that with a few lines of HTML and JavaScript.

Juhana is probably right–this is not a game that plays to Inform’s strengths.

However, I think the absolute simplest way to do it would just be to make every room have no exits and then change them to have appropriate exits:

Completing question 1 is an action applying to nothing. Carry out completing question 1: Change north exit of room 1 to room 2. Report completing question 1: Say "A doorway opens to the north!"

This is automatically a one-way connection (you can’t return to room 1), which is probably what you want.

As for interface, I’d put a person in the room who asks you the riddle and to whom you reply the answer:

[code]The Sphinx is a person in room 1. “An impassive stone statue gazes at you with stern, intelligent eyes.”

Instead of asking the Sphinx about:
say “‘What goes by four legs in the morning, two legs at noon, and three legs in the evening?’”

Instead of answering the Sphinx about:
say “‘Incorrect,’ says the Sphinx, glowering at you with such ferocity that you almost fear to try again.”

Instead of answering the Sphinx about “[man]”:
say “‘Correct!’”;
try completing question 1.

Understand “man” or “men” or “person” or “people” or “human” or “humans” as “[man]”.[/code]

Thanks again, George. And that was exactly the path (pardon the pun) I was already going down. I’ve got the core of the logic working just fine now, however I feel it’s a bit clunky. I will continue refining it and then post here for all to use.

Hehe. Nice try, but no.
That’s not what most people refer to when they say “CYOA”.
My “plot-line” (if you can call it that) cannot get any more linear. I am not looking to choose-your-own-anything. In case my first post wasn’t clear, the player is to flow from one room to the next. The outcome of the game is fixed.

Displaying a 1-line hint (which is not a requirement, by the way) while within a room does not count as “looping back”. Looping back implies that you have already left the room.

I started off doing the exact same thing (which is why I included the reference to N/E/S/W in my original post). But, I found it awkward to code because it wasn’t intuitive for me to think about “solutions” as “cardinal directions”. (There will be approx. 40 rooms in total, so you can see this getting convoluted pretty fast. For example, a player might re-use a previous answer (direction) incorrectly, but still be able to exit the room because it matches the cardinal direction that the current room expects.) Overall, having the interpreter parse a correct answer as a spatial direction just doesn’t smell right to me. :slight_smile: However, it’s still a valid idea and worth revisiting if nothing else proves more elegant.


I wanted to retain the rich and lavish features of the IF experience, that only Inform can provide :slight_smile: (shameless plug).

You’re right - it can be done, simply, with HTML and JavaScript (hell… with DOS batch files!)… but “simple” is not the final look of the game that I’m after. I would still like to code objects, people, and interactions in the game - just at a simpler level. Because the plot is weak (non-existent, actually) then I am relying heavily on scenery descriptions, dialogue, characters, etc… things that Inform does well. All the same, each room (it might be better to call it a “scene”, perhaps) will be self-contained and you can only progress from one to the next by suppling a short (sometimes 1-word, sometimes not) answer to the room’s riddle.

Seems to me that a decent IF compiler is still “the right man for the job”.

I like that a lot, actually. It seems the code would give me tighter control over the flow from one room to the next, yet easily modifiable.

Correct. Except, in your code, the movement from one scene to the next is still an active task (the player has to move himself through the door, for example). I’d prefer it if, once the riddle was solved, you are automatically ushered into the next scene. It seems like a simple enough programming task, so I’ll just look that one up myself.

Staying true to my favourite text-adventure game’s style (HHGTTG), I will be narrating this entirely in the 3rd person.

Thanks, Katz, for the inspiration!

I don’t think he’s “trying” anything. Your objective may not be exactly what most people mean when they say CYOA (no spaceships or pirates), but it has more in common structurally with CYOA than it does with world-modeled IF. In any given room – which cannot be re-visited after exiting, even – there is a “choice”: the correct answer, or any of the wrong ones. This is true even if you haven’t listed the answers out (“1. Banana 2. Apple 3. Orangutan”). The correct answer takes you forward, and the wrong answer keeps you in place (or “loops back” to… exactly where you are). Without that loop, you’d have a game that allows the player to progress regardless of what answer they give, and that doesn’t sound like what you’re thinking of.

What? Not to nitpick, but:

I respectfully disagree on the CYOA question. When I think CYOA I think multiple explicitly given choices with some branching (even if most of the branches terminate quickly); definitely not of things that loop you back till you get the right answer. The game Tigger is describing seems most like “The Grand Quest” or “Gleaming the Verb” from the 2009 comp, both of which had strictly linear progression through a series of puzzles; in The Grand Quest you were gated through a series of rooms, in Gleaming the Verb as soon as you answered a puzzle you got the next clue. But they wouldn’t have worked as CYOAs, because the puzzle was to guess the answer, as a riddle; if the choices had been given explicitly the answer probably wouldn’t have been obvious.

Anyway, to the original question, why not just automatically move the player from one room to the next, if that’s what you want to do? If you want them to automatically move from one room to the next you don’t actually need to implement a connection. I think something like “Now the player is in (whatever the next room is)” will work, with appropriate conditions and text about the player going in the next room. (Don’t have time to check the exact syntax.)

Oops. Brain-fart. I meant to say 2nd-person, not 3rd-person.
If you read the description of “Room1” (in my original post) you’ll see the narrative is in 2nd-person, just like HHGTTG.

He’s trying to insist that my game style is that of a CYOA. However, he is mistaken.

It seems that you, too, have misunderstood the objective of my game.
In no way, whatever, is it accurate to describe it as a CYOA, nor is it appropriate to use a CYOA-style of logic when coding this particular game.

There are no “choices” to be made, here. The player examines a richly-detailed room (possibly containing objects, characters, dialogue, etc.) but the player has exactly ONE move to make: answer the riddle. You either pass, or fail. If fail, stay where you are. If pass, move on to the next room/scene/riddle. The entire plot (if you want to call it that) is PRE-DETERMINED. Indeed, my work is the exact opposite of CYOA.