CS4344 09/10 Lecture 2: Consistency

94
Lecture 2 Consistency 18 January 2010 1

description

 

Transcript of CS4344 09/10 Lecture 2: Consistency

Page 1: CS4344 09/10 Lecture 2: Consistency

Lecture 2Consistency

18 January 2010

1

Page 2: CS4344 09/10 Lecture 2: Consistency

This Lecture:Client/Server Architecture

2

Page 3: CS4344 09/10 Lecture 2: Consistency

or

Collect Events

Render

Wait

GameStates

events

states

Simulate Game

GameStates

3

Page 4: CS4344 09/10 Lecture 2: Consistency

Three Related Topics:

ConsistencySynchronization Protocol

Event Ordering

4

Page 5: CS4344 09/10 Lecture 2: Consistency

Case 1: no delay. Can take the order in which the events are generated and the order in which the events are received as the consistent order.

Player A

Player B

Server

5

Page 6: CS4344 09/10 Lecture 2: Consistency

Case 2: homogeneous delay. Which order should the server take?

Player A

Player B

Server

6

Page 7: CS4344 09/10 Lecture 2: Consistency

Case 3: heterogeneous delay. Which order should the server take?

Player A

Player B

Server

7

Page 8: CS4344 09/10 Lecture 2: Consistency

Player A

received-order delivery: Server executes the events as they are received.

Player B

Server

8

Page 9: CS4344 09/10 Lecture 2: Consistency

Player A

Players see events in the same order (as long as underlying network deliver messages in order.)

Player B

Server

9

Page 10: CS4344 09/10 Lecture 2: Consistency

Player A

Is it fair to Player B? What if the state is continuous?

Player B

Server

10

Page 11: CS4344 09/10 Lecture 2: Consistency

Suppose Player B aims and shoots at A. When B’s message reaches the server, A already moved away.

Did B hit A?

Player A

Player B

Server?

11

Page 12: CS4344 09/10 Lecture 2: Consistency

Server

Player

BA

12

Page 13: CS4344 09/10 Lecture 2: Consistency

Server

Player

BA

RTT/2 later, server is notified

13

Page 14: CS4344 09/10 Lecture 2: Consistency

Lag Compensationor

Time Warp

14

Page 15: CS4344 09/10 Lecture 2: Consistency

Source Multuplayer Game Engine

15

Page 16: CS4344 09/10 Lecture 2: Consistency

Server estimates the latency between itself and Player B.

Let the latency be t.

16

Page 17: CS4344 09/10 Lecture 2: Consistency

Server “rewinds” to t seconds ago.

17

Page 18: CS4344 09/10 Lecture 2: Consistency

Server(now)

Server(now - t)

18

Page 19: CS4344 09/10 Lecture 2: Consistency

Check if hit or miss.

Play forward to now.

19

Page 21: CS4344 09/10 Lecture 2: Consistency

How to estimate one-way delay?

21

Page 22: CS4344 09/10 Lecture 2: Consistency

Player A

Measure RTT, take RTT/2

Server

RTT

22

Page 23: CS4344 09/10 Lecture 2: Consistency

Server executes in the order of events received, but on the state at the time events are generated (approximately).

Does this always work?

Server

23

Page 24: CS4344 09/10 Lecture 2: Consistency

Player A

In received-order delivery, with/without lag compensation, inconsistency may still arise. Some operation might not be permitted by server.

Player B

Server“oops, can’t execute this anymore”

24

Page 25: CS4344 09/10 Lecture 2: Consistency

or

Collect Events

Render

Wait

GameStates

events

states

Simulate Game

GameStates

Such architecture, where the server makes all the decisions, is called permissible client/server architecture.

25

Page 26: CS4344 09/10 Lecture 2: Consistency

Player A

Problem: decrease responsiveness

Player B

Server

lag

lag

26

Page 27: CS4344 09/10 Lecture 2: Consistency

Player A

Problem: unfair to player with higher latency

Player B

Server

lag

lag

27

Page 28: CS4344 09/10 Lecture 2: Consistency

Player A

Try: improve fairness by adding artificial delay at the server. (longer delay for “closer” player)

What is the drawback of this method?

Player B

Server

lag

lag28

Page 29: CS4344 09/10 Lecture 2: Consistency

Player A

Player B

Server

Try: Short circuiting -- execute action immediately locally.

What is the drawback of this method?

29

Page 30: CS4344 09/10 Lecture 2: Consistency

Player A

Recall: server is the authority and maintains the correct states.

Player B

Server

30

Page 31: CS4344 09/10 Lecture 2: Consistency

Player A

We can fix the inconsistency later using the states from the server.

Player B

Server

31

