Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

29
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors

Transcript of Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Page 1: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Artificial Intelligence in Game Design

Complex Steering Behaviors and Combining Behaviors

Page 2: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Path Following

• Examples:– Move from one location to another along known route– Patrol area cyclically– Implementation of high-level path planning

• Go to door of bookstore

• Go down hall

• Go into PC room

Path following moves character along these steps

Page 3: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Path Following

• Note that will never follow path perfectly– Like arrive, can’t ever

reach an exact location– More realistic to move in

smooth curves – More realistic if don’t

follow exact path every time (patrolling) Desired

path

Actual path

Page 6: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Wall Avoidance

• Goal: keep character some avoidDistance from walls– Usually based on “bounding sphere” of object

• Most graphical objects represented this way

avoidDistance

Page 7: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Wall Avoidance

• Project path of character to some lookahead away– lookahead > minimum distance required for stop at

maxAccel when traveling at maxSpeed– Projection can use same algorithms that graphics use for

ray casting

• If wall within lookahead, steer away

lookahead

Page 8: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Wall Avoidance

• Determine collision point• Project to point perpendicular to wall safeDistance away• Seek that location

avoidDistance

Collision point

Seek this point

Page 9: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Wall Avoidance

• May still collide with wall• Algorithm will keep steering until parallel to wall

New collision point

Seek this new point

Page 10: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Wall Avoidance

• Corners can be problem if not detected by ray trace– Very common problem in robotics

• One solution: “whiskers”Project three lines from character

No collision detected

collision detected

Steer away

Page 11: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Collision Avoidance

• Goal: avoid collisions with other characters who are also in motion– Is collision going to occur?– If so, how should we steer?

• Location of closest approach– Not where paths intersect

Page 12: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Collision Avoidance

• If distance less than some safeRadius at that pointFlee that point

• If already in collision with object, just Flee its current location

safeRadius

Collision detected

Flee where obstacle will be at that point

safeRadius

In collision

Flee

Page 13: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Collision Avoidance

• Much more difficult if multiple obstacles– Determine time to collision of all– Flee from location of first collision– No perfect solution to problem

No collision First collision

Later collision

Page 14: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Collision Avoidance

• Expensive to compute if many obstacles– C characters checking for collisions with each other C2

checks

• One solution: only check characters within some search radius

Page 15: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Jumping

• NPC jumping over obstacles key to many games– Run towards obstacle to achieve needed speed

– Jump over obstacle

– Land on other side

• Must be convincing– Speed, launch point must

look realistic– Character should not jump

unless can succeed(unless player interrupts)

Going too slow for realistic jump

Jump fails

Page 17: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Jumping

• “Starting radius” for run up based on maxSpeed, maxAccel– Outside radius Seek jump point– Inside radius Arrive point outside radius

Seek jump point

Jump point

Landing pad

Page 19: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Blended Steering Behaviors

• Weighted sum of steering from different rules– Weights = relative importance of action– Can depend on “strength of stimulus (distance, etc.)

• Example:– Flee player with weight 0.5/distance from player– Arrive gold with weight 1/distance from gold– Steering = sum of these

$$

$

$$

Page 20: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Blended Steering Behaviors

• Can result in “intelligent” path choices

$$

$

$$

Page 21: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Blended Steering Behaviors

• Flocking– Seek “center of gravity” of flock– Align with average direction– Avoid direct collisions

Center of gravity

Avoid collisionAverage direction

Page 22: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Blended Steering Behaviors

• Blending conflicting behaviors can give results that meet no goals

pursue

Wall avoid

result

seek

flee

Stimuli perfectly balanced – no motion at all!

Page 23: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Prioritized Steering Behaviors

• Choose most important goal and execute its steering completely

• Often proximity based– Within safeRadius of wall execute WallAvoid behavior– Within attackRadius of player execute Seek behavior

Pursuenot considered

Wall avoid has priority

Page 24: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Prioritized Steering Behaviors

• Can group similar behaviors– Give each unique priority

• Often based on “level of damage” to character if not handled

– If total steering from high-priority group < thresholdtry next highest priority group

• Stimulus for high-priority behavior not strong enough to matter

Avoid obstacles groupAvoid walls to sideAvoid wall on turns

Avoid collisions groupAvoid cars to sideAvoid car in front

Follow path groupSeek next point on path

around track

Page 25: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Prioritized Steering Behaviors

Avoid obstacles groupAvoid walls to sideAvoid wall on turns

Avoid collisions groupAvoid cars to sideAvoid car in front

Follow path groupSeek next point on path

around track

Next path point

Steer away from wall has priority Ignore possible collisions with carsIgnore next point on path

Steering

Page 26: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Prioritized Steering Behaviors

Avoid obstacles groupAvoid walls to sideAvoid wall on turns

Avoid collisions groupAvoid cars to sideAvoid car in front

Follow path groupSeek next point on path

around track

Avoid collision has priority Avoid obstacles steering below thresholdIgnore next point on path

Next path pointCollision detected

Minimal steering from walls

Steering

Page 27: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Prioritized Steering Behaviors

Avoid obstacles groupAvoid walls to sideAvoid wall on turns

Avoid collisions groupAvoid cars to sideAvoid car in front

Follow path groupSeek next point on path

around track

Seek next path point has priority Avoid obstacles steering below thresholdAvoid collisions steering below threshold

Next path point

Minimal steering from walls

Steering

Minimal steering from other cars

Page 28: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Prioritized Steering Behaviors

• Can still get stuck in cycles– Steer for one high-priority behavior

• Far enough away so no longer priority

– Other behavior becomes priority• Steers back toward first problem

flee

fleeFlee enemies

Seek target

seek

Page 29: Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.

Higher Level Control of Steering

• Conflicts best resolved by higher-level reasoning– What is current state?– What overall goal are we attempting to accomplish?

Same room as player

Seek player

Different room as player

Arrive door

Player exits room

Enter room where player is

Arrive doorSeek player