Title: Artificial Intelligence in Game Design
1Artificial Intelligence in Game Design
- Influence Maps and Decision Making
2Decision Making
- How can influences determine path character
follows? - How can influences determine high level decisions
made by character? - How can goals of player affect influences?
3Simple Tile-Based Movement
- Use influence map directly to determine next tile
- Treasure has positive influence
- Snakes have negative influence
- Move to adjacent tile with highest measure
3 4 5 6 7 7 7 7 7 7
3 4 5 6 7 8 8 8 8 8
3 2 3 4 5 7 9 9 9 8
3 2 1 2 3 7 9 9 8
3 2 1 1 5 7 7 9 8
3 2 1 -2 -1 2 4 6 8 8
2 3 2 2 3 5 7 7
3 4 5 4 2 2 2 4 6 6
3 4 5 3 1 1 1 3 5 5
3 4 4 4 4 4 4 4 4 4
3 4 5 6 7 7 7 7 7 7
3 4 5 6 7 8 8 8 8 8
3 4 5 6 7 8 9 9 9 8
3 4 5 6 7 8 9 9 8
3 4 5 6 7 8 9 9 9 8
3 4 5 6 7 8 8 8 8 8
4 5 6 7 7 7 7 7 7
3 4 5 6 6 6 6 6 6 6
3 4 5 5 5 5 5 5 5 5
3 4 4 4 4 4 4 4 4 4
4Simple Tile-Based Movement
- Vulnerable to local maxima if influences interact
in complex ways - Locations on map where each possible move is
worse than current position - Will become stuck and cycle forever in area
- Requires careful design or heuristics to avoid
- Dont return to previous location, etc.
1 2 3 4 5 6 7 8 9
1 2 1 2 3 6 7 8 9 9
1 0 -1 0 1 4 7 8 8 8
1 0 -1 1 4 7 7 7 7
1 0 -1 -1 0 2 4 6 6 6
1 2 1 0 0 1 1 3 5 5
1 2 3 2 0 0 2 4 4
-1 0 1 1 -1 -1 -1 1 3 3
-3 -2 0 0 0 0 0 0 2 2
-3 -1 1 1 1 1 1 1 1
5Edge Costs
- Use influence map to estimate edge costs in graph
- Based on influences instead of computed from
graph - Other units
- Terrain costs
- Positive number ? low cost to move through
- Negative number ? high cost to move through
- Average influences of start, end point to get
path costs - Assumption half of path is through each area
Average influence 3
Influence 1
Influence 5
6Edge Costs
- Must normalize to get actual edge costs
- Reverse sign
- High influence low edge cost
- Low influence high edge cost
- Must avoid negative edge costs!
- Dijkstra, A will not work if edge costs negative
- Can factor in other costs
- Multiply by distance, etc.
- Simple example edgeCost(i, j)
maximumInfluence averageInfluence(i, j)
Influence 1
Influence 5
maximumInfluence 7 edgeCost 4
7Edge Cost Example
2.5
3.25
5.25
7.75
9.5
1.75
2.5
4.5
7
9.5
10
4.5 4.5 3 0.5 -2 -3
6 4.5 2 -0.5 -3 -3
4.5 4.5 2 -1.5 -3 -3
3 3 2 -0.5 -3 -2
1.75
3.75
6.25
8.75
10
5
8
10
1.75
2.5
10
2.5
3.75
6.75
9.25
10
5
8
3.25
9.5
9.5
3.25
4
4.5
6.25
8.75
9.5
maximumInfluence 7
8Edge Cost Example
Shortest path from A to B
A
2.5
3.25
5.25
7.75
9.5
1.75
2.5
4.5
7
9.5
10
4.5 4.5 3 0.5 -2 -3
6 4.5 2 -0.5 -3 -3
4.5 4.5 2 -1.5 -3 -3
3 3 2 -0.5 -3 -2
A
1.75
3.75
6.25
8.75
10
5
8
10
1.75
2.5
10
2.5
3.75
6.75
9.25
10
5
8
3.25
9.5
9.5
3.25
B
4
4.5
6.25
8.75
9.5
B
9Edge Costs
- Only works for adjacent areas
- Edges between non-adjacent areas might go through
other areas with very different influences
Safe waypoint
Path between them not safe
Safe waypoint
10Edge Costs
- Terrain analysis
- Determine total terrain influence at each tile
- Determine which tiles an edge passes through
- If influence level at a tile significantly
different than at vertices, add a new waypoint
Medium influence
Low measure due to influence of other tile
New waypoint
Path between them not safe Should have a waypoint
here!
Medium influence
11Group Movement
- Edge cost of group of characters based on
individual costs
What is cost of this edge for unit as a whole?
Long Distance Weaponry
Hand to Hand Weaponry
5
Hand to Hand Weaponry
Heavy Weaponry
4
Hand to Hand Weaponry
7
Long Distance Weaponry
6
4
2
12Group Movement
- Possible solutions
- Edge cost of group maximum(individual costs)
- Must do this if cost based on speed over some
terrain - Edge cost of group average(individual costs)
- May do if willing to lose team members to reach
goal quickly - Edge cost of group cost of most critical unit
- Group fails if this unit is lost
- Particularly important if that unithas high cost
5
6
3
6
4
5
5
3
6
4.4
5
3
5
4
3
5
6
5
3
13Decision Making
- Higher-level character actions may be based on
terrain influences
Is there a tile within distance d that has
significant influence over player position?
See player?
yes
no
Wander
Cover nearby?
no
yes
Attack
Run towardscover
Move to tile in range d with highest influence
14Example Master of Orion
- AI selects planets to colonize based on
- Economic value of planets
- Proximity to current borders
- Proximity to borders of other players
- Star in current territory ? all edges from star
connected to colony/another star in territory
15Master of Orion Decision Tree
Already have colony at this star?
yes
no
Another has colony at this star?
Another has colony at this star?
yes
yes
no
no
Star inside ourborders?
Multiplier 1.5
Multiplier 0.8
Multiplier 0.3
yes
no
no
Star insideborders of another?
Multiplier 0.9
Goal Giver each star a multiplier proportional
to influences of our and other player territories
yes
no
Multiplier 0.3
CONTINUE
16Master of Orion Terrain Analysis
- Give other stars multiplier based on how adding
it would change territory - Multiplier 1
- For each new unclaimed star now inside border add
0.25 - For each colony now inside border add 1
- If homeworld now inside border add 1
Colonizing Lupi would put Volans colony inside
border ? multiplier 2
17Master of Orion Decision Making
- Probabilistic decision on planet to colonize
- For each star, generate multiplier and square
- Multiply by economic value of planet to get
weight - Eliminate any with lt 50 of best candidate (avoid
stupid moves) - Choose randomly with probabilities proportional
to weight - Example
A 0.5 B 1.5 C 1.0 D 2.0 E 1.5
0.25 2.25 1.0 4.0 2.25
26 48 26
18Fuzzy Decision Making
- Terrain influences often not binary
- Different objects may have degree of membership
in type of terrain - Example Move to nearby high ground
- What if have several choices?
Mountain 1 Height 400 Distance 80
Mountain 3 Height 500 Distance 100
Mountain 2 Height 200 Distance 50
19Fuzzy Decision Making
- Nearby and high can be fuzzy measures
Nearby
0.9
0.4
0.2
distance
0
20
40
60
80
100
120
1.0
High
0.9
0.3
0
100
200
300
400
500
600
20Fuzzy Decision Making
- Nearby and high min(µ nearby (mountain), µ
high (mountain)) - Choose mountain with highest value
- Mountain 1 min(0.4, 0.9) 0.4
- Mountain 2 min(0.9, 0.3) 0.3
- Mountain 3 min(0.2, 1.0) 0.2
- Many rules include nearby component
- Cover nearby? ? depends on how near and degree of
cover - Attack nearby cities which are no well defended
? depends on how near and degree of
positive/negative influence
Best choice
21Goal-based Terrain
- Understand goals of player
- Areas that player would consider valuable
- Give higher values to areas with influence over
those areas - NPC will try to secure areas of value to the
player - Looks like anticipating player actions
- Prevents players from accomplishing goals
- Looks like trap if NPC units can be hidden
- Can use to manipulate the terrain
- NPC could try to plant goal items (such as
treasure) in areas NPC has control over! - Level design could automatically place goal items
in areas that other areas have influence over
22Goal-based Terrain
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
- Example
- Treasure (with value 4 to player) next to forest
- Forest has influence over open areas next to it
- Areas with influence over the treasure increased
by value of treasure
Best places to be!
-1 -1 -1 -1 -1
-3 -3 -3 -3 -3 -3
3 3 3 7 7 7
1 1 1 1 1 1
23Goal-based Terrain
- Areas with influence over good terrain
- Areas with influence over other high influence
areas
Path with low terrain cost high value to player
Forest area with influence over neighbors
Highest influence areas
B Height 50
Influence over that area more valuable
D Height 30
Area of value to player
C Height 20
24Exploration Goals
- Exploring new areas should be a goal of NPC
- More accurate maps, more accurate influences
- Usually have scouting units for that purpose
- Areas at edge of map should have strong positive
influence - Might be combined with other factors
- Proximity (explore areas already near to)
- Safety (explore areas not under player control)
- Terrain (explore areas can move quickly through)
- Visibility (go to areas where can see much from)
- Mountains, etc.
Visibility area on mountain
Visibility area on ground
25Exploration Goals
Unknown territory
2 4
3 6
2 4
1 4 8 14
1 2 7 12
3 10
3 8
2 6
Views maximum unknown territory
Scouts visibility 2 tiles away