Problem-Solving Characters

version 2 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next

  • Example: *** Motive and Method - Answering WHY and HOW, and some simple parsing to understand the question.
    We'll start with the hot potato example, then add the necessary code.
        "Motive and Method"
        Include Problem-Solving Characters by Ron Newcomb.
        There is room.
        When hindered by the basic accessibility rule:
            we could try attacking the holder of the noun;
            if the holder of the noun is not the holder of the person asked, we could try opening the holder of the noun;
            we could try dropping the holder of the noun.
        Bob is a man.
        A microwave is a closed openable transparent container. Bob and the microwave are here.
        A potato is in the microwave.
        Persuasion: rule succeeds.
        A thing can be hot. The potato is hot.
        Check an actor taking something hot (this is the hot potato rule): say "Too hot!" instead.
        Report an actor examining something hot: now the potato is not hot; say "It eventually cools down." instead.
        When hindered by the hot potato rule, we could try examining the noun.
        Test me with "Bob, take the potato / a / wait / why did you attack the microwave / what are you doing / how will you take the potato / wait / why did you take the potato".
        Persuasion: persuasion succeeds.
        Unsuccessful attempt by when the reason the action failed is the basic accessibility rule: say "'Just a sec.'" instead.
        Unsuccessful attempt by Bob attacking something: say "Bob stabs the open button ineffectively." instead.
    Now we'll add the code to handle the questions. The first hurdle is the parser. WHY and HOW questions take an entire command after them, but if we require a wording like WHY DID YOU TAKE THE POTATO, then we can capture the WHY/HOW in truth states that vary, cut the rest, and leave only TAKE THE POTATO for the parser.
        Asking why, asking how are truth states that vary.
        After reading a command:
            now asking why is (whether or not the player's command includes "why");
            now asking how is (whether or not the player's command includes "how");
            while the player's command includes "why/how/will/did/do/could/you":
                cut the matched text.
    But to whom is the player speaking? And if the player enters DAPHNE, WHY DID YOU TAKE THE POTATO, then they're clearly asking Daphne regardless who they were talking with previously. Let's remember conversation partners, and handle the directly-addressed case.
        The current interlocutor is a person that varies, Bob.
        Persuasion when asking why is true or asking how is true: now the current interlocutor is the person asked; persuasion succeeds.
    Finally, the money shot. The leftover command is parsed as taking the potato, but this Instead rule uses the truth states to determine that a question needs answering rather than a potato needing taking. We feed the current action to a phrase which searches the person's entire agenda for a match. If it finds taking the potato in Bob's past, present, or future, it then gives it to one of the phrases that gets the motive (why) or the method (how) for it. Note that we don't spend much time here dealing with differences in tense, endless WHYs or HOWs, creating attempt based rulebooks for a character, etc. which we would do in a real work.
        Instead of doing anything when asking why is true or asking how is true:
            let the act in question be the current action from the agenda of the current interlocutor;
            if the act in question is nothing, say "'I don't know what you're talking about.'" instead;
            if asking why is true, now the act in question is why the current interlocutor is doing the act in question;
            if asking how is true, now the act in question is how the current interlocutor will accomplish the act in question;
            if the act in question is nothing, say "'Like this,' Bob quips." instead;
            if Bob plans the act in question, say "'Er, because you told me to.'" instead;
            if asking why is true, say "'Because I'm [act in question],' answers Bob.";
            if asking how is true, say "'By [act in question],' answers Bob."
    Similarly, we can make a current response.
        After reading a command when the player's command matches "what are you doing", replace the player's command with "ask [the current interlocutor] about themself".
        Instead of asking someone about "themself/himself/herself", say "'I'm [what the noun will do next],' replies [the noun]."