dead reckoning in sports and strategy games ushhan d. gundevia november 8, 2004
TRANSCRIPT
François Dominic Laramée
In the Gaming business since 1991
Worked on over 20 Games Editor and Principal Author of
Game Design Perspectives Secrets of the Game Business
Some other interesting articles by him
Advanced Genetic Programming: New Lessons from Biology AI Game Programming Wisdom 2 – Sec. 11.5
A Rule-Based Architecture using Dempster - Shafer Theory Using N-Gram Statistical Models to Predict Player Behavior Genetic Algorithms: Evolving the Perfect Troll
All in AI Game Programming Wisdom Character-Based Game Design
http://www.gignews.com/fdlcharacterdesign.htm The Developer's Life
http://www.gignews.com/devlife/ Chess Programming Part I – VI
http://www.gamedev.net/reference/list.asp?categoryid=18
Dead Reckoning
What is Dead Reckoning?Predicting the motion of an object based on
its previous state Uses in the Gaming Industry –
In Sports Games, AI needs to predict a players position to pass/avoid him
In Online Games, its used to offset latencyPredicting Goals of the Human Player
Origins of DR
Originally developed as a tool for Navigation, e.g. Navigating in Heavy Fog without GPS
It does not take into account the effects of outside forces, which leads to less reliable estimates
Equations for DR
Based on the properties of motion, an article can be tracked with the help of InertiaPseudo-Brownian MotionKinematics
Inertia
Everyone remember Newton’s First Law of motion
Px = Px0 + vxt
Py = Py0 + vyt In 3D
Pz = Pz0 + vzt
In situations which are relatively free of outside influence, it works well
Sometimes, may be too well. In these cases we might have to insert evaluation errors.
Pseudo-Brownian Motion
In cases where objects are extremely maneuverable or have many external influences, its impossible to predict its velocity vector over some large interval
Hence, from an observers point of view, they appear exhibiting Random Brownian Motion
What to do then?
The best that can be done is to compute the average displacement among a number of such particles.
In case of objects that are very maneuverable, the best we can do is to calculate a radius of a spherical region in space in which it could have moved
In case of a floating mine, we can assume the radius to be a lot less (half or even its root)
Kinematics
If an objects initial velocity ‘u’ is unknown Plot a curve of its position for an arbitrary
interval, and compute speed as its first Derivative
To add an estimate of acceleration, add the acceleration vector
How to add Acceleration?
For free falling objects, its gravity For a human, it can be calculated by the
buttons he presses For everything else, it’s the second
derivative of the curveP = P0 + v0t + 0.5at2
DR in Sports Games
We apply DR in two situationsAI is trying to shoot pass a human obstacleAI is trying to pass to a human player
DR in Military Stimulations
Examples – In WWII scenario, the human flies a
reconnaissance aircraft over an enemy fleet/army. The bombing raid can be planned with the help of DR
In contemporary warfare, DR can assist in missile tracking and firing counter measures
In Submarine simulations, DR can be used to avoid floating mines which are not always visible through RADAR.
Example of a Paradoxical Situation
Both cars are going head-to-head while passing the line Due to delay, counter player position arrives late, position of
opponent’s car is out-of-date
Both players believe that they are the winner
DR in Online Games
DR can be used to mitigate effects of network latencyEach player broadcasts a packets containing
is location, velocity and accelerationDuring intervals between packets, the AI uses
DRWhen a new packet arrives, the local world
state is updated How often to send a packet will depend on
the game’s domain.
Using Cubic Splines
Using cubic splines to create a path is a matter of simple algebraic equations. The input for these equations are four (x,y) coordinates. Coordinate 1 = Starting position Coordinate 2 = Position after 1 second using starting
velocity = Coordinate1 + StartVelocity
Coordinate 3 = Position after 1 second using reversed ending velocity
= Coordinate4 – EndVelocity Coordinate 4 = Ending position
Using Cubic Splines Here are the parametric equations used to form
the spline. x = At3 + Bt2 + Ct + D y = Et3 + Ft2 + Gt + H
t is the time variable. It ranges from 0 at the initial point to 1 at the end point.
A = x3 – 3x2 +3x1 – x0
B = 3x2 – 6x1 + 3x0
C = 3x1 – 3x0
D = x0
E = y3 – 3y2 +3y1 – y0
F = 3y2 – 6y1 + 3y0
G = 3y1 – 3y0
H = y0
Inferring Goals
In cases when the world is not fully accessible, the AI can use DR to predict the Human Player’s future goals and decide its interception strategy
Correcting Errors in DR
The estimate provided by DR can become unbounded over time
A constant bound might be possible by using a Priori map (evidence grid)The Agent computing its own position
maintains a local short map of its surroundings
This short term map is compared with the priory map using PR techniques
Small, incremental corrections are applied to the agents trajectory
Demonstration - Targeting
Targeting in Real-Time Network Games
The reality of network games; what everyone sees
Pseudo Codefor each frame {
target.x_velocity = target.x_velocity + target.x_acceleration;
target.y_velocity = target.y_velocity + target.y_acceleration;
target.z_velocity = target.z_velocity + target.z_acceleration;
target.x_position = target.x_position + target.x_velocity; target.y_position = target.y_position + target.y_velocity; target.z_position = target.z_position + target.z_velocity; laser.x = (laser.x + target.x_position) / 2; laser.y = (laser.y + target.y_position) / 2; laser.z = (laser.z + target.z_position) / 2; }
Final Effect
The server and other clients can calculate where the laser is on your screen (the target), but rather than just placing it there, it makes the laser quickly converge to that target.
This makes the game run more smoothly for everybody
Conclusion
DR is an easy way to predict trajectories of objects
The calculations are based on the information readily available and hence there is no inherent “cheating”
Its execution time is linear wrt the no. of objects being tracked
References Dead Reckoning in Sports and Strategy Games – AI
Game Programming Wisdom 2 Targeting - A variation of Dead Reckoning - Chris Haag
http://www.gamedev.net/reference/articles/article1370.asp
Defeating Lag With Cubic Splines - Nick Caldwell http://www.gamedev.net/reference/articles/article914.asp
Suitability of Dead Reckoning Schemes for Games
http://netmedia.kjist.ac.kr/courses/dic1623-2002fa/reports/Sehchan-Case%20(Networked%20Game2).ppt#1
A Dead-Reckoning Technique for Streaming Virtual Human Animationhttp://ligwww.epfl.ch/~thalmann/papers.dir/ieeetr_csvt.PDF