The problem with "my" body part

Hello all,

I’ve been perusing the forums pretty much all day today, trying to resolve one niggling little problem that seems to have been bouncing around the community for years.

Now, I’m by no means a master of Inform 7, and I’ve needed to come to the community for help in the past, but I think that today I might be onto something.

I’m not going to link to other topics just at the moment, because as I said, I’ve been bouncing around between posts for hours and I’m not really sure where all of the code I’m using to get this far has come from.

The issue at hand is one where, when giving actors body parts, and then setting the player to be a certain actor, referring to "my peg-leg" when the player character doesn’t have a peg-leg causes the parser to refer instead to a different character’s peg-leg. This is obviously less than desirable.

I managed to prevent this from happening by doing the following:

[ Allow the player to refer to their own body parts using "my". ]
Understand "myy" as a body part when the item described is part of the player.
After reading a command:
	if the player’s command includes " my " begin;
		replace the matched text with “myy”;
		[say “The player’s command is [the player’s command].”;]
		end if.

This works to prevent automatically referring to a different character’s peg-leg, but results in a different undesirable response. For example, inputting examine my peg-leg might result in I only understood you as far as wanting to examine your hook-hand

It occurred to me that this is the same error as you would get in the following scenerio:

The playground is a room.
There is a red ball in the playground.
There is a jungle gym in the playground.

Test me with "examine red jungle gym".

The problem now has nothing to do with the word “my” and how it’s being handled as a pronoun, but instead arises because the parser recognizes “my” as the first word in the name of an object, only be be thrown a second object immediately after. It’s effectively reading the commands as examine my hook-hand peg-leg and examine my red ball jungle gym.

Alas, this is as far as I managed to get. I understand the problem, but I’m not sure how to come up with a solution. Perhaps somebody out there can help me out.

What you need is for ‘myy’ to match only the player’s body parts, but not be sufficient on its own to be a complete match.

You can get this effect with Understand the xxxx property as referring to... (see ‘Terracotta’ example in the documentation).

"Body_parts" by PB

Section - The Map

Treasure Island is a room.

Section - Reading a Command

After reading a command:
	if the player’s command includes " my ":
		replace the matched text with "myy";
		[say "The player’s command is [the player’s command].".]
		
Section - Body Parts

A body-part is a kind of thing.
The peg-leg is a body-part with description "A roughly-hewn stump of splintered oak, strapped to [if the holder of the item described is the player]your[else][the holder of the item described][']s[end if] left knee."
The hook-hand is a body-part with description "An unsightly rusting black iron hook, bound to [if the holder of the item described is the player]your[else][the holder of the item described][']s[end if] right arm."
The glass-eye is a body-part with description "A cloudy white orb, covered with grime and ordinarily inserted into [if the holder of the item described is the player]your[else][the holder of the item described][']s[end if] empty left eye socket."

Every body-part has a text called self-reference. The self-reference of a body-part is "myy".

Understand the self-reference property as referring to a body-part when the item described is part of the player.

Understand "peg leg" or "peg" as the peg-leg.
Understand "glass eye" or "eye" as the glass-eye.
Understand "hook/hand"  as the hook-hand.

Section - Characters

Long John Silver, Captain Hook, Blind Pew are men in the Island.  The player is Long John.

Long John Silver incorporates a peg-leg. Captain Hook incorporates a hook-hand. Blind Pew incorporates a glass-eye.

Section - Changing characters

Character-flipping is an action applying to one visible thing.
Understand "flip [any person]" as character-flipping.

Carry out character-flipping: now the player is the noun.
Report an actor character-flipping: say "You are now [the printed name of the noun].".

Section - Testing

Test me with "x hook hand/x eye/x peg/x my hook/x my eye/x my peg/flip Pew/x hook hand/x eye/x peg/x my hook/x my eye/x my peg/flip Hook/x hook hand/x eye/x peg/x my hook/x my eye/x my peg"
1 Like