Page 32: CS4344 09/10 Lecture 2: Consistency

or

Collect Events

Render

Wait

GameStates

events

STATES

Simulate Game

GameStates

Simulate Game

32

Page 33: CS4344 09/10 Lecture 2: Consistency

Player A

Slight delay in response might be OK. Idea: introduce local lag -- wait for some time t before update states.

Player B

Server

33

Page 34: CS4344 09/10 Lecture 2: Consistency

Player A

Effectively we are trading off responsiveness with consistency.

Player B

Server

lag

34

Page 35: CS4344 09/10 Lecture 2: Consistency

Trade-off responsiveness with consistency

Do first, fix later (optimistic)

35

Page 36: CS4344 09/10 Lecture 2: Consistency

How responsive should the game be?

How consistent should the game be?

How to “fix later” ?

36

Page 37: CS4344 09/10 Lecture 2: Consistency

User Studies: Effects of Network on Games

37

Page 38: CS4344 09/10 Lecture 2: Consistency

Goal: How much network latency is

tolerable?

38

Page 39: CS4344 09/10 Lecture 2: Consistency

Method: Analyze game servers log for

Quake III Arena

39

Page 40: CS4344 09/10 Lecture 2: Consistency

Median Ping (ms)

References

Frags/minutes

3

1

50 400

not the actual graph40

Page 41: CS4344 09/10 Lecture 2: Consistency

Yes, latency does affect playability..

41

Page 42: CS4344 09/10 Lecture 2: Consistency

Question: what’s the annoyance threshold?

42

Page 43: CS4344 09/10 Lecture 2: Consistency

Method: User studies using Unreal

Tournament 2003

43

Page 44: CS4344 09/10 Lecture 2: Consistency

Router Server

ClientsAdd delay here

44

Page 45: CS4344 09/10 Lecture 2: Consistency

Game Activity: move and shoot

45

Page 46: CS4344 09/10 Lecture 2: Consistency

Movement Test: Construct obstacle

course

46

Page 47: CS4344 09/10 Lecture 2: Consistency

47

Page 48: CS4344 09/10 Lecture 2: Consistency

Over 200 users

48

Page 49: CS4344 09/10 Lecture 2: Consistency

Induced latency (ms)

References

Time to complete course (s)

50

0 400

not the actual graph49

Page 50: CS4344 09/10 Lecture 2: Consistency

Player A

Perhaps UT 2003 is using short circuiting for movement?

Player B

Server

50

Page 51: CS4344 09/10 Lecture 2: Consistency

Shooting Test: Two players shooting at

each other using precision weapon

51

Page 52: CS4344 09/10 Lecture 2: Consistency

Complementing these extremes are nine more commonly used weapons. These

include the Minigun, capable of firing high volumes of bullets in a very short time, the

Flak Cannon, used to scatter shards of metal in the general vicinity of your opponents,

and the Rocket Launcher, able to load and launch up to three rockets at a time. Along

with the Lightning Gun, UT2003’s version of a sniper rifle, there are many ways for

players to deal with their opponents.

Figure 4: Fully Zoomed Lightning Gun

In addition to the numerous maps, weapons and gameplay modes, UT2003 also

comes standard with two more features: bots and mutators. Bots are computer controlled

players, each with their own personality and play style. Bots are used when playing

UT2003 single player games or they can be used for multiplayer games when not enough

human players are present. When used this way, bots are run on the game server.

Mutators are custom modifications to the game environment that allow unique scenarios

13

52

Page 53: CS4344 09/10 Lecture 2: Consistency

Induced latency (ms)

References

Hit Fraction

0.5

0 300

0.2

not the actual graph53

Page 54: CS4344 09/10 Lecture 2: Consistency

latency as low as 100 ms were noticeable and latencies around

200 ms were annoying ”“

54

Page 55: CS4344 09/10 Lecture 2: Consistency

Read the paper for complete results.

Other conclusion: loss rate up to 5% has no measurable effects.

55

Page 56: CS4344 09/10 Lecture 2: Consistency

How responsive should the game be?

How consistent should the game be?

How to “fix later” ?

56

Page 57: CS4344 09/10 Lecture 2: Consistency

Method: User Studies using Warcraft III

57

Page 58: CS4344 09/10 Lecture 2: Consistency

Game Activity: build, explore, fight!

58

Page 59: CS4344 09/10 Lecture 2: Consistency

Finding: Players with larger delays see exactly

the same events as players with smaller delays, only at

a later time.

59

Page 60: CS4344 09/10 Lecture 2: Consistency

Player A

Player B

Server

Possible communication architecture?

60

Page 61: CS4344 09/10 Lecture 2: Consistency

