I’m a complete I7 newbie, so please bear with me.
I’m writing an AIF game, but since there doesn’t seem to be any AIF discussion here I’ll be circumspect. It’s a two character game (PC and NPC), and mostly consists of doing various things to various body parts, but the PC and the NPC have some different body parts.
When, for example, the player types “touch my <body part that I don’t have>,” I want the game to print, “You don’t have one of those” and stop the action. At present, it automatically assumes that since the PC doesn’t have one, the body part in question must belong to the NPC, and goes from there. All of my attempts to stop this via various rules have failed, I think because the game makes this switch before it gets to any “instead” or “before” rules.
Ideally, I would also like to be able to have to player type "touch ", no possessive, and have the game understand it as the NPC’s body part, but it’s not a big problem if that doesn’t work.
Any help would be greatly appreciated!
The easiest way is to create a body part object for the player (“my earlobe”), and then have rules like:
Instead of doing anything to my earlobe:
say "You don't have one of those."
Does the player mean doing something with my earlobe:
it is very unlikely.
(Not tested – you may have to fiddle with object names, because “my” is treated as a pronoun.)
The only thing about that is that you will get (maybe unnecessary) clarifications of the parser’s choice, along the lines of
> X EARLOBE
So you might want to consider writing a rule for clarifying the parser’s choice of earlobes (etc), telling it to do nothing. You’ll probably want one or more classes of body part, presumably.
Thank you, that’s very helpful–it seems to work just fine.
Actually, I still have a problem. “Does the player mean doing something with my earlobe: it is very unlikely” works for direct commands, but “[NPC], tug earlobe” generates the disambiguation phrase “Do you mean [NPC]'s earlobe, or your earlobe?”, which I can’t have. “Does the player mean an actor doing something” is apparently not allowed. Is there another way to approach this?
You can define some kinds to be part of every man, some kinds to be part of every woman, and some kinds to be part of every person. If that helps.
The Place is a room.
An earlobe is kind of thing. An earlobe is part of every person.
A renal lobe is a kind of thing. A renal lobe is part of every man.
A flocculonodular lobe is a kind of thing. A flocculonodular lobe is part of every woman.
Inga is a woman in place.
Yourself is a man.
A persuasion rule for asking people to try touching something: persuasion succeeds.
Does the player mean doing something to something that is part of the player: it is unlikely.
Test me with "touch renal / Inga, touch renal / touch flocculonodular / Inga, touch flocculonodular / touch earlobe / Inga, touch earlobe".
Thanks, but that’s more or less where I started. But in case anyone’s interested, I’ve been given a solution: I just need both “Does the player mean doing something to [object]” and “Does the player mean asking someone to try doing something to [object]”. I think this is working.
Many thanks to all who helped me with this!
Note that you can generalize this by defining some body parts to be “nonexistent” and adding appropriate “does the player mean…” rules and check rules to block actions involving them, like this:
"A Nose by Any Other Name" by Vyznev Xnebara
The story headline is "An Interactive Test".
A nose is a kind of thing. A nose is part of every person.
An Adam's apple is a kind of thing. An Adam's apple is part of every person.
Definition: An Adam's apple is nonexistent if it is not part of a man.
Does the player mean doing something when the noun is nonexistent or the second noun is nonexistent: it is very unlikely.
Does the player mean asking someone to try doing something when the noun is nonexistent or the second noun is nonexistent: it is very unlikely.
Instead of an actor doing something when the noun is nonexistent, complain about the nonexistence of the noun.
Instead of an actor doing something when the second noun is nonexistent, complain about the nonexistence of the second noun.
To complain about the nonexistence of (the item - a thing): say "But [if the item is part of the player]you don't[else][the holder of the item] doesn't[end if] [italic type]have[roman type] one of those!"
The Private Location is a room.
Lisa is a woman in the private location.
Yourself is a man in the private location.
Persuasion rule: persuasion succeeds.
Test me with "x nose / Lisa's / x Adam's apple / x Lisa's Adam's apple / Lisa, x Adam's apple".
Test second with "tie Lisa's nose to Adam's apple / tie my nose to Lisa's Adam's apple".
(Yes, the rules are rather verbose, but they should catch any variations I could think of, including stuff like asking someone to insert something into a nonexistent part.)
Ps. A problem with the solution above (and with the nonexistent body part trick in general), is that the nonexistent parts may still appear in “which do you mean?” prompts. For example, if you added another man (let’s call him “Joe”) to the scene above, then “x Adam’s apple” would prompt: “Which do you mean, your Adam’s apple, Lisa’s Adam’s apple or Joe’s Adam’s apple?”
Alas, there doesn’t seem any easy to way to fix that. Overriding the “asking which do you mean” activity would do it, but the manual pretty much just bluntly says that “It is probably better not to try to rewrite this.” Looking at the source code (look for ASKING_WHICH_DO_YOU_MEAN_ACT in Parser.i6t) makes me inclined to agree – at least, it’s way beyond my limited I6 skills. About the best I could do is the following rule, which suppresses the nonexistent body part names, but, alas, still leaves the commas surrounding them:
Rule for printing the name of a nonexistent thing while asking which do you mean: do nothing.
The extension Disambiguation Control by Jon Ingold lets you take care of that problem; you’d have to look at it, but basically once you’ve included it you can write “Should the game suggest a nonexistent thing: never” and then the game will never ask “Which do you mean” about a nonexistent thing. If you look at the extension, Jon fearlessly dove into the I6 code and rewrote it.
So that might be something you’d want to try, though it’s a complicated extension.
Thank you both for further suggestions. What I did seems to be working, so I think I’ll stick with it for now.
After reading Example 196 in 12.9 of the Handbook, I wondered if there might be a way to add a rule to the action processing rules that stopped the problem of “my earlobe” before it started, and thus relieved me of creating nonexistent bodyparts. But I don’t know how to formulate such a rule, or whether it would work.
I don’t think example 196 will help you avoid creating nonexistent bodyparts. Action-processing rules work after the parser has figured out the action name and any nouns (or topics or whatever) that are involved in the current action. If the parser is interpreting “my earlobe” as the NPC’s earlobe, the action-processing rulebooks will interpret the action as “tugging the NPC’s earlobe”; they don’t know that the player typed “my earlobe” to refer to the NPC’s earlobe. So you can’t write a new rule there to stop “my earlobe,” because you don’t know that it’s “my earlobe” rather than “NPC’s earlobe” anymore. (You could potentially recover that information by checking to see what if the player’s command includes “my earlobe,” but it’d probably be difficult to catch all the problem cases that way.)
Thank you for the info. So the parser decides that “my earlobe” must mean any available earlobe before any action processing takes place, and there’s basically no way to change its mind about this (or not without being a real programmer who doesn’t recoil in terror from I6)?
If so, that’s fine–as I said, the workaround is working, though just because this is a two-person game. But it seems like an odd decision for the parser to make: if the player makes such a specific reference, isn’t it likely that he doesn’t mean something belonging to someone else? And I see that the parser does this for any object:
The balcony is a room. Fred is in the balcony.
Fred is holding the large key. The description of the large is "It is large."
The player is holding the small key. The description of the small key is "It is small."
Instead of examining the small key twice: say "You accidentally drop it through the grate."; remove the noun from play.
Repeating “examine my key” produces “It is small.”; “You accidentally drop it through the grate.”; “It is large.” I’m sure there’s a way around this, but I would expect the game to reply with something like “You see no such thing.”
This is what I meant when I said “‘my’ is treated as a pronoun”. It is biased towards objects in your possession, but can refer to any object. (Maybe the large key is actually the key to your house, or was the first object you picked up at the start of the game. The parser has no way to understand ownership in that sense.)
This is a problem for body parts, or anything which has a concrete sense of ownership. Unfortunately, it does require some I6 hacking to work around this. (There may be an extension that deals with it, I’m not sure.)
I think you’d want:
Instead of examining the small key for the second time
Rather than “twice”. (not at a PC to test it right now though)
Either will work. (Yes, I just tested them.) Anyway, that’s not really the point of the example; rather, it just demonstrates that, with the small key out of play, the parser starts to resolve “my key” to the only remaining key in scope, which happens to be the large key carried by Fred.
Aha! Yes, I should probably read things more carefully before posting. This kind of behaviour is really annoying, it’s similar to Inform’s ignoring the word ‘other’.