Foxaroo project #1: TARDIS Adrift

In room descriptions definitely, and also where I’m being lazy with “Look at (person)”, IE if the character isn’t integral to the story and I’m not creating a separate “Look at” description for them.

Right - you just change your existing rule to this:

Rule for writing a paragraph about a person (called X): say "[X] is here, [rundown for X]."

The reason the say-phrase works this way is that unlike the rest of Inform, the compiler parses phrases EXACTLY as you’ve defined them, letter-for-letter. If you create a phrase called “To say Tom’s rundown,” the compiler does not recognize that Tom is the name of a person, it just accepts the word ‘Tom’s’ in that place and no other phrasing (such as ‘X’s’). You might have well called the phrase “To say Albuquerque rundown” and it would have been no more or less linked to Tom in the eyes of the compiler. If you want a phrase to accept a variable, even if that variable can only ever have one value, you must put it in parentheses. Once you’ve done that, phrase overloading works as it would in other object-oriented languages, so you can define any number of phrases with “To say (someone - particular identifier):” This defines a say phrase that takes a parameter called “someone” whose value must be particular identifier.

My WIP has something similar, but I’ve put it into an activity called “behavior.” I’m not totally happy with it, or I would be working on an extension for it. If you’re doing something along the same lines, I might think about an extension more seriously. Maybe start a new thread to discuss this?

I think Matt’s identified the problem, but I’m not sure if this is the right solution. You need to specify the player’s wrist in a way the compiler will understand. If you say:

A wrist is a part of every persion

…the compiler will create one wrist for every person, and it will create a name for each wrist using a specific pattern. For non-player objects, that pattern is “object name’s wrist.” That means if you have an NPC named “Henry David Thoreau,” the compiler will create a wrist called “Henry David Thoreau’s wrist.” You can refer to that wrist in your code as “Thoreau’s wrist” or “Henry David wrist,” but not as “Henry David’s wrist,” because the word “David’s” is not part of the name that the compiler created. Similarly, parts of the “yourself” object will be called “your wrist,” etc. and “the player’s wrist” and “the wrist of the player” will not match, because “of” and “player” and “player’s” are not part of the official name.

You’re right, of course. If you want to write a rule that captures the player’s wrist, one thing you could do is look at the Index (or showme the player) to find out what Inform is calling the object. Or if you need a more general case (if there’s a possibility of switching the player from one person to another) then you might need “a wrist that is part of the player” or “a random wrist that is part of the player” or something like that.

How about something like this?

Rule for writing a paragraph about a person (called X): Say "[X] is here. [rundown of X]". The description of a person is usually "[rundown of the item described]". To say rundown of (X - a person): [complicated code goes here]

I haven’t tested this, but I think it might work.

It worked (with a little fiddling around to control line breaking), and thanks for the explanation. I’m still in the early stages of grappling with Inform’s grammar and syntax, so there’s a long way to go. Inform is the first Interactive Fiction language I’ve learned, and as such completely different from anything I’ve done before.

Possibly, although as a raw novice I wouldn’t be able to contribute much myself. Certainly it would be worth attracting opinions, so if you do start a thread on it pls post a link here to the new thread.

I would have expected describing details of NPCs to be sought fairly often, in a game where details of the characters are subject to change. An example of what I could be doing with the three characters at the construction site is for one to be randomly selected as the murderer, with the telltale signs to be a torn section of their overalls and a pocket bulge where they’ve stowed the murder weapon.

This one is still giving me a headache. I’ve tried the index and showme command. Nothing appears about wrists in the index, but the Showme command identifies them as:
“>showme my wrists
your Wrists - Wrists”

Having learned this I’ve changed the command to:

Does the player mean doing something with your wrists: it is very unlikely.

This successfully compiles, but unfortunately it appears not to have any effect on gameplay:
“>Examine wrists
Which do you mean, your Wrists, Tommy’s Wrists, Richard’s Wrists or Gertrude’s Wrists?”

