Transcript
Page 1: Artificial Intelligence in Game Design Cooperative Movement

Artificial Intelligence in Game Design

Cooperative Movement

Page 2: Artificial Intelligence in Game Design Cooperative Movement

Coordinated Movement

• Steering of individual character based on movement of other characters– Organized movement– Cooperating in pursuit of overall goal

• Moving group in formation– Creating formations

• Implementing plays in sports games

Page 3: Artificial Intelligence in Game Design Cooperative Movement

Fixed Formations

• Line

• Circle

• “V” formation

• Note that all are usually scalable to different group sizes

Page 4: Artificial Intelligence in Game Design Cooperative Movement

Leader-Based Steering

• “Leader” steers towards goal• Followers have slots

– Fixed position relative to leader– Move with leader– Followers seek location of slot

leader

Fixed distance, orientation WRT leader

leader

Leftflank

Rightflank

Rightrear

slots

Seek new slot positions

Page 5: Artificial Intelligence in Game Design Cooperative Movement

Leader-Based Steering

• Problem if leader has to steer around obstacles• Followers will also steer for no good reason! • Need greater degree of independence

leader

Page 6: Artificial Intelligence in Game Design Cooperative Movement

Leader Marker Steering

• “Invisible” leader marker leads formation– All characters have slots relative to leader marker– Leader marker not affected by obstacles

Fixed distance, orientation WRT leader marker

Leader marker

Leftflank

Rightflank

Rightrear

slots

Front

Page 7: Artificial Intelligence in Game Design Cooperative Movement

Leader Marker Steering

• Followers steer around obstacles– Use blending/priorities to determine steering– May have other goals (seek cover, avoid collisions, etc.)

Leader marker

Rightside

Seek slot

Avoid obstacle Seek

cover

Final steering

Avoid collision

Page 8: Artificial Intelligence in Game Design Cooperative Movement

Leader 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

Leftflank

Rightflank

Rightrear

Front

Squad moving slow

Page 11: Artificial Intelligence in Game Design Cooperative Movement

Slot 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

Hand to Hand Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Heavy Weaponry

Page 12: Artificial Intelligence in Game Design Cooperative Movement

Slot 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

Page 13: Artificial Intelligence in Game Design Cooperative Movement

Minimal Cost Slot Assignment

• Goal: Assign slots to maximize score (or minimize “cost”)

Hand to Hand Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Heavy Weaponry

Total score: 8

Hand to Hand Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Heavy Weaponry

Total score: 68

Page 14: Artificial Intelligence in Game Design Cooperative Movement

Minimal 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

second

third

fourth

last

Hand to Hand Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Heavy Weaponry

first

Page 15: Artificial Intelligence in Game Design Cooperative Movement

Dynamic 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

Hand to Hand Weaponry

Empty = - 10

Hand to Hand Weaponry

Empty = -15

Long Distance Weaponry

Empty = - 15Hand to Hand

Weaponry

Empty = - 20

Long Distance Weaponry

Empty = - 5

Heavy Weaponry

Empty = - 50

Page 16: Artificial Intelligence in Game Design Cooperative Movement

Minimal Cost Slot Assignment

• Example:

Hand to Hand Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Empty

Heavy Weaponry

Total score: 54

Hand to Hand Weaponry

Empty

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Heavy Weaponry

Total score: 48

Page 17: Artificial Intelligence in Game Design Cooperative Movement

Minimal 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

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

New attack squad

Hand to Hand Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Hand to Hand Weaponry

Long Distance Weaponry

Empty

Heavy Weaponry

Total score: 46

Page 18: Artificial Intelligence in Game Design Cooperative Movement

Squad 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

Page 19: Artificial Intelligence in Game Design Cooperative Movement

Cover

Cover

CoverCover

Squad Cover Movement

• Can still use formation slots• Based on nearest cover instead of fixed formation

Slot B

Slot D

Slot C

Slot A

Cover

Slot B

Seek

Page 20: Artificial Intelligence in Game Design Cooperative Movement

Squad 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

Page 21: Artificial Intelligence in Game Design Cooperative Movement

Squad Cover Movement

Cover

Cover

Cover

Cover

Cover

Cover

Range of coverage

Cover

Cover

Cover

Cover

Squad center

Page 22: Artificial Intelligence in Game Design Cooperative Movement

State-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

State 1ASteering forthis state

Character AState 2A

Steering forthis state

State 1BSteering forthis state

Character BState 2B

Steering forthis state

Change in character A state

Causes change in character B state

signal

Page 23: Artificial Intelligence in Game Design Cooperative Movement

Play-Based Steering

• Typical in most team sports games– Example: Passing formation

Page 24: Artificial Intelligence in Game Design Cooperative Movement

Play-Based Steering

Arrive atpocket

Quarterback

FollowPath route,Avoid defenders

Receiver

Wander,Avoid

defenders

At route end and open

Wander,Avoid

defenders

Throw:Pursue(football, receiver)

Pursuefootball

Football thrown

Page 25: Artificial Intelligence in Game Design Cooperative Movement

State-Based Implementation

• Character A sets flag in central repository for team in state exit

Reciever3 RunRoute statevoid Exit() { … repository.setFlag( this, “open”, true); …

Who set flag

Flag name, value

Team Repository

Sender Flag Value

Reciever3 open true

… … …

Page 26: Artificial Intelligence in Game Design Cooperative Movement

State-Based Implementation

• Character B checks for flag as input in checkTransitions method to determine whether to change state

QuarterbackWaitForReciever stateint CheckTransitions() { … if (repository.getFlag( Reciever3, “open”)) { return THROW_STATE; } …

Team Repository

Sender Flag Value

Reciever3 open true

… … …

Page 27: Artificial Intelligence in Game Design Cooperative Movement

Handling 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

Page 28: Artificial Intelligence in Game Design Cooperative Movement

Handling Failed States

Arrive atpocket

Quarterback

FollowPath route,Avoid defenders

Receiver

Wander,Avoid

defenders

At route end and open

Wander,Avoid

defenders

Throw:Pursue(football, receiver)

Pursuefootball

Football thrown

Seek goalAvoid defenders3 seconds

Seek defenders


Top Related