Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dead reckoning in Sports and Strategy Games Ushhan D. Gundevia November 8, 2004.

Similar presentations


Presentation on theme: "Dead reckoning in Sports and Strategy Games Ushhan D. Gundevia November 8, 2004."— Presentation transcript:

1 Dead reckoning in Sports and Strategy Games Ushhan D. Gundevia November 8, 2004

2 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 francoislaramee@videotron.ca

3 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 http://www.gignews.com/fdlcharacterdesign.htm The Developer's Life  http://www.gignews.com/devlife/ http://www.gignews.com/devlife/ Chess Programming Part I – VI  http://www.gamedev.net/reference/list.asp?categoryid=18 http://www.gamedev.net/reference/list.asp?categoryid=18

4 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 latency  Predicting Goals of the Human Player

5 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

6 Equations for DR Based on the properties of motion, an article can be tracked with the help of  Inertia  Pseudo-Brownian Motion  Kinematics

7 Inertia Everyone remember Newton’s First Law of motion P x = P x0 + v x t P y = P y0 + v y tIn 3D P z = P z0 + v z t 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.

8 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

9 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)

10 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

11 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 curve  P = P 0 + v 0 t + 0.5at 2

12 DR in Sports Games We apply DR in two situations  AI is trying to shoot pass a human obstacle  AI is trying to pass to a human player

13 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.

14 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

15 DR in Online Games DR can be used to mitigate effects of network latency  Each player broadcasts a packets containing is location, velocity and acceleration  During intervals between packets, the AI uses DR  When a new packet arrives, the local world state is updated How often to send a packet will depend on the game’s domain.

16 Defeating Lag With Cubic Splines P t = P 0 + vt P = P 0 + v 0 t + 0.5at 2

17 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

18 Using Cubic Splines Here are the parametric equations used to form the spline.  x = At 3 + Bt 2 + Ct + D  y = Et 3 + Ft 2 + Gt + H t is the time variable. It ranges from 0 at the initial point to 1 at the end point. A = x 3 – 3x 2 +3x 1 – x 0 B = 3x 2 – 6x 1 + 3x 0 C = 3x 1 – 3x 0 D = x 0 E = y 3 – 3y 2 +3y 1 – y 0 F = 3y 2 – 6y 1 + 3y 0 G = 3y 1 – 3y 0 H = y 0

19 Finally

20 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

21 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

22 Demonstration - Targeting Targeting in Real-Time Network Games The reality of network games; what everyone sees

23 Effects of Latency in a Game Latency causes the game to go in different directions for each player

24 Compensating?? Overly compensating for latency makes the game look bad.

25 Targeting The target (the blue thing) has two elements: A position, and a velocity.

26 Pseudo Code for 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; }

27 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

28 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

29 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 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 Animation http://ligwww.epfl.ch/~thalmann/papers.dir/ieeetr_csvt.PDF


Download ppt "Dead reckoning in Sports and Strategy Games Ushhan D. Gundevia November 8, 2004."

Similar presentations


Ads by Google