Lecture 3
                  Dead Reckoning
                         and
               Local Perception Filter
                             25 January 2010


Saturday, January 23, 2010                     1
states

                      Simulate             Collect Events
                                  events
                       Game
                                                            Game
                             or                             States

                         Game                 Render
                         States

                                               Wait




Saturday, January 23, 2010                                           2
What if a state changes continuously (i.e., is a
                     function of time) ?


                             Player A


                             Server


                             Player B



Saturday, January 23, 2010                                              3
Consider position updates of players. Players
                     send move command. Server replies with
                     positions periodically.


                             Player A


                             Server


                             Player B



Saturday, January 23, 2010                                           4
Two issues:

                             1. Message overhead
                             2. Delay jitter



Saturday, January 23, 2010                         5
Delay jitter causes player’s movement to appear
                  erratic.




                                                            Player A



                                                            Server
                                               time


Saturday, January 23, 2010                                             6
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
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
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
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
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
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
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
idea: trade-off message
                             overhead and accuracy.
                             No need to update if error
                             is small.



Saturday, January 23, 2010                                14
Player A
                                error threshold

                                         Server


                             time
Saturday, January 23, 2010                          15
Player A



                                    Server


                             time
Saturday, January 23, 2010                     16
Player A



                                    Server


                             time
Saturday, January 23, 2010                     17
predicted position at A

                             A’s predicted position at the server



                                                                    Player A



                                                                    Server


                                                       time
Saturday, January 23, 2010                                                     18
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
A converges the entity to the correct
                                     position smoothly.




                                                                 Player A



                                                                 Server


                                                     time
Saturday, January 23, 2010                                                  20
how to set error
                               threshold?



Saturday, January 23, 2010                      21
adapt based on game
                                 requirement
                             (e.g. distance to other players)




Saturday, January 23, 2010                                      22
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
What is the difference between
                   the actual and predicted
                   position ?

                   How long does the difference
                   last?

Saturday, January 23, 2010                          24
error




                                                   time


                                 inconsistency =

Saturday, January 23, 2010                                25
what are the different components of distance
             error?



                                                       Player A



                                                       Server


                                           time
Saturday, January 23, 2010                                        26
Any drawbacks?



Saturday, January 23, 2010                    27
higher CPU cost
                             (needs to simulate other players)

                                         unfair
                   (higher latency leads to larger error)



Saturday, January 23, 2010                                       28
Dead Reckoning



Saturday, January 23, 2010                    29
Generalized Dead Reckoning :
            Prediction Contract



Saturday, January 23, 2010              30
“return to base”
                             “drive along this road”



Saturday, January 23, 2010                             31
Server and clients must have a
                     common notion of “time”




Saturday, January 23, 2010                          32
Two choices:

                              Wall Clock
                              Game Clock



Saturday, January 23, 2010                  33
Wall Clock: clients and
                             server have to synchronize
                             their physical clocks using
                             NTP or SNTP.



Saturday, January 23, 2010                                 34
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
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
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
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
what A sees
                                                       what B sees




                                           A   S   B
                                           3   4   2        game clock

Saturday, January 23, 2010                                               39
Example: using game clock




Saturday, January 23, 2010                               40
A decides to move. Send event to S.




            A            S    B
            1            2    0


Saturday, January 23, 2010                                         41
S receives event, moves A, and
                             tells A and B that A is moving at t = 3




            A            S    B    A    S   B
            1            2     0    2   3    1


Saturday, January 23, 2010                                             42
A moves itself at t = 3.




            A            S   B   A   S   B    A   S    B
            1            2   0   2   3   1    3   4    2


Saturday, January 23, 2010                                  43
B moves A at t = 3.




            A            S   B   A    S    B   A    S      B   A   S   B
            1            2   0   2     3   1   3    4      2   4   5   3


Saturday, January 23, 2010                                                 44
Example: using wallclock




Saturday, January 23, 2010                              45
A decides to move. Send event to S.




            A            S    B
            0            0    0


Saturday, January 23, 2010                                         46
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
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
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
Tight synchronization allows
                   interaction but can lead to
                   visual disruptions.



Saturday, January 23, 2010                        50
Asynchronization allows
                   smooth movement but hinder
                   interaction.



Saturday, January 23, 2010                      51
Local Perception Filter



Saturday, January 23, 2010                    52
Hybrid Model:
                 Render objects within real-
                  time interaction range in
                 real time, other objects in
                        delayed time.

Saturday, January 23, 2010                     53
Two Kinds of Entities
                    Active:
                    	

 	

 players (unpredictable)
                    Passive:
                    	

 	

 ball, bullet (predictable)

Saturday, January 23, 2010                               54
happening
                               now

                             A



                                             happened
                                         B   time t ago




Saturday, January 23, 2010                                55
Question:
                 What if a player A throws a
                     ball at player B?


Saturday, January 23, 2010                     56
happening
                               now

                             A



                                             happened
                                         B   time t ago




Saturday, January 23, 2010                                57
Question:
                 What if a player B throws a
                     ball at player A?


Saturday, January 23, 2010                     58
happening
                               now

                             A



                                             happened
                                         B   time t ago




Saturday, January 23, 2010                                59
Distance of ball (thrown by A) from A versus time.
          distance                          now       time t ago




                         time t ago
                         now




                                                            time

Saturday, January 23, 2010                                         60
What A sees..
          distance




                         time t ago
                         now




                                                      time

Saturday, January 23, 2010                                   61
Distance of ball (thrown by B) from A versus time.
          distance




                         time t ago
                         now


                                                   time t ago
                                        now                 time

