Artificial Intelligence in Game Design
Goal-Oriented Behavior
Goals
• Complex characters have goals– 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 snackCook dinner
Energy Nap in chairSleep in bed
Fun Go to concertPaintRead
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 0
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 0
Fun 3
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
Greatest need
Best action
Side Effects
• Actions can effect multiple goals
Drink Coffee Hunger – 1 Energy – 1
Eat at Restaurant
Hunger – 4 Fun – 3
Gook Gourmet Meal
Hunger – 5 Fun – 1Energy + 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 0 2 0 3
Energy 2 3 1 2 0
Fun 4 3 4 1 4
Total effect 6 7 3 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 0 3
Energy 10 10 5
Fun 3 0 3
Total effect 10 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 3 02 32
Total effect 100 43
Planning and Preconditions
• Actions may have preconditions before they can be taken
• Multiple actions required to meet needs
ActionPreconditions Postconditions
ActionPreconditions which character meets
Postconditions
ActionPreconditions Postconditionsmeet need
meets
Planning and Preconditions
• Example: Microwaving food
Get foodUncooked food in fridge
Have uncooked food
Cook food in microwave
Have uncooked foodHave microwave
Have cooked food
meets
Eat foodHave cooked food
Hunger - 5
meets
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 foodCook food in microwave
Eat food
Have uncooked foodHave microwave
Hungry - 5