7 ms·
I've written a series of articles about this topic: http://gabrielgambetta.com/fast_paced_multiplayer.html http://gabrielgambetta.com/fast_paced_multiplayer.htm
by ggambetta 11y ago
I've written a series of articles about this topic: http://gabrielgambetta.com/fast_paced_multiplayer.html http://gabrielgambetta.com/fast_paced_multiplayer.html It's usually well received, perhaps because it builds the ideas from the ground up and does not include the words "What the fuck is wrong with you?".
- Luc 11y agoThanks very much for this, these are great articles. It seems one would need some way of synchronizing clocks (or measuring the lag between server and client). Do you know if there is a standard way of accomplishing this?
- exDM69 11y ago> Do you know if there is a standard way of accomplishing this? Synchronizing clocks is one of the difficult problems in distributed computing. Games tend to avoid doing proper synchronization of clocks by working in discrete time steps (frames). Because games run at 15-60 frames per second (a bit more for simulators), you can get away with synchronizing the clocks to +/- a few frames, ie. an accuracy of tens of milliseconds is good enough to provide a perception of real time. In other words: game time is measured with an unsigned integer that tells how many time steps have elapsed since the game started.
- techdragon 11y agoSorry but that needs a rather large asterisk applied to it. In the current era of 120Hz LCD displays and a Billion dollar market for video games. It's becoming very evident that the "best", not in a AAA title sense, but in the 'so popular it becomes a sport with professional players" sense, games are those that have put a LOT more effort into the implications of their network synchronisation algorithms. Some game engines have extremely long tail lives as popular mods take advantage of reliable network behaviour to create gaming experiences that don't infuriate passionate players keeping them alive many years after the game that wrote the engine moved on.
- exDM69 11y agoVery good point! Back in Quake 1 days, the gameplay framerate was only 15 frames per second, so a more crude mechanism would do. I guess modern AAA games synchronize their clocks with an algorithm similar to what NTP is using. We're still talking about discrete time steps, though, so there's some tolerance for a little clock mismatch.
- animal531 11y agoUsually these days we use client/server for most games, meaning that initially the server is taken as being authoritative on time. It can collect and use a running average of pings to/from all clients which it can then use to order events (ie. did I do X before you did Y?). But that's where the really hard (and fun!) coding and choices start, such as for example future prediction and unrolling of actions. Roughly speaking, for prediction (to lessen the effect of perceived lag), the server could predict that I was moving forward up to the last packet received, so I'm probably still going to be moving forward. It can then use the predicted values in all calculations until it receives an actual packet informing it what actually happened (at which point it will need to decide how to handle possibly conflicting information, which is handled the same as below). For unrolling, if you have for example a 50ms ping and I 100ms; then at T+51ms you tell the server that you killed me, but I do the same at T+100ms - effectively compensating for the 50ms of lag difference between us you should die since I killed you 1ms before you killed me. BUT now it really depends on the server choices, do you kill me because your message got there first (old-school FPS); or does the server wait for my info since I'm involved in the action and then retroactively adjust you? Worse, since the server only gets my info on T+100 you will at best only get it at T+150, meaning that you will perceive 99ms of being alive (and maybe during which you killed someone else) which the server will then have to discard before killing you (some modern FPS use this scheme, you'll notice it where you peek out around a corner from safety and then go back, before suddenly being dead from an impossible shot). Also tough is the fact that it's not a single unroll, during the extra 99ms of being alive you would have still been sending packets to the server which then all have to be unrolled.
- kaoD 11y agoI've used this technique[0] successfully in a networked minesweeper game I made ages ago. Wikipedia lists more algorithms[1]. [0] http://www.mine-control.com/zack/timesync/timesync.html http://www.mine-control.com/zack/timesync/timesync.html [1] https://en.wikipedia.org/wiki/Clock_synchronization https://en.wikipedia.org/wiki/Clock_synchronization
- floodyberry 11y agogaffer's other articles are not expletive laden, but when you've been writing on a topic for so long and people are _still_ spreading lies and nonsense about it, even _after_ reading your articles, you too might reach a breaking point.
- Mithaldu 11y agoGlenn's articles are also well received and go in fact into much more detail, with code examples of various pieces of infrastructure. He's been writing them based on patreon donations for a while now: https://www.patreon.com/gafferongames https://www.patreon.com/gafferongames This one is just a frustrated vent at people who don't understand the difference between TCP/UDP, don't make the effort to learn about it, but feel the need to espouse about it. -- As an aside: floodyberry, you've been hell-banned for a few years now. Might wanna mail the mods.
- benihana 11y agoI don't get this guy at all. He opens with how hard networking is, then spends the entire article calling his readers stupid for not getting networking. Ok.
- Marazan 11y agoBecause he wrote an article on how to do networking but then gets people who clearly don't understand how networking works criticising and dismissing his article.
- triclohme 11y agoNobody cares if they get hell banned here. It's a bunch of pricks, what do you expect?
- desdiv 11y agoI was hellbanned for a while and didn't know it until someone told me. I emailed the mods and they told me they never banned me and that it must've been a technical glitch.
- exDM69 11y agoTo be fair, Gaffer's original articles are well written, thoughtful and informative too. This is him ranting about the unfounded, negative and incorrect feedback he's been receiving about them from people who are willfully ignorant about networking. He could or should have replied with less attitude and more facts, though. I understood what and why he's saying what he is, but I didn't enjoy the negativity either.
- ggambetta 11y agoHis articles are excellent, and I've learned a lot from them myself. But I cannot sympathise with lowering the level of a technical discussion to personal insults.
- Wintamute 11y agoI would be wary about parsing any text below the words "RANT MODE ON" all caps in bold as technical discussion.
- copperx 11y agoOn the other hand, I really love those personal insults. They get the point across. Maybe there's something wrong with me?
- amagumori 11y agothere's a difference between being angry at people and insulting them. he was definitely pissed off, but he didn't insult anyone.
- angersock 11y agoI don't know if this is a general failing of people's critical thinking abilities, a sloppiness in their reading, or something else, but I have noticed over the past (feels like) few years a growing problem: A lot of folks conflate personal insults ("you, ggambetta, are clearly a dunderhead when it comes to reading comments") with general sentiments about a group or abstract population ("Hacker News posters tend to be overly sensitive to the point of being crybabies"). A great deal of the flavor and comedy in writing, especially pieces that are self-identified rants, are not from personal insults but instead from hyperbolic and sometime vitriolic statements about an abstract other.
- Goladus 11y agoPersonally, I consider it very bad taste for you to sanctimoniously criticize Gaffer's tone to promote your own work. Sometimes a good rant is a very effective way to communicate. PS http://www.paulgraham.com/disagree.html http://www.paulgraham.com/disagree.html
- paulhauggis 11y agoFunny. If you are loved on hn, you can treat other people like shit (and berate them). Pg is not a god and it makes the community look hypocritical and stupid.
- andy_ppp 11y agoHmmmm. https://en.wikipedia.org/wiki/The_pot_calling_the_kettle_black https://en.wikipedia.org/wiki/The_pot_calling_the_kettle_bla...
- Goladus 11y agoAt least make sure your accusation is true before making it.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- ggambetta 11y agoYou are probably right -- it was bad taste. I got a bit annoyed by the tone of the article; I don't think personal insults have a place in a technical discussion. I taught Computer Graphics for several years, and I came across two kinds of students: uninterested, so no matter what you do they probably won't learn; and interested and trying hard but not understanding, in which case it's my responsibility as the teacher to find a way to get the idea into their heads. In this latter case I believe asking someone who is trying (but failing) to understand what I'm saying "What the fuck is wrong with you?" doesn't lead to better understanding on their part. Yes, I promote my own work, but this is because I feel it caters to a public that is usually left out -- the absolute beginner. The kind of people who are missing a mental leap or two to get the concepts but are either ignored or essentially called idiots for not understanding.
- rch 11y agoThe phrase you're apparently concerned with here is preceeded by: "I swear you guys are like the fucking climate change deniers of network programming." I appreciate the sentiment in context.
- nickpsecurity 11y agoI liked that part, too. Haha.
- jokoon 11y agoSometimes inviting the reader to ask himself question or be curious about the tools he's using can be important. Latency is not often taken in consideration when teaching networking. So many consider TCP to be the standard versus UDP, which needs to be clarified.
- archagon 11y agoI'm usually allergic to rants, but I liked this one because it didn't attack anyone in particular and also had tons of technical evidence to back up its claims. Gaffer even helped out the OP in a big way by providing a solution to his problem. Basically a free consultation from a networking expert.