intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 18, 2013 5:12 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Jul 17, 2011 6:27 pm 
Offline

Joined: Wed Jul 06, 2011 7:44 pm
Posts: 15
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:
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.

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:
Code:
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?


Top
 Profile Send private message  
 
PostPosted: Sun Jul 17, 2011 7:52 pm 
Offline
User avatar

Joined: Sun Nov 22, 2009 12:58 pm
Posts: 399
Location: Malmö, Sweden
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.

_________________
~Björn Paulsen


Top
 Profile Send private message  
 
PostPosted: Sun Jul 17, 2011 8:02 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2127
Location: Burlington, VT
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.


Top
 Profile Send private message  
 
PostPosted: Sun Jul 17, 2011 8:23 pm 
Offline

Joined: Thu Oct 22, 2009 4:31 pm
Posts: 1137
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;
   decide yes.
   

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.

--Erik

_________________
Glimmr: Advanced Graphics for I7
blog | download | bug-tracker


Top
 Profile Send private message  
 
PostPosted: Sun Jul 17, 2011 9:44 pm 
Offline

Joined: Wed Jul 06, 2011 7:44 pm
Posts: 15
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

Code:
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...


Top
 Profile Send private message  
 
PostPosted: Mon Jul 18, 2011 1:14 am 
Offline
User avatar

Joined: Fri Jul 15, 2011 2:46 pm
Posts: 230
Location: Cental Ohio
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.

_________________
David Good
http://david-good.com/portfolio/interactive-fiction/
http://www.facebook.com/duodave


Top
 Profile Send private message  
 
PostPosted: Mon Jul 18, 2011 1:44 am 
Offline

Joined: Thu Jun 02, 2011 7:55 pm
Posts: 23
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."


Top
 Profile Send private message  
 
PostPosted: Mon Jul 18, 2011 3:34 pm 
Offline

Joined: Fri Jul 16, 2010 2:09 pm
Posts: 1950
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.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group