Saturday, January 23, 2010                                         62
Distance of ball (thrown by B) from A versus time.
          distance




                         time t ago
                         now




                                                            time

Saturday, January 23, 2010                                         63
A       happened t ago
                                     happened t - 1 ago
                                     happened t - 2 ago


                                 B




Saturday, January 23, 2010                                64
Question:
                 What if a player A throws a
                     ball at player B?


Saturday, January 23, 2010                     65
What A sees..
          distance




                                             time

Saturday, January 23, 2010                          66
What A sees..
          distance




                                             time

Saturday, January 23, 2010                          67
Question:
                 What if a player B throws a
                     ball at player A?


Saturday, January 23, 2010                     68
Distance of ball (thrown by B) from A versus time.
          distance




                                                            time

Saturday, January 23, 2010                                         69
Saturday, January 23, 2010   70
time




Saturday, January 23, 2010          71
3 slots ago


                                    2 slots ago


                                    1 slots ago


                                     now


                             time




Saturday, January 23, 2010                        72
Assignment 1




Saturday, January 23, 2010                  73
Saturday, January 23, 2010   74
Assignment 1




Saturday, January 23, 2010                  75

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 astate changes continuously (i.e., is a function of time) ? Player A Server Player B Saturday, January 23, 2010 3
  • 4.
    Consider position updatesof 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 causesplayer’s movement to appear erratic. Player A Server time Saturday, January 23, 2010 6
  • 7.
    Recall: Short circuitingis 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 velocityremains 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 overthe 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 maychange (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 stillneed 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 atA A’s predicted position at the server Player A Server time Saturday, January 23, 2010 18
  • 19.
    A’s version ofthe 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 theentity to the correct position smoothly. Player A Server time Saturday, January 23, 2010 20
  • 21.
    how to seterror threshold? Saturday, January 23, 2010 21
  • 22.
    adapt based ongame requirement (e.g. distance to other players) Saturday, January 23, 2010 22
  • 23.
    Space inconsistency: dueto 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 thedifference 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 thedifferent components of distance error? Player A Server time Saturday, January 23, 2010 26
  • 27.
  • 28.
    higher CPU cost (needs to simulate other players) unfair (higher latency leads to larger error) Saturday, January 23, 2010 28
  • 29.
  • 30.
    Generalized Dead Reckoning: Prediction Contract Saturday, January 23, 2010 30
  • 31.
    “return to base” “drive along this road” Saturday, January 23, 2010 31
  • 32.
    Server and clientsmust 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: clientsand 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 tosync 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 statesto 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
  • 40.
    Example: using gameclock Saturday, January 23, 2010 40
  • 41.
    A decides tomove. Send event to S. A S B 1 2 0 Saturday, January 23, 2010 41
  • 42.
    S receives event,moves A, and tells A and B that A is moving at t = 3 A S B A S B 1 2 0 2 3 1 Saturday, January 23, 2010 42
  • 43.
    A moves itselfat t = 3. A S B A S B A S B 1 2 0 2 3 1 3 4 2 Saturday, January 23, 2010 43
  • 44.
    B moves Aat t = 3. A S B A S B A S B A S B 1 2 0 2 3 1 3 4 2 4 5 3 Saturday, January 23, 2010 44
  • 45.
  • 46.
    A decides tomove. 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 itselfto 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 outA 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
  • 50.
    Tight synchronization allows interaction but can lead to visual disruptions. Saturday, January 23, 2010 50
  • 51.
    Asynchronization allows smooth movement but hinder interaction. Saturday, January 23, 2010 51
  • 52.
  • 53.
    Hybrid Model: Render objects within real- time interaction range in real time, other objects in delayed time. Saturday, January 23, 2010 53
  • 54.
    Two Kinds ofEntities Active: players (unpredictable) Passive: ball, bullet (predictable) Saturday, January 23, 2010 54
  • 55.
    happening now A happened B time t ago Saturday, January 23, 2010 55
  • 56.
    Question: What if a player A throws a ball at player B? Saturday, January 23, 2010 56
  • 57.
    happening now A happened B time t ago Saturday, January 23, 2010 57
  • 58.
    Question: What if a player B throws a ball at player A? Saturday, January 23, 2010 58
  • 59.
    happening now A happened B time t ago Saturday, January 23, 2010 59
  • 60.
    Distance of ball(thrown by A) from A versus time. distance now time t ago time t ago now time Saturday, January 23, 2010 60
  • 61.
    What A sees.. distance time t ago now time Saturday, January 23, 2010 61
  • 62.
    Distance of ball(thrown by B) from A versus time. distance time t ago now time t ago now time Saturday, January 23, 2010 62
  • 63.
    Distance of ball(thrown by B) from A versus time. distance time t ago now time Saturday, January 23, 2010 63
  • 64.
    A happened t ago happened t - 1 ago happened t - 2 ago B Saturday, January 23, 2010 64
  • 65.
    Question: What if a player A throws a ball at player B? Saturday, January 23, 2010 65
  • 66.
    What A sees.. distance time Saturday, January 23, 2010 66
  • 67.
    What A sees.. distance time Saturday, January 23, 2010 67
  • 68.
    Question: What if a player B throws a ball at player A? Saturday, January 23, 2010 68
  • 69.
    Distance of ball(thrown by B) from A versus time. distance time Saturday, January 23, 2010 69
  • 70.
  • 71.
  • 72.
    3 slots ago 2 slots ago 1 slots ago now time Saturday, January 23, 2010 72
  • 73.
  • 74.
  • 75.