Physics-based Racing AI

Содержание

Слайд 2

Game AI Conference, Paris June 2010

Game AI Conference, Paris June 2010

Слайд 3

Overview Part 1 – Racing AI Tutorial Basics in Steering, Throttle

Overview

Part 1 – Racing AI Tutorial
Basics in Steering, Throttle & Brake

managment
Group behaviours (avoiding, overtakes)
Part 2 – A method for optimizing AI performances
Fairness in racing games
Main alghoritm for an AI optimizator

Game AI Conference, Paris June 2010

Слайд 4

RACING AI TUTORIAL Part 1 Game AI Conference, Paris June 2010

RACING AI TUTORIAL

Part 1

Game AI Conference, Paris June 2010

Слайд 5

AI - Physics interface Input: Steer, Throttle, Brake, ... Position, Direction,

AI - Physics interface

Input: Steer, Throttle, Brake, ...

Position, Direction, Speed, ...

Game

AI Conference, Paris June 2010
Слайд 6

AI - Physics interface Physics as a black box (too much

AI - Physics interface
Physics as a black box (too much complexity

to forecast exactly the results of an action)
Physics changes during the project

Game AI Conference, Paris June 2010

Слайд 7

Racing Line Generated Line Edited Line Game AI Conference, Paris June 2010

Racing Line

Generated Line

Edited Line

Game AI Conference, Paris June 2010

Слайд 8

Representation Segments & Fixed Radius Curves Game AI Conference, Paris June 2010

Representation

Segments & Fixed Radius Curves

Game AI Conference, Paris June 2010

Слайд 9

Representation Splines (hermite) Edit Nodes (pos) Edit Tangents (dir & len)

Representation

Splines (hermite)
Edit Nodes (pos)
Edit Tangents (dir & len)

Game AI Conference, Paris

June 2010
Слайд 10

Sampling the racing line Sample: Position Border Right Distance Border Left

Sampling the racing line

Sample:
Position
Border Right Distance
Border Left Distance

Radius
...

Game AI Conference, Paris June 2010

Слайд 11

Following the racing line Target Basic: Steer = Angle * Factor

Following the racing line

Target

Basic:
Steer = Angle * Factor

Angle

Game AI Conference, Paris

June 2010
Слайд 12

Following the racing line Target Advanced: Steer = Lean which resulting

Following the racing line

Target

Advanced:
Steer = Lean which resulting radius
leads to

the target (given current speed)

Game AI Conference, Paris June 2010

Слайд 13

Throttle and Brake managment 60 m/s 55 m/s 40 m/s 25

Throttle and Brake managment

60 m/s

55 m/s

40 m/s

25 m/s

Game AI Conference, Paris

June 2010
Слайд 14

Throttle and Brake managment Basic implementation: Speed Speed > Speed Target

Throttle and Brake managment

Basic implementation:
Speed < Speed Target ? Throttle =

MAX
Speed > Speed Target ? Brake = MAX
Better implementation uses Throttle and Brake modulation (could model also driver characteristics, like aggressiveness or smoothness in driving)

Game AI Conference, Paris June 2010

Слайд 15

Recovery Mechanics Mechanics that detect a dangerous situation and apply an

Recovery Mechanics

Mechanics that detect a dangerous situation and apply an action

to restore a safer situation
AI that detect too much dritfing uses counter steer (car)
AI that detect a big angle with the target uses a rear brake (bike)
Drawback: loss of performances

Game AI Conference, Paris June 2010

Слайд 16

Avoiding Collision Sphere Game AI Conference, Paris June 2010

Avoiding

Collision Sphere

Game AI Conference, Paris June 2010

Слайд 17

Avoiding 10 secs 50 m/s 40 m/s 3 secs Impact time

Avoiding

10 secs

50 m/s

40 m/s

3 secs

Impact time

Brake to 40 m/s

Game AI Conference,

Paris June 2010
Слайд 18

Overtake Overtake direction 40 m/s 50 m/s Game AI Conference, Paris June 2010

Overtake

Overtake direction

40 m/s

50 m/s

Game AI Conference, Paris June 2010

Слайд 19

Overtake 4 meters Game AI Conference, Paris June 2010

Overtake

4 meters

Game AI Conference, Paris June 2010

Слайд 20

Overtake Adding component to steer (Steer = SteerToTarget + C) Fast

Overtake

Adding component to steer (Steer = SteerToTarget + C)
Fast reaction
Can increase/decrease

dynamically the component
Harder to control distances and deviating speed
Considering more vehicles
Calculating the overall occlusion
Finding the nearest free block

Game AI Conference, Paris June 2010

Слайд 21

Mistakes “Natural” errors Collisions Losing control in overtake/group situations Generated errors

Mistakes

“Natural” errors
Collisions
Losing control in overtake/group situations
Generated errors
Steering, Throttle, Brake
Falls (bike): low

side, high side

Game AI Conference, Paris June 2010

Слайд 22

Car AI Game AI Conference, Paris June 2010

Car AI

Game AI Conference, Paris June 2010

Слайд 23

Bike AI Game AI Conference, Paris June 2010

Bike AI

Game AI Conference, Paris June 2010

Слайд 24

A METHOD FOR OPTIMIZING AI PERFORMANCES Part 2 Game AI Conference, Paris June 2010

A METHOD FOR OPTIMIZING AI PERFORMANCES

Part 2

Game AI Conference, Paris June

2010
Слайд 25

Fairness in racing games Common trick is using simplified (or helped)

Fairness in racing games

Common trick is using simplified (or helped) physics

for Ais
Easier to obtain good performances (and tune)
Easier managing group situations
Visual effect not too realistic
Difficult to maintain a fair situation with the player

Game AI Conference, Paris June 2010

Слайд 26

Fairness in racing games Using (almost) the same player physics Much

Fairness in racing games

Using (almost) the same player physics
Much better under

a visual point of view (realism)
AI can’t do something that player can’t so fairness is guaranteed
Much more difficult to obtain good performances
More difficult also managing group situations
Need a better method than simple speed precalculation

Game AI Conference, Paris June 2010

Слайд 27

Speed precalculation Grip Radius F = m*speed^2/radius MaxSpeed = sqrt(grip*G*radius) Game AI Conference, Paris June 2010

Speed precalculation

Grip

Radius

F = m*speed^2/radius

MaxSpeed = sqrt(grip*G*radius)

Game AI Conference, Paris June 2010

Слайд 28

Speed precalculation 15 m/s (min speed in the turn) 25 m/s

Speed precalculation

15 m/s (min speed in the turn)

25 m/s

40 m/s

Deceleration

23 m/s

35

m/s

Game AI Conference, Paris June 2010

Слайд 29

Speed precalculation You can tweak the precalculation affecting the grip and

Speed precalculation

You can tweak the precalculation affecting the grip and deceleration

values the alghoritm consider (not the real grip and brakes)
Solution would never be optimal (improve in some points but exit from the track in others, or stay into the track but still too slow in some sectors)

Game AI Conference, Paris June 2010

Слайд 30

Dividing into sectors Sector 1 (Grip Mod 1, Dec Mod 1)

Dividing into sectors

Sector 1 (Grip Mod 1, Dec Mod 1)

Sector 2

(Grip Mod 2, Dec Mod 2)

MaxSpeed = sqrt(grip*grip_mod_2*G*radius)

MaxSpeed = sqrt(grip*grip_mod_1*G*radius)

Game AI Conference, Paris June 2010

Слайд 31

Iterative method Detect sectors in an automatic way Start when inverse

Iterative method

Detect sectors in an automatic way
Start when inverse radius !=

0, end when inverse radius returns 0
Make the AI drive (graphics disabled)
Act on grip and deceleration modifier
Define a step
Increase grip modifier for higher speeds
Increase deceleration modifier for more aggressive approach

Game AI Conference, Paris June 2010

Слайд 32

Iterative method Increment modifiers as soon as lap time decrease One

Iterative method

Increment modifiers as soon as lap time decrease
One lap could

not be sufficient (starting conditions). Up to 5 laps for evaluation.
Pass to an other sector when lap time does not decrease any more
First pass on grip modifiers, second pass on decelerations
More iteractions could help (restart the process)

Game AI Conference, Paris June 2010

Слайд 33

Extra conditions Considering only lap time is often not sufficient Need

Extra conditions

Considering only lap time is often not sufficient
Need extra conditions

to be satisfied
Out of track check
Distance from ideal line
Others (skid, wobble, wheelie, …)
Invalidate single lap or the entire trial when a condition is not satisfied

Game AI Conference, Paris June 2010

Слайд 34

Resulting Data Stored as a track asset For each sector: start

Resulting Data

Stored as a track asset
For each sector: start sector info,

end sector info, grip modifier, deceleration modifier
Speeds are calculated at initialization time taking in account generated modifiers
Flexibility in case of ideal line or grip changes

Game AI Conference, Paris June 2010

Слайд 35

Not optimized lap Game AI Conference, Paris June 2010

Not optimized lap

Game AI Conference, Paris June 2010

Слайд 36

Grip modifiers BestTime = 128.11 Grip Modifier 0 = 1.00 BestTime

Grip modifiers

BestTime = 128.11
Grip Modifier 0 = 1.00
BestTime = 127.76
BestTime =

127.45
BestTime = 127.21
BestTime = 127.10
Grip Modifier 1 = 1.40
BestTime = 126.93
BestTime = 126.80
BestTime = 126.70
BestTime = 126.63
Grip Modifier 2 = 1.40
...

Game AI Conference, Paris June 2010

Слайд 37

Deceleration modifiers BestTime = 114.59 Dec Modifier 0 = 1.00 BestTime

Deceleration modifiers

BestTime = 114.59
Dec Modifier 0 = 1.00
BestTime = 114.51
BestTime =

114.38
BestTime = 114.28
BestTime = 114.23
BestTime = 114.19
Dec Modifier 1 = 1.50
BestTime = 114.18
Dec Modifier 2 = 1.10
Dec Modifier 3 = 1.00
Dec Modifier 4 = 1.00
...

Game AI Conference, Paris June 2010

Слайд 38

Optimized lap (no extra conditions) Game AI Conference, Paris June 2010

Optimized lap (no extra conditions)

Game AI Conference, Paris June 2010

Слайд 39

Adding extra conditions Example No out of track Ideal line distance

Adding extra conditions

Example
No out of track
Ideal line distance < 3 meters

(CM of vehicle)

Game AI Conference, Paris June 2010

Слайд 40

Optimized lap (with extra conditions) Game AI Conference, Paris June 2010

Optimized lap (with extra conditions)

Game AI Conference, Paris June 2010

Слайд 41

Advantages Simple implementation Editable results Speeds are still proportional to the

Advantages

Simple implementation
Editable results
Speeds are still proportional to the radius
Can tweak by

affecting the (real) grip (but not too much)

Game AI Conference, Paris June 2010

Слайд 42

Possible improvements Step managment Order optimization Extra conditions Acting not only

Possible improvements

Step managment
Order optimization
Extra conditions
Acting not only on speeds (driving parameters)

Game

AI Conference, Paris June 2010
Слайд 43

Conclusions Fairness is very important Difficult to forecast physics (and track)

Conclusions

Fairness is very important
Difficult to forecast physics (and track)
Trying and see

what happen is a good solution

Game AI Conference, Paris June 2010