There’s a rather brute-force solution that I found while working on something else.

Remove your Wrists from play

Not ideal for all situations, but it’s one option. This came about while I was getting ahead of myself and trying out ideas for a furry Interactive Fiction game. With different species having different body parts the only way I found to achieve this was to say that all body parts are a part of a person and then to remove from play the incorrect ones.
Simplified example:Claws are a part of every person. Hooves are a part of every person. When play begins: Remove Mr Ed's Claws from play. Remove Shere Khan's hooves from play. [Etc.]
A question that might possibly lead to a solution (or maybe more problems): When there are pairs of body parts, what’s the correct way to create them?

Wrists are a part of every person.
or
A left wrist is a part of every person. A right wrist is a part of every person. (This produced a compilation error).
or
Two wrists are a part of every person. (This was successfully compiled, but then I couldn’t apply the “Remove your Wrists from play” and in gameplay it became impossible to perform actions on anyone’s wrists because Inform could no longer distinguish one wrist from another).

I think you’re hitting one of the annoyances of DTPM rules. As I understand it, they assign a score to every possible match, and if one object comes out with the best score then they pick that object. But if there’s a tie, they ask the player to disambiguate every possible match. So in this case, if there’s one NPC in the location I think it will automatically examine the NPC’s wrists, but if there is more than one NPC it will disambiguate among everyone’s wrists.

You could see if the Disambiguation Control extension helps. I don’t know any other way to solve the problem.

Okay that sounds logical.

Not familiar with those terms though. What’s DTPM and Disambiguation Control? I couldn’t find either of those in the manual.

Sorry, DTPM is “does the player mean,” and Disambiguation Control is an extension by Jon Ingold found here.

DTPM is short for Does The Player Mean. Disambiguation Control is an extension by Jon Ingold.

I haven’t had much luck with Disambiguation Control. It only does certain things, and I can’t remember whether removing an item from the match list is one of them.

I spend a lot of time debugging DTPM. Here are some things I keep in mind:

The DTPM rulebook runs once for every possible action that the parser tries to match against the command. In effect, every noun is tried one at a time. And like any other rulebook, DTPM stops running on the first rule that produces a result. So rule order matters. If you have one DTPM that refers to examining and one that refers to body parts, only one of them will apply to examining wrists, and which one depends on the rule order.

So, two super-valuable things to do:

Turn rules on. This will tell you which DTPM, if any, are running. Unfortunately, you won’t be able to see what circumstances they’re running on. So the second thing is to add this rule:

First does the player mean: showme the current action.

That will give you a nice “header” for every block of DTPM that runs, ending with the one that made the decision.

If you get really desperate, you can use the “trace” debug command, but that will give you a lot of I6 parser stuff that’s hard to decipher.

My approach to this problem is to make an extra effort to ensure that only one choice scores high - thus avoiding disambiguation completely. A few specific cases that trigger “it is very likely” are much more powerful than a large number of cases returning “it is very unlikely.”

Here, you might want something like:

Does the player mean doing something with a body part that is part of a dead person: it is very likely.

Thanks. I’ve downloaded and incorporated it successfully, but the link to the documentation is dead. Are there any docs available for using this extension?

Done! (In the “Not for release” section).

…best left then for when I progress from a noob to a halfway decent I7 developer.

Good thinking, I’ll put that in.

Still looking for an answer from anyone on the below question:
When there are pairs of body parts, what’s the correct way to create them?

Wrists are a part of every person.
or
A left wrist is a part of every person. A right wrist is a part of every person. (This produced a compilation error).
or
Two wrists are a part of every person. (This was successfully compiled, but then I couldn’t apply the “Remove your Wrists from play” and in gameplay it became impossible to perform actions on anyone’s wrists because Inform could no longer distinguish one wrist from another).

