DRIVING AI
1
DRIVING AI 1 Driving AI AI world representation Path finding - - PowerPoint PPT Presentation
DRIVING AI 1 Driving AI AI world representation Path finding AI driving Traffic Navigation Obstacle avoidance World Representation Need some way to keep track of the world from a driving standpoint Roads,
1
standpoint
– Roads, intersections, etc. – Other vehicles and dynamic obstacles
– Navigation
around the static obstacles in the world?
– Cruising
– Maneuvering
– A list of polygons covering all navigable areas – Polygons marked to be road, sidewalk, intersection, etc – Neighbour information in each polygon edge
– Directional – Every lane must have a match in adjacent road segments – Lanes have a list of vehicles currently travelling along it » Useful for querying if a lane is good to enter
– Knows what roads start and end at its edges – Has lanes connecting incoming lanes to outgoing ones – Roads (lanes) can only branch at intersections
– Intersections as nodes and roads as edges
– Two list of nodes “closed set” and “open set” – Heuristic for estimating cost from node to target
– Nodes on the “edge” are the open set, start with only start point in
– Each iteration, take node with lowest combination of actual measured cost from start and estimated cost to target
– Stop when you hit the target
– Good way to implement jumps, shortcuts, roadblocks, etc – Increase cost for nodes that you want to avoid
for correct results
– Vary cost from time to time to implement random behaviour
– Beeline from edge to edge might not look natural, particularly in “real world” scenarios like road and intersections – May want to generate curve of some kind
– Traffic
– Opponents
– When to path-find – How to drive on roads – Obstacle avoidance
– Just slide along road lanes, aiming at lane ends – If lane blocked, try to change it – Slow down gradually when coming to a stop
– If no damage, try to get back on the path – Can be turned into user drivable vehicle – Otherwise, turn into a static or simulating rigid body
– May want traffic AI to have some sort of stop sign / traffic light behaviour at intersections – Stop sign is easiest, just have all cars stop for intersections, keep queue at each intersection – Pick a random lane to exit
does
– AI should steer a virtual gamepad, not modify things directly – Opponents using traffic style cheats will feel strange
– Often based on proximity to player – Usually also depends on game mode
– Often a point to pathfind to
– Destination
adjacent waypoints
– Intercept
player is now, anticipation is better)
– Avoid
make some random choices, fire weapons.
– Chase
engage (ram, fire weapons etc)
– Follow (relatively straight) navigation path
– Like driving, but may need to brake/e-brake and modify turn parameters
– Get around another vehicle
– Need to get back on
problems for Hit & Run
– Not remotely the only solutions to these problems
– Calculated from path finding
– Find closest point on path by checking distance to line segments – Extend forward along path by fixed distances – H&R used two with different distances (second used for cornering)
vector to the “steer to” point to generate turning
– Be mindful of corners (see next slide)
– AI always uses full gas when just driving – H&R used vehicle speed to tune difficulty, could also have speed
– At speed, turning is hard – Tends to overshoot dramatically
– Difference in angle (∆α) between near and far steer to point
– Establish speed limits for various ∆α ranges
– If current velocity is above the threshold, slow down
– Steer to far point instead
– If angle gets to big, try to power-slide
– We took very simple approach to this (you can too)
– Can get away with only handling one – Often when there are several cars there is no good solution anyway – Check if another car is within some volume in front
– If road network allows it
– Otherwise
– To sell the effect try honking the horn and flashing the headlights!
– For some games, you may want opponents to actually manoeuvre a lot off-road
– Full path-finding info for entire world – Lot of work to generate – May be expensive to store
– Find nearest point on road, drive straight towards it – If there is an obstacle, it's all over
– Use point where you left the road instead – Use reverse (and turn harder) – If you hit an obstacle, reverse farther
– Need some sort of graph for path finding – A* is your main tool
– Traffic tricks – High level behaviours (navigation / intercept / etc.) – Driving and cornering