Which do you mean? Question

In one of my games everyone is wearing a brown coat. How do I handle the following problem?

Is there any reason why the coats have to be indistinguishable from one another? If not, probably the easiest way to deal with this is simply to give each coat a unique name (e.g., John is wearing the brown tweed coat, Bill is wearing the brown leather coat, and Ted is wearing the brown wool coat).

If you do need them to be indistinguishable, then I think there are ways to use “understand” statements so that items can be understood by their relationships (so that a coat could be identified by the person who is wearing it at the time), but I’ll leave it to somebody who knows this area better to point you towards the proper sytax for doing that.

Robert Rothman

If possible I would like them to be indistinguishable from one another. I normally use the trick of making like things slightly different - like notebook, notepad, pad, booklet etc. But, I thought this time I would see if a proper solution existed.

Could you not just add onto the beginning of each object:


John's brown coat is a thing. Bill's brown coat is a thing. Your brown coat is a thing. etc.

alternatively chapter 3.18 may provide a way.

In the Belfry is a man called the vicar. The indefinite article of the vicar is "your local".

You may possibly be able to add an indefinite article to the coats aka “your”, “Bill’s” and “John’s”.
Not sure if that works for objects.

Check out Chapter 17.29, especially the noses part of the “Walls and Noses” example, and possibly also Chapter 4.14 (the “The Night Before” example; disambiguation in the Inform documentation is very nose-centric). Failing that, you might look into Jon Ingold’s Disambiguation Control extension.

It’s possible to have things be named according to relations. It’s tricky to do this sort of thing, though - you might be better off giving each coat a name like “John’s brown coat.” Inform does that for you when you create anonymous incorporated objects, but it doesn’t seem to do it for anonymous worn objects.

I think in this case you would have to create a kind-of-value called “possessive adjective” or somesuch, and assign one to each person. Then you can understand a person’s possessive adjective as referring to something related by enclosure. And you can tack the adjective onto the printing the name activity or the indefinite article property of the coat. Be careful, though - Inform 7 doesn’t give you any hooks into the definite article (which is frustrating because Inform 6 does). So you might have to make the coats proper-named and then fake the article, or perform some other similar form of hack.

This sort of thing ought to go into an extension. Does one exist already?

[simul-post: oh yes, Walls and Noses. Good advice.]

Beware, though - as I mentioned before, wearing doesn’t have the same name-generating effects as incorporation, so Walls and Noses won’t work by itself. To see what I mean, compile this source and then look at the World Index:

[code]Test is a room.

A brown coat is a kind of thing. It is usually wearable. A nose is a kind of thing.

Every person wears a brown coat. A nose is part of every person.

John, Bill and Ted are men in Test.

You’ll see this:

Test - room where play begins John - man part John's nose - nose worn brown coat - brown coat Bill - man part Bill's nose - nose worn brown coat - brown coat Ted - man part Ted's nose - nose worn brown coat - brown coat yourself - person part your nose - nose worn brown coat - brown coat

Making the possessive part of the name of each object (e.g., John’s brown coat) won’t accomplish awhat you need if what you really need is that the objects themselves be identical. For example, if there is any chance that the characters could switch coats, this approach could result in John wearing the thing that is named “Bills’ brown coat” (since “Bill’s” is part of the object’s name rather than something which changes with the wearer). On the other hand, if you don’t really need indistinguishability but you just want them to look the same to the player (except for an unchangeable characteristic such as who the owner is), then this idea should work.

Multiple indistinguishable objects are, to me, one of the most confusing aspects of Inform 7.

Robert Rothmsn

Thanks for all the advice everyone. I think I can make the “John’s brown coat” technique work in the game.

So I have some code that works for some parts of this, but it also has some weirdnesses. If the NPCs aren’t exchanging brown coats then just calling everything “Bill’s brown coat” etc. should work fine.

Here’s the bit that works, though perhaps a bit too broadly:

[code]Section 2 - 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.

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

Section 3 - Disambiguation

For printing the name of a brown coat (called trench) while asking which do you mean:
if a person encloses trench:
say “[random person enclosing trench]'s brown coat”;
say “the brown coat”. [/code]

Section 2 is what lets the game understand “Bill’s brown coat” as a brown coat that Bill wears (or carries, or whatever). First it takes “x bill’s brown coat” and turns it into “x bill 's brown coat” so the apostrophe-s can be understood as a separate word. Then it takes “bill 's” as referring to something that bill encloses – so if there are a bunch of brown coats, but Bill only encloses one, then “bill’s brown coat” will wind up referring to Bill’s. (If Bill is wearing one and carrying another, there’s a problem.)