Now a new problem that’s cropped up and I’ve been unable to resolve. I suspect this is probably a limitation of Inform?
My idea was that the murderer would be randomly chosen from one of the three labourers. The player has to wait until they change out of their work gear to find a blood stain on one person’s clothing. This means 3 individual copies of each piece of clothing, 1 for each labourer.

This was my first attempt:

[code]In the construction site is a man called Tom. The printed name of Tom is “Tommy”. Tom is wearing Tom’s shirt, Tom’s dungaries and Tom’s boots. To say rundown for (somebody - Tom): say “[if Tom is In WorkGear]Muscle man Tommy is here, in grubby work clothes[Else]Off-duty Tom is here, wearing [a list of things worn by Tom]”. The description of Tom is “[rundown for Tom]”.

In the construction site is a man called Dick. Dick is wearing Dick’s shirt, Dick’s dungaries and Dick’s boots. To say rundown for (somebody - Dick): say “[if Dick is In WorkGear]Tricky Dicky is here, in grubby work clothes[Else]Off-duty Dick is here, wearing [a list of things worn by Dick]”. The description of Dick is “[rundown for Dick]”.

In the construction site is a woman called Gerty. Gerty is wearing Gerty’s shirt, Gerty’s dungaries and Gerty’s boots. To say rundown for (somebody - Gerty): say “[if gerty is In WorkGear]Gerty the welder is here, in grubby work clothes[Else]Off-duty Gertrude is here, wearing [a list of things worn by gerty]”. The description of gerty is “[rundown for gerty]”.

Before writing a paragraph about a person (called X):
say “[rundown for X]”.

A WorkGarment is a kind of thing. A Shirt is a WorkGarment. Dungaries are a WorkGarment. Boots are a WorkGarment.

Definition: A person is In WorkGear if they are wearing more than 2 WorkGarments.

A job is a kind of value. A person has a job. The jobs are Detective and Labourer. Understand the job property as describing a person.
The player is a Detective.
Tom is a Labourer.
Dick is a Labourer.
Gerty is a Labourer.

The Construction Site is a room. “You are at the construction site.”[/code](There’s probably ways of streamlining the code too)

By design all three characters should show as “in grubby work clothes” when on duty. However this produced a very peculiar result:
construction site
You are at the construction site.

“Muscle man Tommy is here, in grubby work clothes
Off-duty Dick is here, wearing Dick’s shirt, Dick’s dungaries and Dick’s boots
Off-duty Gertrude is here, wearing Gerty’s shirt, Gerty’s dungaries and Gerty’s boots”

Using the showme command I discovered that this is happening beause only the 1st NPC’s clothing is being designated as “WorkGear” and while the 2nd & 3rd NPC are not. I confirmed this by swapping the order and indeed I found that regardless of which names were used, only the 1st one’s clothing became “WorkGear.”

My next approach was to implement this:

When play begins: Repeat with TheWorker running through the people in the construction site: say "[TheWorker][Line Break]"; Now TheWorker wears a Shirt; Now TheWorker wears Dungaries; Now TheWorker wears Boots.But this failed because only one set of clothing was created, and passed along each time. Tom and Dick ended up without any clothing as it was claimed by Gerty. Another problem is that I couldn’t find the way to restrict the repeat to just the labourers; it included the player as well. What’s the correct syntax for repeating only through those whose job is Labourer?

My third endeavour was to specify this:

However I couldn’t figure out the command to make the NPCs pick up each piece of clothing. “Now TheWorker carries…” didn’t take any of the clothes.

Suggestions?

The docs for extensions are included with the extension itself. They have to be indexed before you can see them first. Just include the extension in a compilable project like:Include Disambiguation Control by Jon Ingold. Lab is a room.
After you hit compile (the “Go” button) the index will be updated. Now when you go to the “Installed Extensions” section of the docs and click on “Disambiguation Control” (under Jon Ingold’s name) the documentation for that extension will appear in that pane.

ETA: This is true under Windows, not sure about other OSs.

