Showing posts with label Hugo theory. Show all posts
Showing posts with label Hugo theory. Show all posts

Thursday, July 19, 2012

my ASK ABOUT conclusion

Ok, so I played with this a little bit today. Surprisingly, the method I thought would work better didn't work at all. I forgot that while an object's property can be a property routine, you can't just fill property array elements with calls to routines to add some extra dynamic elements. It's pretty important for a game to support multiple adjectives per object, so I ended up abandoning that route.

That leaves me with the other method. Here is the code I came up with:
verb "ask", "question", "consult"
    * (LivingAsk) "about" "his"/"her"/"its" anything                   DoAsk

routine LivingAsk(var)
{
    if var is not living
        {
        "That doesn't make any sense."
        return false
        }
    local i
    for (i = 2;i < words ;i++ )
        {
        if word[i] = "about"
            break
        }
    local a
    select word[(i + 1)]
        case "his" : a = "he"
        case "her" : a = "she"
        case "its" : a = "it"

    if var.pronoun ~= a or not Contains(var,xobject)
        {
        "That doesn't make any sense."
        return false
        }
    else
        return true
}
The downside of the above is that you have to predict proper error messages for every case (it's conceivable that there are times where "That doesn't make any sense." doesn't cut it). Just the same, I was pleased that this worked at all.

Anyhow, drumroll, please...

The easiest, simplest way to support >ASK CHARACTER ABOUT HIS POSSESSION

Just add this line to your code:
removal "his","her","its","your"
("Your" because we also want to accept, CHARACTER, GIVE ME YOUR POSSESSION)

Just ignoring these words completely will largely support our cause, I figure. It is more likely that the player will only use these words in instances where they make sense, then they are likely to type, ASK YOUR CHARACTER HIS ABOUT HER ITS POSSESSION (which will still be processed, using the removal method).

So, yeah, that'll make your game sound smarter. Otherwise, you could always mix-and-match between these two methods to make your game seem as smart as possible (I'd probably always declare "your" as a removal, as code that only applies to order_response's seems like it'd be a pain in the ass), and there's plenty of room for improvement with the routine-grammar-token route (for instance, you could have it rely on an ownership system that is unaffected by actual possession).

>ASK ROODY ABOUT HIS NEXT TASK

A recent review of a game at the IF Database reminds me that it bugs me that a player can't easily ask an NPC about his or her possessions with something like >ASK MAN ABOUT HIS POSSESSION ('his' being the important word here). I think my next little distraction will involve trying to come up with the simplest, best way to handle this.

The two approaches I am considering:
  1. Make a routine to added to the adjective property array of any object that can be picked up by an NPC. Have the routine return the word "his" or "her" or "its" based on the NPC's gender and whether the object is in a character's possession.
  2. Make a verb grammar that uses a routine as a grammar token to verify that the item is being held by the right person.

The first approach will probably be easier and more-likely-to-succeed, but we'll see what works out better.