- 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?
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?