Title: Artificial Intelligence in Game Design
1Artificial Intelligence in Game Design
2Coordinated Movement
- Steering of individual character based on
movement of other characters - Organized movment
- Cooperating in pursuit of overall goal
- Moving group in formation
- Creating formations
- Implementing plays in sports games
3Fixed Formations
- Line
- Circle
- V formation
- Note that all are usually scalable to different
group sizes
4Leader-Based Steering
- Leader steers towards goal
- Followers have slots
- Fixed position relative to leader
- Move with leader
- Followers seek location of slot
slots
Rightrear
Rightflank
leader
leader
Leftflank
Seek new slot positions
Fixed distance, orientation WRT leader
5Leader-Based Steering
- Problem if leader has to steer around obstacles
- Followers will also steer for no good reason!
- Need greater degree of independence
leader
6Leader Marker Steering
- Invisible leader marker leads formation
- All characters have slots relative to leader
marker - Leader marker not affected by obstacles
slots
Rightrear
Rightflank
Front
Leader marker
Leftflank
Fixed distance, orientation WRT leader marker
7Leader Marker Steering
- Followers steer around obstacles
- Use blending/priorities to determine steering
- May have other goals (seek cover, avoid
collisions, etc.)
Seek slot
Rightside
Leader marker
Avoid obstacle
Final steering
Seek cover
Avoid collision
8Leader Marker Steering
- Problem if many obstacles in squad path
- Leader marker not affected
- Followers are slowed by obstacles
- Followers get far behind leader
- Leader marker should move slow if necessary
- Target velocity of leader Average current
velocity of squad
Rightrear
Rightflank
Front
Squad moving slow
Leftflank
9Leader Marker Steering
- Problem if some units slower than others
- Smaller MaxVel, MaxAccel
- Larger units ? slower to steer past
- Target velocity of leader Minimum velocity of
units in squad
Rightflank
Front
Center
Leftflank
10Hierarchical Formations
- Large units usually consist of smaller squads
also in fixed relative locations - Have overall leader marker
- Leader markers of individual squads have slots in
overall unit
Flankers
Infantry
Infantry
Heavy weapons
Overall leader
Flankers
11Slot Assignment
- Different slots in a formation may require
different abilities - Given group of characters, how should those slots
be filled? - Example Heavy weapon escort
group
Long Distance Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Heavy Weaponry
Hand to Hand Weaponry
Long Distance Weaponry
12Slot Assignment
- Different characters have different abilities
- Can represent fit to role numerically
Swords-man Pikeman Axeman Archer Catapult Cannon Grenadier
Hand to Hand 10 10 10 4 0 0 3
Long Distance 0 3 0 10 0 0 7
Heavy Weaponry 0 0 0 0 20 20 3
13Minimal Cost Slot Assignment
- Goal Assign slots to maximize score (or
minimize cost)
Long Distance Weaponry
Long Distance Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Heavy Weaponry
Hand to Hand Weaponry
Heavy Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Long Distance Weaponry
Long Distance Weaponry
Total score 8
Total score 68
14Minimal Cost Slot Assignment
- Not feasible to check all possible assignments
- n characters ? O(n!) possible assignments
- Greedy algorithm
- Start with hardest to assign characters first
- Characters with greatest variance between slot
scores
Long Distance Weaponry
Hand to Hand Weaponry
first
second
Hand to Hand Weaponry
Heavy Weaponry
third
Hand to Hand Weaponry
fourth
Long Distance Weaponry
last
15Dynamic Slot Assignment
- May need to reassign slots dynamically
- Squad members removed
- May need to factor in cost of empty slot
- Can use to put preferences on filled slots
- Without a heavy weapon, no purpose for squad!
- Can use to put preferences on numbers in slots
- Ok to have one hand to hand slot in front, but
not to havenone in front
Long Distance Weaponry Empty - 15
Hand to Hand Weaponry Empty - 20
Hand to Hand Weaponry Empty -15
Heavy Weaponry Empty - 50
Hand to Hand Weaponry Empty - 10
Long Distance Weaponry Empty - 5
16Minimal Cost Slot Assignment
Long Distance Weaponry
Long Distance Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Heavy Weaponry
Hand to Hand Weaponry
Heavy Weaponry
Hand to Hand Weaponry Empty
Hand to Hand Weaponry
Long Distance Weaponry
Long Distance Weaponry Empty
Total score 48
Total score 54
17Minimal Cost Slot Assignment
- If costs too great, may need to change squad type
- Try all squad types of new group size
- Example
Hand to Hand Weaponry
Long Distance Weaponry
Long Distance Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Hand to Hand Weaponry
Heavy Weaponry
Hand to Hand Weaponry
Long Distance Weaponry
Long Distance Weaponry Empty
Hand to Hand Weaponry
New attack squad
Total score 46
18Squad Cover Movement
- Squad moves one at a time
- Rearmost member moves to next cover position
- Rest of squad remains stationary, providing cover
- Squad as a whole must move in desired direction
Desired direction
19Squad Cover Movement
- Can still use formation slots
- Based on nearest cover instead of fixed formation
Cover
Cover
Slot A
Slot B
Cover
Seek
Slot B
Cover
Cover
Slot C
Slot D
20Squad Cover Movement
- Choose squad member furthest from goal
- Choosing next cover point
- In direction of squad goal
- Often done by targeting a squad anchor point in
center of formation - Not used by another member of squad
- Within cover range of rest of squad
- May not necessarily put in front of rest of squad
- Move squad member slot to that cover point
- Squad member will seek that slot
Cover
21Squad Cover Movement
Range of coverage
Cover
Cover
Cover
Cover
Cover
Cover
Cover
Squad center
Cover
Cover
Cover
22State-Based Movement
- Character does not begin movement until signaled
to do so by another character - Direction/type of steering depends on
location/steering of other characters
Change in character A state
State 1A Steering forthis state
State 2A Steering forthis state
Character A
signal
State 1B Steering forthis state
State 2B Steering forthis state
Character B
Causes change in character B state
23Play-Based Steering
- Typical in most team sports games
- Example Passing formation
24Play-Based Steering
Quarterback
Football thrown
Arrive atpocket
Wander,Avoiddefenders
ThrowPursue(football, receiver)
Receiver
FollowPath route,Avoid defenders
Wander,Avoiddefenders
Pursuefootball
At route end and open
25State-Based Implementation
- Character A sets flag in central repository for
team in state exit
Reciever3 RunRoute state void Exit()
repository.setFlag( this, open, true)
Team Repository
Sender Flag Value
Reciever3 open true
Who set flag
Flag name, value
26State-Based Implementation
- Character B checks for flag as input in
checkTransitions method to determine whether to
change state
Quarterback WaitForReciever state int
CheckTransitions() if (repository.getFlag(
Reciever3, open)) return
THROW_STATE
Team Repository
Sender Flag Value
Reciever3 open true
27Handling Failed States
- Example
- Target receiver never open
- Quarterback must eventually take another action
- Choose another receiver
- Scramble
- Need a state timeout to recognize this
- Receiver should recognize and change to
blocking state
28Handling Failed States
Seek goal Avoid defenders
3 seconds
Quarterback
Football thrown
Arrive atpocket
Wander,Avoiddefenders
ThrowPursue(football, receiver)
Receiver
Seek defenders
FollowPath route,Avoid defenders
Wander,Avoiddefenders
Pursuefootball
At route end and open