Wednesday 29 August 2007

How to Become a Great Network Programmer: Part II



How to Become a Great Network Programmer: Part II - GameCareerGuide.com
#
How to Become a Great Network Programmer: Part II
[08.21.07]
- Adam Martin
#

Game 3. RTS: Determinism, Replay, Sync

You've made a simple real-time game and a simple persistent game, but nothing so far has run into any of the big classic problems of network programming. That's going to change with the next game. It's time to learn about determinism.

The aim here is to create a top-down real-time strategy game with a hundred or more units running around on a map and swarming your opponent's base(s), all without any apparent slowdown in the graphical user interface.

The best way to do this is to make all your calculations deterministic so that instead of having to send the result of every single calculation across the network, you can just send the inputs of each player to each other player, and all the players' machines can work out for themselves what's happening on all the other computers. This method reduces the volume of network messages vastly, but it goes horribly wrong if the slightest bit of non-determinism sneaks into the system.

Making this work properly and play nicely with a good path-finding algorithm will give you plenty to chew on. Get something wrong, and your units will start wandering off in strange directions or giving up and not moving at all. Or, if you try to skip the determinism, you'll quickly find the volume of shared data and calculations are so great, you can't get the game to work at a decent real-time speed.

Remember, though, that "deterministic" doesn't mean you can't have random numbers -- it just means you have to seed them.

For bonus points, implement a fully deterministic AI as well.

more information in the original article
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo

Google Analytics