Is it possible – in the core inform language or by an existing extension – to have a relation that is multivalued rather than just on/off? For example, a person could like something, dislike it, or (the default) be indifferent to it.
I know it’s possible to set this up using two relations:
Liking relates various people to various people.
The verb to like (he likes, they like, he liked, it is liked, he is liking) implies the liking relation.
Disliking relates various people to various people.
The verb to dislike (he dislikes, they dislike, he disliked, it is disliked, he is disliking) implies the disliking relation.
But this makes it possible for someone to both like and dislike something at the same time, and requires the coder to always remember to change both relations at once:
now Spot likes the red chew toy;
now Spot does not dislike the red chew toy; [unfortunately not redundant...]
Any known way to make this into a single three-state relation rather than a pair of two-state ones?
There’s some mention of this on the uservoice page. The capability that you describe isn’t supported at present, and I can’t really envision any way to do something like that within I7 right now, other than in a very limited (and likely to be manually operated) sense.
One possible hack might be to define a relation “really likes” as X really likes Y if X likes Y and X does not dislike Y. Then <X dislikes Y, X really likes Y, X neither likes nor dislikes Y> would be exhaustive. But you’d still have to change both relations manually when you wanted to make sure that X really liked Y (probably by writing a phrase for that), and you’d have to make sure you always checked “really likes” instead of “likes,” so it might not be that much less inconvenient.
I think your basic approach will work relatively well if you just add some phrases to allow you to set the three states with one line of code each, along with a to-decide phrase to let you test the indifference pseudo-relation with a single line (obviously, you can already test liking and disliking with a single line). Here’s some code:
[code]Liking relates various people to various people. The verb to like (he likes, they like, he liked, it is liked, he is liking) implies the liking relation.
Disliking relates various people to various people. The verb to dislike (he dislikes, they dislike, he disliked, it is disliked, he is disliking) implies the disliking relation.
To cause (S - object) to like (O - object):
now S likes O;
now S does not dislike O.
To cause (S - object) to be indifferent to (O - object):
now S does not like O;
now S does not dislike O.
To cause (S - object) to dislike (O - object):
now S does not like O;
now S dislikes O.
To decide if (A - a person) is indifferent to (B - a person):
if A likes B, decide no;
if A dislikes B, decide no;
Test is a room.
Spot is a person in Test.
Larry is a person in Test.
When play begins:
cause Spot to like Larry;
if Spot likes Larry, say “Spot makes goo-goo eyes at Larry.”;
if Larry is indifferent to Spot, say “Larry ignores Spot.”
Things will be more complicated if you try to do more than three possibilities, of course, but that’s to be expected.
Thanks for the rapid response, Elias, Matt, and Ektemple. I had a feeling there was no direct way to do this, but I wanted to be sure I wasn’t missing something.
I like the pseudo-relation suggestion. About the only thing it sacrifices is the ability to say things like “Whiskers likes every catnip toy” – you’d have to loop over catnip toys, calling the “Cause to like” phrase on each – but it’s still much better than manipulating both of the underlying relations by hand.
In fact, it now occurs to me that with a set of N hidden underlying relations and some convenient phrases, you could have a pseudo-relation with 2^N distinct values. For example, the phrases
to decide which number is the opinion of (p - a person) toward (t - a thing):
to set the opinion of (p - a person) toward (t - a thing) to (n - a number):
to alter the opinion of (p - a person) toward (t - a thing) by (n - a number):
could implement numerical opinions ranging from 0 to 255…when what is really going on behind the scenes is that eight hidden relations are carrying the eight bits of the number. After writing the three “interface” phrases, the programmer would never again have to think about those eight underlying relations…
Yeah, I think the best way would be to define a variable, then put a value into it, then use some sort of if-then/switch statement as your control.
“like” could be the name of the variable, then how much it’s liked could be numeric, I suppose.
Yeah I’d like a feature like this, although with just numeric values. Then I could do things like “Bob owes George 20 dollars. Hamilton owes the player 50 dollars. The player owes Don Corleon 1000 dollars.”
I had need of something like that when I was writing Multitudes. I ended up using a table read by To Decide phrases and conditional relations and set by To increase/decrease etc. phrases.