Artificial Intelligence in Game Design Goal-Oriented Behavior
Goals Complex characters have goals Issue: Add to realism of character Actions appear motivated instead or reflexive Player must be aware of character motivations Example: Napoleon “boss” NPC Capture other cities Protect own cities Increase gold level Issue: What if goals conflict? Get gold Avoid player ???
Goals and the Sims Overall goals (player meets) Positive and negative goals Goals based on physical needs Hunger Energy Fun Etc. Characters automatically choose actions to meet needs
Goals and Actions Goals determine actions than fulfill need Game keeps list of actions for each need Which actions should NPC take to fulfill goals? Hunger Eat snack Cook dinner Energy Nap in chair Sleep in bed Fun Go to concert Paint Read
Insistence of Needs Needs may have “degree of urgency” (insistence) How critical is need? How important is this need relative to others? How much of an action is needed to fulfill need? Represented as number Higher = greater need Zero = no need Need Insistence Hunger 5 Energy Fun 3
Actions and Goals Actions can permanently fulfill goals Replaced with another related goal (Sims) Ends game (Napoleon captures all cities in world) Actions can temporarily lessen needs Action: Need – n lessens that need by n Hunger Eat snack: Hunger – 1 Cook dinner: Hunger – 5 Energy Nap in chair: Energy – 1 Sleep in bed: Energy – 5 Fun Go to concert: Fun – 4 Paint: Fun – 2 Read: Fun – 1
Choosing Actions Simple approach: Choose goal with highest insistence Choose action that gives largest decrease Need Insistence Hunger 6 Energy Fun 3 Greatest need Best action Eat Eat snack: Hunger – 1 Cook dinner: Hunger – 5 Energy Nap in chair: Energy – 1 Sleep in bed: Energy – 5 Fun Go to concert: Fun – 4 Paint: Fun – 2
Side Effects Actions can effect multiple goals Side effect Drink Coffee Hunger – 1 Energy – 1 Eat at Restaurant Hunger – 4 Fun – 3 Gook Gourmet Meal Hunger – 5 Fun – 1 Energy + 1 Side effect Fulfilling one goal increases other needs
Overall Utility Utility-based decision making Determine effect of each action on total needs Choose action that has best overall effect One criteria: sum of all needs Need Current level After Cook Gourmet Meal After Drink Coffee After Eat at Restaurant After Sleep in Bed Hunger 3 2 Energy 1 Fun 4 Total effect 6 7 Best action
Overall Utility Problem: This can ignore very severe needs Behavior does not appear rational! Need Current level After Eat at Restaurant After Sleep in Bed Hunger 3 Energy 10 5 Fun Total effect 11 Will be chosen, even though Sim is very tired!
Overall Squared Utility Common solution: Total discontentment = sum of square of needs Need Current level After Eat at Restaurant After Sleep in Bed Hunger 3 02 32 Energy 10 102 52 Fun Total effect 100 43
Planning and Preconditions Actions may have preconditions before they can be taken Multiple actions required to meet needs Action Preconditions Postconditions Preconditions which character meets Action Postconditions meets Action Preconditions Postconditions meet need 12
Planning and Preconditions Example: Microwaving food Uncooked food in fridge Get food Have uncooked food meets Have uncooked food Have microwave Cook food in microwave Have cooked food meets Have cooked food Eat food Hunger - 5
Planning Methods Scripted action sequences Actually single action with what appears to be multiple steps Long animated sequence Very simple to implement (no planning needed!) Weaknesses: Cannot interrupt sequence without starting over entirely Phone rings while cooking Cannot start plan until all preconditions met Get food Cook food in microwave Eat food Have uncooked food Have microwave Hungry - 5