Docstoc

Steering

Document Sample
Steering Powered By Docstoc
					 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
                                 Path following
     • Go down hall              moves character
     • Go into PC room           along these steps
                   Path Following
• Note that will never
  follow path perfectly
   – Like arrive, can’t ever
     reach an exact location
                                          Actual
   – More realistic to move in            path
     smooth curves
   – More realistic if don’t
     follow exact path every
     time (patrolling)              Desired
                                    path
                   Path Following
• Break desired path down into set of points along path
• Seek each point in sequence
   – When “close enough” to point, seek next point
                         Possibly defined as slowRadius
                      Path Following
• Choosing points on path
   – Seek next point fixed distance
     along curve from current target
       • Easy to compute
       • Can miss sharp curves

   – Seek next point at closest
     approach to path at current
     direction
       • Most smooth, precise
         following
       • Complex to compute
       • Can miss major sections of
         complex path
                  Path Following
• Waypoints at important
  path points
   – Chosen manually by level
     designer
   – Most accurate to meet
     goal of path
   – Less automatic

                                   Desired
                                   path
                     Wall Avoidance
 • Goal: keep character some avoidDistance from walls
    – Usually based on “bounding sphere” of object
        • Most graphical objects represented this way



safeDistance
                  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
                 Wall Avoidance
 • Determine collision point
 • Project to point perpendicular to wall safeDistance away
 • Seek that location

                                Collision point
safeDistance




                                Seek this point
                 Wall Avoidance
• May still collide with wall
• Algorithm will keep steering until parallel to wall


                                  New collision point




                                  Seek this
                                  new point
                 Wall Avoidance
• Corners can be problem if not detected by ray trace
   – Very common problem in robotics

                                                            No collision
                                                            detected




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




                                       collision detected
               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
              Collision Avoidance
                                                        safeRadius
• If distance less than some
  safeRadius at that point
  Flee that point
                   Flee where
                   obstacle will be
                   at that point                Collision
                                                detected


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

                                                               Flee
            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



                                             Later collision




            No collision   First collision
            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
                         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                       Going too slow
                                                    for realistic jump
     look realistic
   – Character should not jump
     unless can succeed                                    Jump fails
     (unless player interrupts)
                            Jumping
• Jump points
  – Target for “run up” by NPC
  – Usually have corresponding “landing pad”
     • Large enough so covers all landing points from all of jump point
  – Created by level designer
     • Ideally room designed so jump point looks “natural”




                    Jump                Landing
                    point                 pad
                               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         Landing
                                      point          pad
    Combining Steering Behaviors
• What if multiple steering rules fire?
   – What should resulting steering be?
                                                   $ $
                                                 $    $
                                                    $
                                   Arrive gold




                                                  Flee player


                                             Avoid wall
   – Blending results of rules
   – Prioritizing some rules over others
      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

                                                     $ $
                                                   $    $
                                                      $
      Blended Steering Behaviors
• Can result in “intelligent” path choices




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



                          Average direction
        Avoid collision
                                  Center of gravity
             Blended Steering Behaviors
• Blending conflicting behaviors can give results that meet
  no goals
                                         flee

                                                  Stimuli perfectly
                                                  balanced – no
                                                  motion at all!

              pursue                       seek

                       result

Wall avoid
     Prioritized Steering Behaviors
• Often need to give one steering behavior total control
      • Imminent collision with obstacle  avoid
      • About to be caught by predator  flee
   – Bad idea to blend with other behaviors
      • Example: wall avoid steering will only be half of total output
      • Will only brake at half maximum speed




     Wall avoid



                                                pursue
    Prioritized Steering Behaviors
• Often proximity based
   – Within safeRadius of wall  execute WallAvoid behavior
   – Within attackRadius of player  execute Seek behavior



     Wall avoid
     has priority



                                     Pursue
                                     not considered
     Prioritized Steering Behaviors
• Can group similar behaviors                  Avoid obstacles group
   – Give each unique priority                   Avoid walls to side
       • Often based on “level of damage”        Avoid wall on turns
         to character if not handled

   – If total steering from high-
                                               Avoid collisions group
     priority group < threshold                  Avoid cars to side
     try next highest priority group              Avoid car in front
       • Stimulus for high-priority behavior
         not strong enough to matter


                                                Follow path group
                                               Seek next point on path
                                                    around track
         Prioritized Steering Behaviors
                                                           Avoid obstacles group
                                                             Avoid walls to side
                                                             Avoid wall on turns

                              Steering




                                                           Avoid collisions group
                                         Next path point
                                                             Avoid cars to side
                                                              Avoid car in front




Steer away from wall has priority
Ignore possible collisions with cars
Ignore next point on path                                   Follow path group
                                                           Seek next point on path
                                                                around track
                    Prioritized Steering Behaviors
                                                                     Avoid obstacles group
                                                                       Avoid walls to side
                                                                       Avoid wall on turns



Minimal steering
from walls
                                                                     Avoid collisions group
                              Collision detected
                                                   Next path point     Avoid cars to side
                   Steering                                             Avoid car in front



Avoid collision has priority
Avoid obstacles steering below threshold
Ignore next point on path
                                                                      Follow path group
                                                                     Seek next point on path
                                                                          around track
              Prioritized Steering Behaviors
                                                            Avoid obstacles group
                                                              Avoid walls to side
                                                              Avoid wall on turns



Minimal steering
from walls
                              Steering
                                                            Avoid collisions group
                                          Next path point     Avoid cars to side
           Minimal steering                                    Avoid car in front
           from other cars




   Seek next path point has priority
   Avoid obstacles steering below threshold
   Avoid collisions steering below threshold
                                                             Follow path group
                                                            Seek next point on path
                                                                 around track
     Prioritized Steering Behaviors
• Can still get stuck in cycles                         flee enemies
                                                        Flee
   – Steer for one high-priority behavior
       • Far enough away so no longer priority
   – Other behavior becomes priority                    Seek target
       • Steers back toward first problem



                                    flee


                                                 seek
   Higher Level Control of Steering
• Conflicts best resolved by higher-level reasoning
   – What is current state?
   – What overall goal are we attempting to accomplish?

                            Player exits room
   Same room as player                            Different room as player

       Seek player            Enter room                Arrive door
                              where player is




                                         Seek player
                     Arrive door

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:12
posted:2/24/2012
language:
pages:31