1st underestimation : Floating Points

People who aren’t exactly familiar with the networking techniques will think that in a multiplayer game, the server will always be the one sending all the world information to every single player all the time, even though it ensures that every one sees the world the same way as others, it’s not always the best solution. Instead of sending every 20 millisecond the states of the enemy AI from the server to clients, we can simply send the action to perform and then simulate the same behavior across the clients and make them behave in the same exact way everywhere, saving us a hell lot of data to transfer which we can use for more important stuff. For certain types of games such as FPS ones, it’s acceptable if some things aren’t simulated in the same way across all machines but for RTS games, synchronizing the gameplay is THE most important thing.

The first problem with my game was the fact that I underestimated the determinism, I thought “hey, I could simply make some fancy pathfinding and replicate it across clients” but I soon discovered that a floating point can be a bitch and small differences were noticeable while doing network tests, ultimately ending up with desynchronized games.

The problem with floating points is that you don’t exactly have the same result on all machines ( if you’re interested for more details, here’s a nice A-to-Z article on floats : http://randomascii.wordpress.com/2013/02/07/float-precision-revisited-nine-digit-float-portability/ ) but in some languages such as C++, you have the possibility of forcing the machine to use a certain standard, allowing the floats to have same results across all platforms. Unfortunately in C#, you do not have this option.

I didn’t expect the lack of such thing and this had caused me some problems because most of my game’s logic was already heavily based on floats. AI wars’ developer Christopher M. Park encountered the same kind of problem for his game and he managed to create a fixed point class that would be used like deterministic floats, resolving his problems once and for all. ( http://stackoverflow.com/a/616015 )

My new goal for the new build of FationCommand would be avoiding the floats and using integers or fixed point values instead.