<p>I'm thinking about making a networked game.  I'm a little new to this, and have already run into a lot of issues trying to put together a good plan for dead reckoning and network latency, so I'd love to see some good literature on the topic.  I'll describe the methods I've considered.</p>

<p>Originally, I just sent the player's input to the server, simulated there, and broadcast changes in the game state to all players.  This made cheating difficult, but under high latency things were a little difficult to control, since you dont see the results of your own actions immediately.</p>

<p><a href="http://www.gamasutra.com/features/19970919/aronson_01.htm" rel="noreferrer">This GamaSutra article</a> has a solution that saves bandwidth and makes local input appear smooth by simulating on the client as well, but it seems to throw cheat-proofing out the window.  Also, I'm not sure what to do when players start manipulating the environment, pushing rocks and the like.  These previously neutral objects would temporarily become objects the client needs to send PDUs about, or perhaps multiple players do at once.  Whose PDUs would win?  When would the objects stop being doubly tracked by each player (to compare with the dead reckoned version)?  Heaven forbid two players engage in a sumo match (e.g. start pushing each other).</p>

<p><a href="http://www.gamedev.net/reference/articles/article1370.asp" rel="noreferrer">This gamedev.net bit</a> shows the gamasutra solution as inadequate, but describes a different method that doesn't really fix my collaborative boulder-pushing example.  Most other things I've found are specific to shooters.  I'd love to see something more geared toward games that play like SNES Zelda, but with a little more physics / momentum involved.</p>

<ul>
<li>Note: I'm not asking about physics simulation here -- other libraries have that covered.  Just strategies for making games smooth and reactive despite network latency.</li>
</ul>

[{'answer_id': 42549, 'author': 'Cristian Sanchez', 'author_id': 3659, 'author_profile': 'https://Stackoverflow.com/users/3659', 'pm_score': 5, 'selected': True, 'text': '<p>Check out how Valve does it in the Source Engine: <a href="http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking" rel="noreferrer">http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking</a></p>\n\n<p>If it\'s for a first person shooter you\'ll probably have to delve into some of the topics they mention such as: prediction, compensation, and interpolation.</p>\n'}, {'answer_id': 74415, 'author': 'Joel Martinez', 'author_id': 5416, 'author_profile': 'https://Stackoverflow.com/users/5416', 'pm_score': 0, 'selected': False, 'text': '<p>Check out Networking education topics at the XNA Creator\'s Club website.  It delves into topics such as network architecture (peer to peer or client/server), Network Prediction, and a few other things (in the context of XNA of course).  This may help you find the answers you\'re looking for.</p>\n\n<p><a href="http://creators.xna.com/education/catalog/?contenttype=0&amp;devarea=19&amp;sort=1" rel="nofollow noreferrer">http://creators.xna.com/education/catalog/?contenttype=0&amp;devarea=19&amp;sort=1</a></p>\n'}, {'answer_id': 835317, 'author': 'Jonas Byström', 'author_id': 87973, 'author_profile': 'https://Stackoverflow.com/users/87973', 'pm_score': 4, 'selected': False, 'text': '<p>I find <a href="https://web.archive.org/web/20181107181430/https://gafferongames.com/post/networked_physics_2004/" rel="nofollow noreferrer">this network physics blog post</a> by Glenn Fiedler, and even more so the response/discussion below it, awesome. It is quite lengthy, but worth-while.</p>\n\n<h3>In summary</h3>\n\n<p>Server cannot keep up with reiterating simulation whenever client input is received in a modern game physics simulation (i.e. vehicles or rigid body dynamics). Therefore the server orders all clients latency+jitter (time) ahead of server so that all incomming packets come in JIT before the server needs \'em.</p>\n\n<p>He also gives an outline of how to handle the type of ownership you are asking for. The slides he showed on GDC are awesome!</p>\n\n<h3>On cheating</h3>\n\n<p>Mr Fiedler himself (and others) state that this algorithm suffers from not being very cheat-proof. This is not true. This algorithm is no less easy or hard to exploit than traditional client/server prediction (see article regarding traditional client/server prediction in <a href="https://stackoverflow.com/questions/42515/dealing-with-latency-in-networked-games/42549#42549">@CD Sanchez\' answer</a>). </p>\n\n<p>To be absolutely clear: the server is not easier to cheat simply because it receives network physical positioning just in time (rather than x milliseconds late as in traditional prediction). The clients are not affected at all, since they all receive the positional information of their opponents with the exact same latency as in traditional prediction.</p>\n\n<p>No matter which algorithm you pick, you may want to add cheat-protection if you\'re releasing a major title. If you are, I suggest adding encryption against <a href="http://en.wikipedia.org/wiki/Aimbot#StoogeBot" rel="nofollow noreferrer">stooge bots</a> (for instance <a href="http://en.wikipedia.org/wiki/XOR_cipher" rel="nofollow noreferrer">an XOR stream cipher</a> where the "keystream is generated by a pseudo-random number generator") and simple sanity checks against cracks. Some developers also implement algorithms to check that the binaries are intact (to reduce risk of cracking) or to ensure that the user isn\'t running a debugger (to reduce risk of a crack being developed), but those are more debatable.</p>\n\n<p>If you\'re just making a smaller indie game, that may only be played by some few thousand players, don\'t bother implementing any anti-cheat algorithms until 1) you need them; or 2) the user base grows.</p>\n'}, {'answer_id': 835356, 'author': 'Andrioid', 'author_id': 99209, 'author_profile': 'https://Stackoverflow.com/users/99209', 'pm_score': 0, 'selected': False, 'text': "<p>You could try imposing latency to all your clients, depending on the average latency in the area. That way the client can try to work around the latency issues and it will feel similar for most players.</p>\n\n<p>I'm of course not suggesting that you force a 500ms delay on everyone, but people with 50ms can be fine with 150 (extra 100ms added) in order for the gameplay to appear smoother.</p>\n\n<p>In a nutshell; if you have 3 players:</p>\n\n<ul>\n<li>John: 30ms </li>\n<li>Paul: 150ms</li>\n<li>Amy: 80ms</li>\n</ul>\n\n<p>After calculations, instead of sending the data back to the clients all at the same time, you account for their latency and start sending to Paul and Amy before John, for example.</p>\n\n<p>But this approach is not viable in extreme latency situations where dialup connections or wireless users could really mess it up for everybody. But it's an idea.</p>\n"}, {'answer_id': 28838510, 'author': 'drusilabs', 'author_id': 4628936, 'author_profile': 'https://Stackoverflow.com/users/4628936', 'pm_score': 2, 'selected': False, 'text': '<p>we have implemented a multiplayer snake game based on a mandatory server and remote players that make predictions. Every 150ms (in most cases) the server sends back a message containing all the consolidated movements sent by each remote player. If remote client movements arrive late to the server, he discards them. The client the will replay last movement.</p>\n'}]
['https://Stackoverflow.com/questions/42515', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2653/']