Finding: Latency of up to 800 ms has negligible effect

on the outcome of Warcraft III.

61

Page 62: CS4344 09/10 Lecture 2: Consistency

Finding: Latency of up to 500 ms can be

compensated by the players

62

Page 63: CS4344 09/10 Lecture 2: Consistency

Finding: Latencies between 500 and 800 ms degrade game experience.

63

Page 64: CS4344 09/10 Lecture 2: Consistency

Finding: Players that micro-manage units in combat feel the latency more than players who

don’t.

64

Page 65: CS4344 09/10 Lecture 2: Consistency

Strategy is more important in RTS games,

not reaction time.

65

Page 66: CS4344 09/10 Lecture 2: Consistency

Q: How responsive and consistent should the game be?

A: Depends on the characteristics of game.

66

Page 67: CS4344 09/10 Lecture 2: Consistency

Important: understand user

requirements

67

Page 68: CS4344 09/10 Lecture 2: Consistency

How responsive should the game be?

How consistent should the game be?

How to “fix later” ?

68

Page 69: CS4344 09/10 Lecture 2: Consistency

Player A

We can fix the inconsistency later using the states from the server.

Player B

Server

69

Page 70: CS4344 09/10 Lecture 2: Consistency

State: positionsEvent: movements

70

Page 71: CS4344 09/10 Lecture 2: Consistency

Unreal Tournament’s lock-step predictor/

corrector algorithm for player’s movement

71

Page 72: CS4344 09/10 Lecture 2: Consistency

Server

Player

72

Page 73: CS4344 09/10 Lecture 2: Consistency

Server

Player

Player moves

73

Page 74: CS4344 09/10 Lecture 2: Consistency

Server

Player

Player updates server

“I am moving east at 5m/s”

74

Page 75: CS4344 09/10 Lecture 2: Consistency

Server

Player

RTT/2 later, server is notified

“Player A is moving east at 5m/s”

75

Page 76: CS4344 09/10 Lecture 2: Consistency

Server

Player

Player might moves again

Server simulates player and updates player“You are here at time t”

76

Page 77: CS4344 09/10 Lecture 2: Consistency

Player

RTT/2 later, player learns its actual position sometime in the past.

77

Page 78: CS4344 09/10 Lecture 2: Consistency

Player

Player re-executes its moves to find its proper position now.

78

Page 79: CS4344 09/10 Lecture 2: Consistency

Convergence

79

Page 80: CS4344 09/10 Lecture 2: Consistency

(zero order convergence)

If no convergence is used, player updates its position immediately -- in effect teleporting to the correct position, causing visual disruption.

80

Page 81: CS4344 09/10 Lecture 2: Consistency

If no convergence is used, player updates its position immediately -- in effect teleporting to the correct position, causing visual disruption.

(zero order convergence)

81

Page 82: CS4344 09/10 Lecture 2: Consistency

Convergence allows player to move to the correct position smoothly. First pick a convergence period t, and compute the correct position after time t.

82

Page 83: CS4344 09/10 Lecture 2: Consistency

Convergence allows player to move to the correct position smoothly. First compute the correct position after time t.

83

Page 84: CS4344 09/10 Lecture 2: Consistency

Move to that position in a straight line.

(linear convergence)

84

Page 85: CS4344 09/10 Lecture 2: Consistency

Curve fitting techniques can be used for smoother curves.

85

Page 86: CS4344 09/10 Lecture 2: Consistency

Visual disruption can still occur with convergence.

86

Page 87: CS4344 09/10 Lecture 2: Consistency

Player A

Recall: With short-circuit, we may need to fix inconsistency later using the server states.

Player B

Server

Inconsistent

87

Page 88: CS4344 09/10 Lecture 2: Consistency

Can we fix all inconsistency?

88

Page 89: CS4344 09/10 Lecture 2: Consistency

Player A

Player B

Server

A shoots B, B killed

B shoots C, C killed

B shoots C

89

Page 90: CS4344 09/10 Lecture 2: Consistency

A dead man that shoots

”“90

Page 91: CS4344 09/10 Lecture 2: Consistency

Short-circuiting not suitable for all cases.

Besides, important events like “hit” should be decided by the server.

91

Page 92: CS4344 09/10 Lecture 2: Consistency

Player A

Player B

Server

A shoots B

B shoots C

B shot &killed C

C killed

killed by A

kills B

92

Page 93: CS4344 09/10 Lecture 2: Consistency

Games can use audio/visual tricks to hide the latency between shooting and hitting.

93

Page 94: CS4344 09/10 Lecture 2: Consistency

Responsive

Consistent

Cheat-Free

Fair

Scalable

Efficient

Robust

Simple

94