I would like to implement disguises, where an actor can disguise himself as somebody else and the NPCs respond intelligently.
[code]An appearance is a kind of thing.
Resemblance relates a person to an appearance. The verb to resemble (he resembles, they resemble, it is resembling, he is resembling) implies the resemblance relation.[/code]
So I can get as far as, to use a somewhat silly example, “Zorro-mask is an appearance. Diego resembles Zorro-mask.” Or maybe “when an actor wears the hood and cape, he resembles Zorro-mask.”
Then what I need is some way to create a correspondence between what an actor looks like, and what other actors think that means. When Rosa and Juan see Diego walk in the door, wearing his disguise, Juan thinks it’s Zorro, but Rosa knows it’s Diego.
But relationships can’t include three poles — Juan identifies the Zorro-mask appearance as Zorro. (I presume I have to create a placeholder “person” named Zorro.) And four is right out (eg, “When Diego resembles Zorro-mask, Juan identifies Diego as Zorro”). Ultimately, I would like a system flexible enough to understand that anybody with that disguise may be identified as Zorro. The player might walk into the room and see “Zorro is here,” but not know who was in the disguise just now.
Where do I start? A table? I have no idea which tools to use, here.
I think a rulebook might be reasonable. I never remember how rulebooks return a value, but I’m pretty sure that they can. So you set up a “perception” rulebook that returns an appearance.
[code]Perception of Juan when the person asked is Diego: Rule succeeds with result Diego-appearance.
Perception of Rosa when the person asked wears the Zorro mask: Rule succeeds with result Zorro-appearance.[/code]
For convenience, you can create a “to decide which appearance” phrase that runs the rulebook and returns the result. [note to Inform developers - can we integrate “to decide” phrases with rulebooks more seamlessly?]
If “the person asked” doesn’t work for you, you’ll have to set up a new global variable to use as a parameter, since a rulebook can only take one parameter. Perhaps “the disguised person” or “the perceived person”.
It’s not clear to me that the resemblance relation helps you at all. You could just have the rulebook return objects (so Diego resembles Diego or the Zorro mask, etc.) To decide phrases can take multiple parameters, and I’ve done something like this before:
To decide which object is the appearance of (the view - a thing) to (the viewer - a person):
Now the disguised item is the view;
Follow the perception rules with the viewer;
decide on the result of the rulebook.
Like I said, I don’t remember the syntax for rulebooks that return a result, so that probably won’t compile, but you get the idea for how to turn phrase parameters into global variables for use in a rulebook.
A phrase, a rulebook, or an activity would all work. (A phrase is simple but gives you limited ability to split up the code. A rulebook is middlin’ flexible. An activity has before/during/after rulebooks, which gives you extra stages to work with.)
The important thing – the tricky part, really – is to have a test that you can put in your code. For maximum flexibility, this test should be an adjective. That means relying on “is” verbs, which is awkward, but gives you options. For example:
Definition: a person is Juan-like if …
Now you can write any of:
if Steve is Juan-like: …
if someone in the Kitchen is Juan-like: …
if someone (called P) in the location of Rosa is Juan-like: …
for all Juan-like people in the Kitchen: …
I think these are the constructions you’ll be relying on in your code.
Now, in that definition line, “Juan” isn’t a variable. (A definition can’t take multiple arguments.) So you’ll need one of those definition lines per character, and you won’t be able to say
*if Steve is someone-in-the-Kitchen-like: …
But I suspect that will never come up.
As for the body of the definition, that’s where you stick in a phrase or rulebook or activity invocation. There is more work there, but I think it will be easier when you know what framework it has to go in.
Thank you, zarf and capmikee. Of the solutions presented, I think capmikee has the edge, at least in simplicity. Defining adjectives never occurred to me.
Where I was going with the appearance object, zarf, was to establish actor knowledge; by creating a relationship between appearance and actor, I could establish that while Juan and Rosa have both seen Zorro (that is, the appearance Diego resembled), only Rosa knows it was Don Diego. Then at a later time, Juan learns who Zorro really is, so I’ll figure out a way to shift that dynamically. I figured an appearance object, related to an actor, gave me stuff to tie recognition to. Maybe I should tie recognition to the actor itself. To decide if Juan recognizes Diego when Diego is not Diego-like, or something.