Since you need more than one left wrist and right wrist in the game, you need to make it a kind first:

A left wrist is a kind of thing. A right wrist is a kind of thing. A left wrist is a part of every person. A right wrist is a part of every person.
You could alternately create a “wrist” as a kind of thing and create a new kind of value (called for example “sides”) with values of “left” and “right” and then assign that as a property of wrists, but then creating the assembly is a little more complicated.

As it stands, your code begins by creating nine individual objects (Tom’s boots, Gerty’s shirt, Dick’s dungaries etc.); then it creates a kind (WorkGarment); then it says that three individual objects, called “Shirt”, “Dungaries”, and “Boots” respectively, is of the kind WorkGarment, and Inform picks the first objects created that contain the word “shirt”, “dungaries”, and “boots” in their names, which happen to be the things Tom is wearing – so only these three objects are ever declared to be of the WorkGarment kind.

Apparently, you want Shirt, Dungaries, and Boots to be subkinds of WorkGarment. Just explicitly declare them to be so – only you have to do that before you create the individual objects called “Tom’s shirt” etc.

[code]A WorkGarment is a kind of thing. A Shirt is a kind of WorkGarment. Dungaries are a kind of WorkGarment. Boots are a kind of WorkGarment.

In the construction site is a man called Tom. The printed name of Tom is “Tommy”. Tom is wearing a shirt called Tom’s shirt. He wears some dungaries called Tom’s dungaries. He wears some boots called Tom’s boots. To say rundown for (somebody - Tom): say “[if Tom is In WorkGear]Muscle man Tommy is here, in grubby work clothes[Else]Off-duty Tom is here, wearing [a list of things worn by Tom]”. The description of Tom is “[rundown for Tom]”.[/code]etc.

I think you could do more with sub-kinds:

A construction worker is a kind of person. Every construction worker wears a shirt. Every construction worker wears dungaries. Every construction worker wears boots. Tom is a male construction worker. Dick is a male construction worker. Gertie is a female construction worker.

As long as you don’t refer to the “man” and “woman” kinds specifically, I don’t think you really need them.

Also, regarding the “wrists” issue: Unless you actually need to do something with the wrists of arbitrary people, I would advise against creating a large catalog of body parts for every single person in the game. Not only will it confuse the parser, but it could distract the player and slow down the virtual machine.

For my WIP, I use my “Lost Items” extension to catch references to body parts (among other things) when the player might expect them to be there, but doesn’t need to interact with them:

For noticing absence of a body part (called item): say "You only need to deal with [the item]s of the victims, and there are no victims here."

Got it, there they are, thankee Skinny Mike! :slight_smile:
Whoooo boy… more manual pages to read! :open_mouth:

YES!!! It worked. Thanks Felix. :smiley:

This is something I tried at a much earlier stage, and I had great hopes for it because assigning the job as a kind would have streamlined a great deal of code. Not just in the current (curiosity) project but many others.
Unhappily this was the result, and I even tried compiling in an otherwise blank project:

Problem. You wrote ‘Tom is a male construction worker’ , but also ‘Dick is a male construction worker’ : that seems to be saying that the same object (shirt) must be in two different places (Tom and Dick). This looks like a contradiction.

Problem. You wrote ‘Tom is a male construction worker’ , but also ‘Gertie is a female construction worker’ : that seems to be saying that the same object (boots) must be in two different places (Tom and Gertie). This looks like a contradiction.

It produced six rows of this error; one for each of the six objects following the first nine because it interprets them as a contradiction.

(Skinny Mike, haven’t had a chance tonight to experiment with your suggestion for wrists - I’ll need to give that a try tomorrow if I can).

That’s because in addition you also need to declare the shirt, dungaries, and boots kinds. If you don’t, Inform will assume that the shirt, the dungaries, and the boots arnot kinds but three individual objects. This compiles fine:

[code]The Construction Site is a room.

