[Newbie] Parts and description thereof

Hello, everyone! I’ve just started to try my hand at I7. It’s been frustrating and wonderful by turns.

A lot of problems I’ve encountered I’ve managed to work out in time. This one, though, has me stumped. Maybe someone here can help me.

"Written on the body"
A body part is a kind of thing.
A face is a kind of body part. A face is part of every person. 
A pimple is a kind of body part. A pimple is part of every man.

Definition: a person is other if it is not the player.
Definition: a thing is selfish if it is part of the player and the player can see an other person. 
Does the player mean doing something when the noun is a selfish thing: it is very unlikely. 

The Hall of Testing is a room. "This place is curiously empty."
Manny is a man in the Hall of Testing. The player is Manny.
Jane is a woman in the Hall of Testing. "Jane is here. She's, most emphatically, not you."

Test me with "look at Jane's face/look at your face/look at pimple"

The problems are twofold:

  • How do I get the parser to efficiently refer to the player as “you” when we’re referring to parts of the player, and
  • How do I make it associate “you” as in “your face” as referring to the part in question?

This is probably a newbie mistake, but I’m at my wits’ end.

Well, that was bracing.

After a lot of looking around and poking about, I solved it.

"Overwritten on the body" A body part is a kind of thing. A face is a kind of body part. A face is part of every person. A pimple is a kind of body part. A pimple is part of every man. The Hall of Testing is a room. "This place is curiously empty."

So far so good. Everything is as before. But now, we make a few changes.

Understand "your/my/mine" as a thing when the item described is part of the person asked.
Definition: a person is other if it is not the player.
Definition: a thing is selfish if it is part of the player and the player can see an other person. 
Does the player mean doing something when the noun is a selfish thing: it is very unlikely.

Next, the “fix.” It’s ugly and clunky, but it preserves the sometimes transient nature of The Player. In other words, it changes the printed name of the body part in question whenever it is called.

Rule for printing the name of a body part when the player encloses the noun:
	Let N be indexed text;
	Let N be the printed name of the noun;
	replace the regular expression ".*[apostrophe]s " in N with "your "; 
	say "[N]".

Manny is a man in the Hall of Testing. The player is Manny. Understand "me" as Manny. 
Jane is a woman in the Hall of Testing. "Jane is here. She's, most emphatically, not you."
The hat is a thing. It is in the Hall of Testing.
Test me with "look at Jane's face/look at your face/look at pimple"

While I was typing a response to your post, it looks like you figured something out on your own. In case it may be helpful, here’s what I was going to suggest:

[code][First method–add the following to the code you posted originally]
The printed name of a face is usually “face”.
The printed name of a pimple is usually “pimple”.

After reading a command:
let typed-in be indexed text;
let typed-in be the player’s command;
replace the regular expression “my” in typed-in with “manny’s”;
change the text of the player’s command to typed-in.

Before printing the name of a body part that is incorporated by a person (called the owner):
if the owner is the player:
say "your ";
otherwise:
say "[owner]'s ".
[/code]

Since your second post indicates you may be familiar with the frustrating issues associated with “your former self,” I’ll skip what I was going to write about that. Furthermore, if you’re at a point where you can come up with that text substitution rule on your own then you probably don’t need the preface to the second method I was going to write so I’ll just post the code:

[code][Second method–in place of all the code you originally posted]
Embodiement relates one person (called the bodifier) to various things. The verb to embody (he embodies, they embody, he embodied, it is embodied, he is embodying) implies the embodiement relation.

A body part is a kind of thing.
A face is a kind of body part. A face is part of every person. The printed name of a face is usually “face”.
A pimple is a kind of body part. A pimple is part of every man. The printed name of a pimple is usually “pimple”.

Definition: a person is other if it is not the player.
Definition: a body part is selfish if the player embodies it.

Does the player mean doing something to a selfish body part in the presence of an other person: it is unlikely.

The Hall of Testing is a room. “This place is curiously empty.”
Manny is a man in the Hall of Testing. The player is Manny.
Jane is a woman in the Hall of Testing. “Jane is here. She’s, most emphatically, not you.”

After reading a command:
let typed-in be indexed text;
let typed-in be the player’s command;
replace the regular expression “my” in typed-in with “manny’s”;
change the text of the player’s command to typed-in.

Before printing the name of a body part that is incorporated by a person (called the owner):
if the owner is the player:
say "your ";
otherwise:
say "[owner]'s ".

[Assuming the game doesn’t have a homicidal maniac who carries the severed noses of his victims in his pocket:]

When play begins:
repeat with person-setup running through people:
repeat with part-setup running through body parts enclosed by person-setup:
now person-setup embodies part-setup.[/code]

