Title: Artificial Intelligence in Game Design
1Artificial Intelligence in Game Design
- Goal-Oriented Action Planning
2Goals
- Complex characters have goals
- Actions appear motivated instead of reflexive
- Player must be aware of character motivations
- Example Napoleon boss NPC
- Capture other cities
- Protect own cities
- Increase gold level
- What if goals conflict?
- Get gold
- Avoid player
???
3Goals and the Sims
- Overall goals for player to meet
- Positive and negative goals
- Transient goals based on physical needs
- Hunger
- Energy
- Fun
- Etc.
Characters automatically choose actions to meet
needs
4Goals and Actions
- Goals have actions than fulfill need
- Key questions Which actions should NPC take to
fulfill which goals?
Hunger Eat snack Cook dinner
Energy Nap in chair Sleep in bed
Fun Go to concert Paint Read
5Insistence 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
6Actions 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
7Choosing Actions
- Simple approach
- Choose goal with highest insistence
- Choose action that gives largest decrease
Need Insistence
Hunger 6
Energy 0
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
8Side Effects
- Actions can effect multiple goals
Drink Coffee Hunger 1 Energy 1
Eat at Restaurant Hunger 4 Fun 3
Cook Gourmet Meal Hunger 5 Fun 1 Energy 1
Side effect Fulfilling one goal increases other
needs
9Overall 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
10Overall 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!
11Overall Squared Utility
- Common solutionTotal 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
12Planning
- Creating series of actions to meet some goal
- Planning actions to meet multiple needs
- Chosen so final state has highest utility
- Intermediate states after part of sequence should
not be unacceptable - Allows fast actions to be chosen in logical
circumstances - Planning actions with multiple steps before
payoff - Purchase ingredients
- Cook ingredients in oven
- Eat meal
- No effect on hunger until after last step
13Planning Example
Action Effect on Fun Effect on Energy
Paint -2 1
Go to Concert -9 3
Nap in Chair 1 -2
Sleep in Bed 5 -10
Need Current level After Paint After Go to Concert After Nap in Chair After Sleep in Bed
Fun 8 62 02 92 132
Energy 6 72 92 42 02
Total effect 100 85 81 107 169
Best action if single action allowed Will be very
tired afterward!
14Planning Example
- Better approach for two large needs
- Take fast action to relieve one
- Then take another action to relieve other
- Example
- Take nap before concert
Need Current level After Nap in Chair Then After Go to Concert
Fun 8 92 02
Energy 6 42 72
Total effect 100 107 49
Better than taking single action
15Planning and Search Trees
- Must try all possible combinations of actions
- Compute total discontentment for each path
- Choose path with lowest total
root
Sleep in Bed
Nap in Chair
Go to Concert
Paint
Paint Paint
Paint Go to Concert
Paint Nap in Chair
Paint Sleep in Bed
Nap in Chair Paint
Nap in Chair Go to Concert
Nap in Chair Nap in Chair
Nap in Chair Sleep in Bed
Go to Concert Paint
Go to Concert Go to Concert
Go to Concert Nap in Chair
Go to Concert Sleep in Bed
Sleep in Bed Paint
Sleep in Bed Go to Concert
Sleep in Bed Nap in Chair
Sleep in Bed Sleep in Bed
16Planning and Search Trees
- an possible paths to test
- Given a possible actions
- Given n possible levels
- Expanding search tree is costly
- Will only be able to test small number of action
combinations (lookahead limit) - Even two actions enough to seem intelligent
- Looks like character thinking ahead
17Planning and Search Trees
- Algorithm depth limited search
- Depth-first search to some fixed limit n
- an leafs in tree, so choose n so this can be
computed in reasonable time - At each leaf, compute discontentment
- Just keep track of best path found so far
- Storage cost n
Best sequence of actions found so far
Current path being tested
18Pruning and Search Trees
- Can cut off search down obviously bad branches
- Branches with intermediate state unacceptably bad
- Can possibly save search time (but no guarantee)
Character dead No path can be better than best
found so far, so no further search
Discontentment 172