A construction worker is a kind of person.
Tom is a male construction worker in the Construction Site. Dick is a male construction worker in the Construction Site. Gertie is a female construction worker in the Construction Site.

WorkGarments is a kind of thing.
A shirt is a kind of WorkGarments. Some dungaries are a kind of WorkGarments. Some boots are a kind of WorkGarments.

Every construction worker wears a shirt. Every construction worker wears dungaries. Every construction worker wears boots. [/code]

The problem with this for your present project (I guess) would be that all three shirts, dungaries, and pairs of boots would be called just “shirt”, “dungaries”, and “boots”; so there will be no easy way to examine (say) Dick’s dungaries in particular.

I have some code (mostly borrowed from an example in the Punctuation that will automatically make “Tom’s shirt” refer to a shirt worn by Tom, and similarly for anything that’s part of Tom or held by Tom (this is the enclosure relation). I’m pasting an unnecessarily long bit under a spoiler tag:

[spoiler][code]“possessions” by Matt Weiner

Section 1 - Of Hats

clothing is kind of thing.
a hat is kind of clothing.
clothing is always wearable.

understand “hat” as a hat.

The fuschia hat is a hat. The bright red hat is a hat. The bright blue hat is a hat. The purple hat is a hat.
The indefinite article of a hat is usually “a”. The description of a hat is usually “It’s [indefinite article of the noun] [printed name of the noun].”.

Section 2 - Of Sticks

The swagger stick is a thing. The description is “It seems confident, if not arrogant.” The walking stick is a thing. The description is “Sturdy and mostly straight, it looks like it might help you walk.”

Section 3 - Of Noses

A nose is a kind of thing. Every person incorporates a nose.
The description of a nose is usually “[Random person incorporating the item described][’]s nose is noselike.”

Section 4 - Of Enclosures

After reading a command:
let X be indexed text;
let X be the player’s command;
replace the text “'s” in X with " [’]s";
change the text of the player’s command to X;
say “[line break]”.

Understand “[something related by reversed enclosure] 's” as a thing.
Understand “my” as a thing when the player encloses the item described.

Enclosure-querying is an action applying to one thing. Understand “scan [something]” as enclosure-querying. [This is for debugging; you don’t want to include it]
Carry out enclosure-querying: say “[list of things enclosed by the noun].”

Section 5 - Scenario

Starter is a room.

Bob and Mike are men in Starter.

Understand “Robert” as Bob.
Barbie and Sandie are women in Starter.

Bob wears the red hat. Mike wears the blue hat. Barbie wears the fuschia hat. Sandie wears the purple hat. Sandie carries the swagger stick. Mike carries the walking stick.

Persuasion rule: persuasion succeeds.

Test me with “x bob’s hat/x bob’s nose/x sandie’s stick/bob, drop hat/mike, doff hat/x mike’s hat/mike, take hat/x mike’s hat/bright blue hat/x mike’s blue hat/mike, wear red hat/mike, drop blue hat/take hat/x my hat”.
[/code][/spoiler]

I think this works, though there may be some bugs in it and disambiguation might be hinky. However, it probably won’t suit your purposes, because I suspect you want “Tom’s shirt” to refer to the shirt Tom was wearing even when he’s taken it off. To do that, you might try something like the ideas discussed here (unfortunately there’s a lot of fairly irrelevant back-and-forth in that thread), particularly the “embodiment” relation set with the When play begins rule. (Though you probably want to call it “ownership” and certainly want to set it to anything that the person encloses rather than anything that is part of the person.)

Of course, at this point a simpler way might just be to manually declare the items as “Tom’s shirt” etc.

Matt, I don’t think that’s necessary in this case because the compiler automatically calls it “Tom’s shirt” when it’s created. Now if the character were called Tom Jones, then the shirt would be called “Tom Jones’s shirt” and you might have to do some work if you wanted it to be called/understood as “Tom’s shirt” instead. But if you’re not doing that, you should be fine.