Body parts, and in general any things/kinds of things that rely heavily on incorporation, are very awkward to deal with using Inform. I write a lot of code like this myself, so if you have any other questions please don’t hesitate to ask.

I love this!

The concept of relations is one I’ve just begun to dip my to into. Not too surprisingly (given my programmer inclinations) I want to abstract everything down to generalised situations, so I suspect relations would work like a charm. Must… learn… goddammit!

I was kinda proud of the solution I cobbled together, but your second solution is just plain elegant. I have to ask one thing, though, about one section.

After reading a command: let typed-in be indexed text; let typed-in be the player's command; replace the regular expression "my" in typed-in with "manny's"; change the text of the player's command to typed-in.

It seems this would iterate regardless of what was written, and would mean hard-coding you to a particular player name. What am I missing?

As an aside: how heavy is regex on the virtual machine anyways? I was crashing on a regular basis while trying to tame the indexed text.

I feel your pain. I’m no programmer, but due to the way my mind seems to work in general I’m the same way. However, if you approach every particular coding problem in Inform with a view to generalizing it to all situations, I think you’ll learn the ins-and-outs of the program much faster; so while it may be frustrating at first, eventually you’ll advance your knowledge very effectively compared to someone who writes highly specialized rules for one unique situation, then moves on to the next unique situation, etc.

You’re not missing anything; what you said is correct. If you’re making a game where the player will experience the world through the eyes of several characters, you could just add on lines to the rule:

After reading a command: let typed-in be indexed text; let typed-in be the player's command; if the player is Manny: replace the regular expression "my" in typed-in with "manny's"; if the player is Jane: replace the regular expression "my" in typed-in with "jane's"; change the text of the player's command to typed-in.
If you’re making some sort of game focused on astral projection, “Quantum Leap,” or something like that where the player will constantly be jumping through dozens of bodies, you could generalize this to:

[code]The printed name of Manny is “Manny”.
The printed name of Jane is “Jane”.

After reading a command:
let typed-in be indexed text;
let typed-in be the player’s command;
let currentname be indexed text;
let currentname be the printed name of the player;
replace the regular expression “my” in typed-in with “[currentname][apostrophe]s”;
change the text of the player’s command to typed-in.[/code]
Although not related to your question, this rule allows you to do other interesting things. For example, say we write “A thing called Manny’s suitcase is in the Hall of Testing.” If the player is Manny, I think it would be perfectly natural for them to type “x my suitcase” or “get my suitcase”. This rule facilitates that kind of easy interaction.

I’m not sure what you mean. What kind of trouble exactly did you have?

(edit) p.s. In the “Second Method” I posted above, the line “Before printing the name of a body part that is incorporated by a person (called the owner):” should actually read “Before printing the name of a body part that is embodied by a person (called the owner):” for two reasons:
a) To generally take advantage of the embodiement relation, and
b) One of the main points of using a relation here is to easily deal with further sub-incorporation, in cases where we want to add something like “Some eyes are part of every face.”

I will admit that I’ve made progress beyond my expectations during the short while I’ve worked with it. Also, what you say is absolutely true: I’ve lost count of the reams and reams of code that eventually collapsed under sheer feature bloat. Generalising these thing has become less of a cute trick and more of a survival strategy, these days. sigh

Very slick. I like it. Initially I was against it because I wanted to define all the characters by name in one place only. Biases, I suppose, and I’d lack the nifty effects you described.

Well, I tried, for instance, to echo “[name of object]”, and the virtual machine died. Then again, I suspect such use was highly… irregular… in the first place.

Anyway, I noted another bug cropping up in the example. The command works perfectly until such time as we try to refer to the other person by their assumed pronoun. Some extra fiddling and the inclusion of the Pronouns extension by Ron Newcomb helped me deal with it, but it now still requires post-processing, plus that it looks overly elaborate. I’ll see what I can do to make it a bit more elegant.

I honestly don’t know much about pronoun-usage in Inform; perhaps someone else can address that. I never use pronouns when playing a game, and since all my Inform-writing is designed only to entertain myself I (perhaps unwisely) don’t take pronouns into consideration when writing code.

If that’s exactly what you wrote, “[name of object]” doesn’t have a valid referent as far as I know. You could however have “[printed name of the noun]” or “[printed plural name of the item described]” or just “[noun]”, for example. Also as far as I know you can’t use text tokens to compile indexed text, since Inform (rightly) wants to be very particular about indexed text. For example, if you wrote “Manny is a man,” you wouldn’t be able to write “Let “[man]” be indexed text,” since there could be men other than Manny and Inform would have no way to decide what to fill in for “[man].”

Oh, I just noticed this – I pulled something similar once. I believe that I had tried to use a [name of object] token in a phrase to determine the name of the object, which led to an infinite loop and crashed the virtual machine. “[printed name of object]” worked, I think.