To begin with, a thought provoking quote:
“Subtle interactions such as conversations are still out of reach of autonomous AI; games rely on clever scripting or cutscenes to get that across. If we as a field will master these types of interactions, more parts of the game can be interactive, and possibly whole new game genres may become feasible.”
– Remco Straatman in The Future of AI in Games (2010)
So what would it take to allow free form conversation in a text based game? More after the break.
A Short Conversation
Imagine the following conversation with an NPC:
For a game to generate this kind of dialog in a consistent way, a large amount of infrastructure needs to be in place: parsing and grammar rules, conversation topic tracking, dialog content and so on. The game also needs to perform reasoning using NPC and general knowledge.
Processing the Question
Consider what an advanced game engine might do to process the question, "Should we go back to the village?"
- The words "back to" are used to disambiguate which village is meant: a village visited by the player and the NPC (if there is more than one such village, probably the most recently visited one). Call it village X.
- The sentence is understood as: “PC asks NPC opinion of action: PC and NPC go to village X.”
- The NPC evaluates the action.
- A plan is formed with the goal, “PC and NPC are in village X.” This goal is found to be achievable, with no significant obstacles or events predicted on the way.
- The consequences are evaluated. One possible consequence is meeting a dangerous enemy in the village who is likely to attack them.
- The NPC weighs up: potential benefits (unknown, but since it was suggested by the PC, assume there is a good reason); potential risk (medium); the NPC’s personality and emotions (moderate level fear about consequences). The result is neutral – the benefits may or may not be worth the risk.
- The end result is that the NPC objects to the action (on the grounds of danger), but not strongly enough to refuse outright.
- A response is generated to express this: "It could be dangerous". Some alternative responses include:Risky. Why do you want to go back there?I'm not sure it's worth the risk.What about that guy who attacked us?I don't know ... maybe.Why?
Checking the Conversation Context
The player replies, "I've run out of arrows".
- This statement implies several things:
- “PC possesses zero arrows”
- “PC previously possessed nonzero arrows”
- “PC desires nonzero arrows” (probable implication of the phrase “run out”).
- The game checks if this response matches the current conversation context, which is: the PC asked for an opinion (about going to village X) and the NPC objected (asserting danger).
In this context there are several possible responses from the player:
- End the conversation or change the topic (implying that the PC was persuaded by the objection).
- Agree with the objection: "OK, forget it".
- Disagree with the objection: "I don't think so".
- Attempt to persuade the NPC.
Detecting Attempted Persuasion
From the above list, the PC could either be changing topic or trying to persuade the NPC. The game checks if the PC’s response can be interpreted as persuasion: does it justify the PC’s proposal and/or counter the NPC’s objections?
- Proposal: PC and NPC go to the village.
- Assertion: PC possesses zero arrows.
- Is the assertion a problem, and is the proposal its solution? (Does the assertion justify the proposal?)
- Yes, this is a problem. General knowledge confirms that people with a bow (which the PC has) desire multiple arrows. This is reinforced by the probable assertion, “PC desires nonzero arrows”.
- Now the game needs to decide if the action “PC and NPC go to village X” would contribute towards the PC having nonzero arrows.
- The game forms plan A with the goal “PC has nonzero arrows.” There are multiple solutions: (1) get arrows from a shop in village X, (2) get arrows from a village further away, (3) go back the way they came and collect the PC’s spent arrows, or (4) collect wood, feathers and flint and manufacture some arrows.
- The game now has information about alternate solutions, which the NPC can potentially suggest to the PC ("We can get arrows in village Y; it would be safer").
- Note that the search space needs to be limited (e.g. by time). It is not a reasonable plan to take a six month journey to another continent just to buy some arrows.
- The game forms plan B with goal “PC and NPC are in village X” and finds the optimal solution. Starting from the final state of plan B, the game forms plan C with goal “PC has nonzero arrows” and finds the optimal solution.
- The game finds that plan C corresponds to solution (1) of plan A, but is shorter: in other words, obtaining arrows from village X is easier if you start from village X. Therefore the proposal does indeed contribute towards the the assertion, “PC possesses nonzero arrows.”
- Note that this approach is not perfect: some plans may contradict other (potentially more important) goals in the game, such as the PC heading for a certain location, etc.
- If plan C is longer than whichever solution in plan A it corresponds to, the game assumes that the player has changed the conversation topic (the logic being: going to village X has nothing to do with obtaining arrows). But it is possible that the player’s assumptions are incorrect. For example, maybe no one in village X actually sells arrows, or they are all sold out.
- To deal with this problem, the game could have a general knowledge rule such as, “Weapons are usually sold in settlements.” So when the plans are created, the goal “PC has nonzero arrows” will be met by going to village X, even though that is not what would actually happen – a plan does not have to be successful to be valid.
- If NPC knowledge contradicts the general knowledge rules used in a plan, the NPC could point this out: "They don't sell arrows there".
Responding to Persuasion
- The game has determined that the PC is trying to persuade the NPC. Now it must decide whether the NPC is swayed by the PC’s argument.
- In the mind of the NPC, the consequences of agreeing or
disagreeing with the PC are:
- Agree: (1) Exposure to danger; (2) The PC will have some arrows (which according to general knowledge is desirable for the NPC; there could be a rule like: “The more well armed person P is, the more beneficial for P’s companions”).
- Disagree: The PC will have no arrows, which is undesirable for the NPC.
- The fact that the PC is attempting to persuade the NPC adds
some additional factors:
- Agree: (1) The PC will be glad to satisfy his goal of getting arrows (which is desirable for the NPC because the PC is his friend); (2) It is an act of friendship for the NPC to take a risk to meet the PC’s goal (which is internally rewarding for the NPC, and the PC might owe him a favour).
- Disagree: The PC may be sad about not satisfying his goal (undesirable for the NPC because the PC is his friend).
- There are several other possible factors as well:
- The NPC’s personality. If the NPC is afraid of conflict, he might be reluctant to disagree with the PC.
- The NPC’s mental model of the PC. For example, the NPC may understand the importance of various things to the PC.
- The relationship between the PC and NPC. The PC may be seen as a friend, rival, enemy, potential ally or total stranger. The NPC might despise or look up to the PC due to their relative status, prejudice, reputation etc.
- The NPC’s emotional state. In a bad mood, the NPC might not be inclined to do the PC any favours; if the NPC is feeling grateful to the PC, he might take more risks for him than usual.
- The NPC’s belief about the PC’s emotional state. If he believes the PC is angry, he might not want to upset him any further by disagreeing with him.
- Weighing up all these factors, the game decides that
the NPC has been persuaded to go to the village, and generates
the text: "OK then, let's go." The NPC
could equally have said:No more arrows? That could be a problem. Let's go.Well that settles it. Back to the village then.Back we go, then.Well, I need a good feed anyway.
- For this last response, the game needs to search for benefits of going to the village other than just obtaining arrows for the PC: a satisfying meal.
Other Responses to Persuasion
If the NPC was not persuaded, there are various possible responses:
- NPC simply refuses: "It's not worth the risk".
- NPC adds more arguments and/or reiterates previous arguments (either for or against the proposal): "And I could do with more supplies. But it just seems like such a risk.".
- NPC suggests an alternative plan. Plan A resulted in multiple solutions to choose from: go to another village, collect spent arrows or make some by hand. Another possible solution is for the PC to go to the village alone: "You go, and I'll meet you back here".
- NPC suggests an improvement to the original plan: "Maybe we should go in disguise".
- NPC suggests an alternative goal: "How about getting a slingshot?"
- NPC negotiates: "I'll go if you buy me a horse".
- NPC broadens the conversation topic: "I'd just like a break from constant peril".
Thoughts
Processing even a brief conversation can require surprisingly complex rules:
- Generating plans to achieve goals, and evaluating their costs and benefits.
- Modelling NPCs’ personality and emotions to determine their reactions.
- Interpreting responses according to the current conversation context.
As human beings we do these kinds of things automatically, but it is challenging to try and list the rules of conversation we use every day.
Later on in this series we will look at whether the rules can be made more manageable.
No comments:
Post a Comment