"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter
1. Lecture 3
Dead Reckoning
and
Local Perception Filter
25 January 2010
Saturday, January 23, 2010 1
2. states
Simulate Collect Events
events
Game
Game
or States
Game Render
States
Wait
Saturday, January 23, 2010 2
3. What if a state changes continuously (i.e., is a
function of time) ?
Player A
Server
Player B
Saturday, January 23, 2010 3
4. Consider position updates of players. Players
send move command. Server replies with
positions periodically.
Player A
Server
Player B
Saturday, January 23, 2010 4
5. Two issues:
1. Message overhead
2. Delay jitter
Saturday, January 23, 2010 5
6. Delay jitter causes player’s movement to appear
erratic.
Player A
Server
time
Saturday, January 23, 2010 6
7. Recall: Short circuiting is used to predict own
states. We can similarly predict opponent’s
state.
Player A
Server
Player B
Saturday, January 23, 2010 7
8. Suppose the velocity remains constant, then we
can predict every position at all time.
predicted position
Player A
Server
time
Saturday, January 23, 2010 8
9. x[t] position of entity at time t
v velocity of the entity
x[ti ] = x[ti−1 ] + v × (ti − ti−1 )
Saturday, January 23, 2010 9
10. We send over the initial position x[t], t, and
velocity. (Why do we need to send t?)
predicted position
Player A
Server
time
Saturday, January 23, 2010 10
11. But velocity may change (e.g. a car accelerating).
To counter this, we send position, velocity, and
acceleration as update.
Player A
Server
time
Saturday, January 23, 2010 11
12. x[t] position of entity at time t
v velocity of the entity
a acceleration of the entity
1
x[ti ] = x[ti−1 ] + v(ti − ti−1 ) + a(ti − ti−1 )2
2
Saturday, January 23, 2010 12
13. We will still need substantial number of updates
if the direction changes frequently (e.g. in a FPS
game).
B
Player A
Server
time
Saturday, January 23, 2010 13
14. idea: trade-off message
overhead and accuracy.
No need to update if error
is small.
Saturday, January 23, 2010 14
15. Player A
error threshold
Server
time
Saturday, January 23, 2010 15
16. Player A
Server
time
Saturday, January 23, 2010 16
17. Player A
Server
time
Saturday, January 23, 2010 17
18. predicted position at A
A’s predicted position at the server
Player A
Server
time
Saturday, January 23, 2010 18
19. A’s version of the entity’s position is now too far
away from the correct position. Server updates A
with the new velocity and position.
Player A
Server
time
Saturday, January 23, 2010 19
20. A converges the entity to the correct
position smoothly.
Player A
Server
time
Saturday, January 23, 2010 20
21. how to set error
threshold?
Saturday, January 23, 2010 21
22. adapt based on game
requirement
(e.g. distance to other players)
Saturday, January 23, 2010 22
23. Space inconsistency: due to error threshold and
convergence
Time inconsistency: due to message delay and
clock asynchrony
Player A
Server
time
Saturday, January 23, 2010 23
24. What is the difference between
the actual and predicted
position ?
How long does the difference
last?
Saturday, January 23, 2010 24
25. error
time
inconsistency =
Saturday, January 23, 2010 25
26. what are the different components of distance
error?
Player A
Server
time
Saturday, January 23, 2010 26
31. “return to base”
“drive along this road”
Saturday, January 23, 2010 31
32. Server and clients must have a
common notion of “time”
Saturday, January 23, 2010 32
33. Two choices:
Wall Clock
Game Clock
Saturday, January 23, 2010 33
34. Wall Clock: clients and
server have to synchronize
their physical clocks using
NTP or SNTP.
Saturday, January 23, 2010 34
35. now is
10:18:32 now is
10:18:29.5
now is
10:18:30
now is
10:18:33.5
Saturday, January 23, 2010 35
36. now is
10:18:32 now is
10:18:29.5
now is
10:18:30
now is
10:18:33.5
Time now should be
10:18:30.5
RTT = 1s
OWD = 0.5s
Saturday, January 23, 2010 36
37. Players try to sync the game states with the
server at the same wallclock time, and predict
ahead with an amount of time equal to one-
way delay.
Player A
Server
Player B
Saturday, January 23, 2010 37
38. or: synchronize states to game clock, which
runs behind the server by an amount of time
equals to the one-way delay.
Player A
Server
Player B
Saturday, January 23, 2010 38
39. what A sees
what B sees
A S B
3 4 2 game clock
Saturday, January 23, 2010 39
46. A decides to move. Send event to S.
A S B
0 0 0
Saturday, January 23, 2010 46
47. S receives event, moves A, and
tells A and B that A is moving at t = 1
A S B A S B
0 0 0 1 1 1
Saturday, January 23, 2010 47
48. A moves itself to where it should be at t = 2.
A S B A S B A S B
0 0 0 1 1 1 2 2 2
Saturday, January 23, 2010 48
49. B finds out A moves at t = 1 and
moves A to where A should be at t = 3
A S B A S B A S B A S B
0 0 0 1 1 1 2 2 2 3 3 3
Saturday, January 23, 2010 49