Postscript in small print:

There is a bug in Ver 10.1.2 whereby after a disambiguation question (‘which do you mean…’) the command buffer is not immediately reprocessed (‘tokenised’) to reflect any changes made, which interferes with the subsequent proper operation of this ‘After reading a command’ rule.

To make it work properly if you type a new command- something like ‘examine my peg’- in response to ‘which do you mean- Captain Hook’s hook-hand or Blackbeard’s hook-hand’, do the following:

To retokenise: (- VM_Tokenise(buffer, parse); players_command = 100 + WordCount(); -).

After reading a command:
	retokenise;
	if the player’s command includes " my ":
		replace the matched text with “myy”;
1 Like

Prohestesis are complex animals, because by nature are both bodyparts and wearable… albeit a pirate can find useful an hollow peg-leg, and… what about a sword-cane variant of a peg-leg ? nasty, to say the least… and hooks need only to be hooks ? not necessarily nasty hooks, but, what about, say, a tool-hook (hammer, saw, whatever is needed for a crippled, but definitively still adventurous pirate…)

so, the problem deserve an ingenious solution, IMVHO.
Best regards from Italy,
dott. Piergiorgio.

Good news: this was just fixed in the current dev version.

1 Like

Here’s an alternate approach, which takes advantage of the fact that in phrases of the form Understand "first-word second-word..." as some-object-or-kind the words between the quotes will only be matched in a command if they all occur and in the correct order. This is different from an ordinary multi-word name, where one or any number of the words, in any order, including repeats, will match.

Understand "peg leg" or "peg" as a peg-leg.
Understand "myy peg" or "myy peg leg" as a peg-leg when the item described is part of the player.
Understand "glass eye" or "eye" as a glass-eye.
Understand "myy eye" or "myy glass eye" as a glass-eye when the item described is part of the player.
Understand "hook/hand"  as a hook-hand.
Understand "myy hook/hand" or "myy hook hand" as a hook-hand when the item described is part of the player.

Consequently, “myy” alone, or with another person’s body part after it, will not match any of these Understand phrases.

To get the same behaviour as multi-word names (which is not what we want here) the words need to be separated by slashes:

Understand "myy/peg/leg" as a peg-leg when the item described is part of the player.

Thankyou very much for this fix! I just tested it out now and it seems to work perfectly.
I don’t really understand why it works when you give body parts a text to reference rather than just using part of the name - it seems to me as though:

Understand the self-reference property as referring to a body part when the item described is part of the player.

and:

Understand "myy" as a body part when the item described is part of the player.

should do pretty much the exact same thing. Can you clarify why doing it this new way makes a difference?

When you use the “Understand the xxxx property as referring to…” declaration, the property name is not sufficient to refer to the object on its own. So “EXAMINE MYY” will not be accepted. You have to say “EXAMINE MYY LEG”.

If you said “Understand “myy” as a body part…” or “Understand the xxxx property as describing…”, then “EXAMINE MYY” would work.

See chapter 17.15.

The root of the issue here is the special treatment of the word 'my' as a “descriptor” by the parser. The way that it does this places the emphasis on the position of the object within the I6 object tree (which seems a bit out of date because it ignores the incorporation relation structure). On top of that, the descriptor really only matters when working in “indefinite mode” or trying to automatically disambiguate, and it is basically ignored when the parser is able to identify a single object via the words that come after 'my'.

EDIT: While experimenting with this, I got a little carried away and wrote an extension that allows the word ‘my’ to be based on whatever criteria of ownership the author likes. If anybody wants to give it a try, let me know by PM.

2 Likes

The quick and dirty AIF method:

A nose is a kind of thing. One nose is part of every man. One nose is part of every woman.

your nose is a nose. It is part of the player. Understand "my nose" as your nose.

2 Likes

You phrase it like that on purpose, right?

2 Likes