This would produce problems if one person could pick up another, but that’s not that common – if you have portable persons, don’t use this code. (There’s some discussion of related code here; the initially posted version of the code has at least one bad error where I wrote “the noun” instead of “the item described,” and there’s a whole lot of talking past each other when something refused to compile because of an extraneous line break that worked its way into the copy-paste.)

Section 3 is what actually answers your original question – it ensures that when disambiguating, it asks “Which do you mean, Bill’s brown coat, Bob’s brown coat, or Mike’s brown coat?” This wouldn’t be useful without section 2, because section 2 is what lets the game understand the answer.

OK, that’s the part that works, at least kind of. Here’s some bizarritudes.

  1. In the code I have to test this, I created the brown coats thus:

[code]a brown coat is a kind of thing.
a brown coat is always wearable.
A brown coat is usually improper-named.
The printed name of a brown coat is usually “the brown coat”.
Starter is a room.

Bob and Mike and Bill are men in Starter.

Brown coat 1 is a brown coat. Bob wears brown coat 1. Brown coat 2 is a brown coat. Mike wears brown coat 2. Brown coat 3 is a brown coat. Bill wears brown coat 3.[/code]

Why did I create the brown coats by hand? Because when I do this instead:

Bob wears a brown coat. Mike wears a brown coat. Bill wears a brown coat.

the game doesn’t even try to disambiguate them. All references to “brown coat” automatically go to Bob’s brown coat. Same if I just start with the coats on the floor, by saying “Three brown coats are in Starter.” This seems bad.

  1. I’d have liked to write this:

Understand "[something related by reversed wearing] 's" as a thing.

but when I did, any reference to a brown coat caused the game to hang. I don’t know why.

  1. There may be some hinkiness about the articles that apply to the brown coat once we define its name by hand. I think I fixed this in my code fragment (in some stuff I didn’t post), but be aware that issues might arise.

Matt W’s post rings a bell – I once wrote a game in which the lucky player found himself in a harem full of lovely ladies, each wearing a veil. I remember struggling over the use of indexed text to remove the apostrophes so that the player could specify whether he wanted to lift the blonde’s veil,the redhead’s veil or the brunette’s veil. (Nothing off-color happened when you did; you either got kissed or got slapped, depending on which girl you chose). I think you have to go through the indexed text thing whether you use the approach of understanding things by their relations or you use the approach of making the possessive part of the thing’s name; I think the problem is that the parser generally does not understand an apostrophe as part of a word. I was surprised that the Punctuation Removal extension did not provide a more automated means of stripping out the apostrophes, as it does for other types of punctuation marks.

Robert Rothman

As it was explained to me when someone told me how to do this, the problem isn’t so much that Inform doesn’t recognize the apostrophe as part of the word, it’s that it doesn’t recognize the relation between “Bill” and “Bill’s,” or “Bill” and “Bills” for that matter; you have to break the apostrophe-s into a separate word so it can be parsed separately. (Though if you auto-generate noses through “A nose is part of every person,” the noses will come out named “Bill’s nose” etc., so that’ll be taken care of automatically.)

What if you did this?

Bob wears a brown coat called Bob's brown coat. Mike wears a brown coat called Mike's brown coat. Bill wears a brown coat called Bill's brown coat.

That’s fine, and I think it’s the solution that the original poster is going to adopt, but I’m still curious why the other solution results in no disambiguation whatsoever. (It may be some kind of failsafe to prevent disambiguation loops when you have a bunch of identical items in the same location.)

Note also that the behavior isn’t identical – in the code I posted, whatever coat Mike is wearing (or carrying) will be called “Mike’s brown coat”; in this version the coat Mike starts with is always called Mike’s brown coat. Which is probably better (and won’t be an issue if people don’t switch coats) but I do want to know if my way can be made to work.

If I remember correctly, the parser refuses to disambiguate between anonymous objects with identical names. But I could be wrong.

That’s about right. The parser has a notion of indistinguishable objects, so that (e.g.) if you see six identical coins and you type “take coin”, it just picks one.

I don’t remember exactly under what conditions objects are indistinguishable – I tend not to use anonymous or identical objects in my games – but this sounds like that case.

That seems like an excellent decision. And I guess it settles rotter’s original question; s/he doesn’t want to make the brown coats indistinguishable, because then they’ll never get disambiguated, no matter how many tricks we try.

(If anyone has an idea about the problem I had with the reversed wearing relation crashing the game in run-time, I made a new topic here.)