Math Q: How do Internet video games solve the "shot at same time" dilemma?

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
I've wondered for some time how multiplayer video games - that is, those involving players distributed across a network - decide upon a winner in this typical situation:

Player A and Player B fire a one-shot-kills bullet at each other at nearly the same time - Player A's fires 1/1000th of a second first. Being that each player is on their own machine across a network and that the time on their machines is not necessarily correct (a bit fast or a bit slow), you can't trust that data. How is the who shot first decision made?

I thought that Lamport timestamps might be the solution, but after thinking about it while doing dishes this morning I'm not so sure - that seems to solve the issue only when A and B talk to each other first, and then each try to contact C. I'm starting to suspect that the only solution is to start each game session with a "synchronize!" command to all machines, and then further synchronize commands at regular intervals during the match (plus tracking of what machines fall behind and built-in compensation for it). I keep thinking I might be missing a simpler solution, though. Anyone have any ideas?
 

nick1985

Lifer
Dec 29, 2002
27,158
6
81
In BFBC2 you both die. If I had a nickel for all the times that's happened to me in that game I could retire.
 

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
Yeah, in the Halo games you also both die - and that's not a bad solution considering that the alternative is one player consistently winning because the who-wins algorithm just happens to be in his Xbox's favour for that match (my Xbox's local time is 1/100th of a second before you, thus I always win). There's got to be an overall strategy for this sort of thing that I'm curious about.
 

DayLaPaul

Platinum Member
Apr 6, 2001
2,072
0
76
I remember only one instance of a double death (not including nades) in Counterstrike but that was in early beta. Now whoever fires first always gets the kill. In the event that you both fired at the *exact* same time, I believe he who does the most damage past 0 HP gets the kill.
 

Malak

Lifer
Dec 4, 2004
14,696
2
0
In CoD you both die. Has happened to me on several occassions. Back in the day when bullets were instant hits this couldn't occur.
 
Oct 27, 2007
17,010
1
0
Heh I went through a whole computer science degree without coming across Lamport timestamps. Interesting article.

As for your question OP, I'm not really sure but I'm interested to hear the answer.
 

yhelothar

Lifer
Dec 11, 2002
18,408
39
91
What about if player A and player B are on the same team, and they both one shot kill player C at the exact same time.

Who gets the kill?
 

biggestmuff

Diamond Member
Mar 20, 2001
8,201
2
0
Bungie used to blog about this type of stuff. Should be easy to find. I can't think of any other developer that has written about it.
 

0roo0roo

No Lifer
Sep 21, 2002
64,862
84
91
very rare, i'm not sure what it involves when adding lag compensation. only remember it once.
 

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
The same way offline 2p+ simultaneous games do.
Unless I'm missing something, the process of having multiple machines involved make it much more complicated than the offline scenario.

Quake 3, both die as the bullets actually take time to travel.
You were my #1 hope to know of a mathematical approach for this problem!

Bungie used to blog about this type of stuff. Should be easy to find. I can't think of any other developer that has written about it.
I thought so too, but I can't find anything. I posted this question on Quora hoping it comes to someone's attention...
 

mpo

Senior member
Jan 8, 2010
457
51
91
The Source Engine's multiplayer networking page deals with this:
http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

A relevant quote:
The lag compensation system keeps a history of all recent player positions for one second. If a user command is executed, the server estimates at what time the command was created as follows:
Command Execution Time = Current Server Time - Packet Round-Trip-Time - Client View Interpolation
Then the server moves all other players - only players - back to where they were at the command execution time. The user command is executed and the hit is detected correctly. After the user command has been processed, the players revert to their original positions.
 

CZroe

Lifer
Jun 24, 2001
24,195
856
126
Unless I'm missing something, the process of having multiple machines involved make it much more complicated than the offline scenario.


You were my #1 hope to know of a mathematical approach for this problem!


I thought so too, but I can't find anything. I posted this question on Quora hoping it comes to someone's attention...

No. The logic of deciding is the same. The compensations considered do but, as anyone knows, the compensations aren't always fair. Your rail shots in Quake III Arena connect immediately if you are the host, but your opponents have to "lead" you by varying amounts according to their latency.

Quake 3, both die as the bullets actually take time to travel.

Rail shots don't.
 

yllus

Elite Member & Lifer
Aug 20, 2000
20,577
432
126
The Source Engine's multiplayer networking page deals with this:
http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

Excellent, thanks! This is what I was looking for.

No. The logic of deciding is the same. The compensations considered do but, as anyone knows, the compensations aren't always fair. Your rail shots in Quake III Arena connect immediately if you are the host, but your opponents have to "lead" you by varying amounts according to their latency.

If you introduce trust logic, lag compensation logic and interpolation logic, then, no, in a networked game your logic is different than that of a game played on a single machine.
 

somethingsketchy

Golden Member
Nov 25, 2008
1,019
0
71
I thought that Lamport timestamps might be the solution, but after thinking about it while doing dishes this morning I'm not so sure - that seems to solve the issue only when A and B talk to each other first, and then each try to contact C. I'm starting to suspect that the only solution is to start each game session with a "synchronize!" command to all machines, and then further synchronize commands at regular intervals during the match (plus tracking of what machines fall behind and built-in compensation for it). I keep thinking I might be missing a simpler solution, though. Anyone have any ideas?


The only question I would have at this point, with all of the "sync" commands, is how much extra overhead would be introduced into the current game. It would be all right if this command was done every 15 seconds, but I would think at 60 times a minute, you would start to introduce more "lag" into the game.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
Quake 3, both die as the bullets actually take time to travel.
It depends on the weapon. The railgun, machinegun, and shotgun are all "direct fire," meaning that their shot hits instantly when you shoot. The way Q3 handles the problem is by splitting server/client communications into discrete time events (sv_fps is the console command for setting steps per second, IIRC). As long as two shots are fired within this time step, they will be treated as simultaneous by the server. This works very well in a low-ping environment when the server has access to all of the information for every player within that time increment, but it starts to break down when pings approach the time interval of a single interval. I'm actually not sure what happens in that case, though it may depend on a number of other settings.
 

SSSnail

Lifer
Nov 29, 2006
17,461
82
86
I don't think it cares. They calculate it based on the HP and the damage done per hit, once the damage factor leaves, it couldn't care less when it gets there, but when it gets there if the DMG > HP then the person dies (and lag be damned).
 

CZroe

Lifer
Jun 24, 2001
24,195
856
126
Quake 3 didn't have bullet travel time.

Not for machine or rail guns, but the rocket launcher, BFG, grenade, and plasma certainly did. There was obviously some slack in the calculations because I can't tell you how many times I and my opponent have both died together when facing off with insta-kill weapons.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |