How we solved an infamous sliding bug(joostdevblog.blogspot.nl) |
How we solved an infamous sliding bug(joostdevblog.blogspot.nl) |
I was sincerely hoping for an actual technical solution for dealing with peer-to-peer networking and lag. I feel somewhat cheated out of the time it took me to read that article. While it did explain the problem very nicely, the solution was to just disable the feature outright.
> The solution we finally managed to come up with is also a good example of how very incorrect workarounds can actually be a really good solution to a complex problem.
So you knew they were presenting a "very incorrect workaround"---which, counterintuitively, worked better than some of the more "correct" things they tried.
It actually made it a bit more enticing, I was expecting a horrific chain of gotos or some other cliche programming paradigm being completely violated for the sake of pragmatism.
What we got instead was, "This is a hard problem, let's just not solve it." which was written up with a title of "How we solved a hard problem"
To be fair, they did solve the problem. If it isn't noticeable during gameplay and doesn't create unwanted degenerate actions from players, they succeeded in fixing the bug, even if the technical aspect is simple.
Every player uses a tick-engine (ie tick every 0.1s) that performs the same commands on the same ticks. When a player issues a command, such as "Build Unit X", it sends it to every other player to run a couple ticks ahead (how far ahead is based on average lag or whatever). If anyone performs differently, then a de-synchronization occurs and the game is over.
It's explained much better here http://www.gamasutra.com/view/feature/3094/1500_archers_on_a... "Because the game's outcome depended on all of the users executing exactly the same simulation, it was extremely difficult to hack a client (or client communication stream) and cheat. Any simulation that ran differently was tagged as "out of sync" and the game stopped. Cheating to reveal information locally was still possible, but these few leaks were relatively easy to secure in subsequent patches and revisions. Security was a huge win. "
I wonder what their reasons were for going with peer-to-peer instead of anointing a player as the 'server' as many other console multiplayer games do (Awesomenauts started out on console, IIRC)? That would solve a lot of these desync problems because the server would be responsible for resolving all the collisions.
There might still be corner cases, but it would seem to resolve the described issue, since irrespective of where you think the other player is, if you both reverse your motion you should disengage.
I can see 3-body problems being more problematic, but that's probably also the case with the original code.
In the original version only the higher objectID would react and disable his collision, thus not requiring the lower objectID to detect the problem.
It is not called out, but it looks like they not have both sides call out when a collision occurs, allowing both to turn off in this case.
So the collision occurs, both say "I am going right" and when they hear the other one doing the same they both stop.
That way, one player would move right (or left) more than the other player and the collision would still resolve itself.
I've worked anti-cheat (and written cheats) for several games, and there's little you can do in the space of 1-on-1 games to prevent cheating(1), but in the space of 3+ player games the separate simulations can "vote" to remove the player who is cheating (in the desynchronization fashion as above), if you assume there are going to be fewer cheaters in games than legitimate players. Of course if there is any knowledge hidden by the client in its render/UI of the game then a cheater can always recover that data, which is why when you can build a client/server model not transmitting hidden data is the most effective strategy to counter cheating (for example don't transmit entities the player shouldn't be able to see.) This is often difficult, of course, for example if you want footstep sounds to travel through walls in an FPS, but a lot of low-hanging fruit that cheaters would want can be pruned that way.
1: The other (common) approaches are to detect the cheats and punish the cheaters afterwards (Punkbuster, Valve Anti-Cheat, Warden, etc.) or try to lock down the process and make it difficult to write effective cheats (GameGuard, or one trick Blizzard does is attach a second process as a debugger of the game process and IPC validation checks so you can't directly/easily hook into the main process.)
Edit: I now realize you mention hidden data still being recoverable, and desynchronization as a method to combat cheating, I missed that at first but figure I'll leave my post up anyways, even if only to emphasize that seeing the whole map is a very valuable cheat that has taken players easily into the top of the Starcraft ladder (and the top of the Grandmaster rank in Starcraft 2).