Game Netplay Rollback System – Development and Networking

game developmentnetworking

Can one explain the specifics and details of a netplay framework for a game that optimizes connection through a "prediction / rollback" mechanic, as seen in games where speed is a priority (first-person shooters, modern fighting games since Street Fighter IV, etc)?

I have previously studied this article as an example: Source Multiplayer Networking, which describes Valve's techniques used in their shooters on a high, abstract level. However, it is simply too high-level and theoretical to be of use to me. Other similar articles follow this same pattern; none offer code samples or working examples.

I have previously crafted netplay systems that use unoptimized TCP/IP, which is obviously horrendously slow and non-useful for anything except LAN play. Although I have taken a college course on network programming, I am only confident and experienced enough to have made this system through approximate copying of other pre-existing code.

Best Answer

Prediction/rollback algorithms work similar to MPEG compression. MPEG predicts possible changes based on a previous frame. Follow up frames end up being mostly diffs off the previous frames. When there is a major change...or every so often a Keyframe is encoded to synchronize the true decompressed image with the actuals.

In a similar way rather than having to synchronize every action across all the clients, the host makes predictions about next frames (aided by facts it knows about the world -- this rocket will travel straight until it hits something) and the clients do the same.

The clients receive differences (player a changed direction) in the form of raw input and "key frame" updates from the server and synchronize their state to that. Sending input operations to the clients and a full synchronization every so often from the server decreases the chatter while still allowing the server to be the "master" of state.

I can't remember where I read this article that gave me an good understanding of the technique (either Gamasutra or one of the Game Programming Gems series), but it discusses how this was an improvement of the network stack between Doom 2 and Quake. I did find a nice example in C# that shows a Prediction algorithm that you can build on.

Here is a similar question on Gamedev about that very topic

Related Topic