Speed issues, scale, etc
The first game I wrote online - at least the first major game - was Universal Wars. I actually spent a great deal of time writing and then rewriting the game multiple times over. Often starting from scratch each time, it was never ‘quite right’. Each time it would take quite a while, and yet never see the light of day. But then, my partner had a big Uni assignment to do over two days, and I focussed - in just two days I finished (from scratch!) a completed and working copy of Universal Wars that actually went online! And it was great!
But, it suffered from scale. Eventually, a victim of both it’s own success and design flaws, the game became too slow. ‘Ticking’ once a minute used to be painless - then, started to take 10 seconds or more. Then 20. Eventually, the game couldn’t continue, and was taken down.
Fast forward a couple of years and I’m remaking the game using a powerful C++ server I wrote initially for the next version of Universal Wars. So scalability and speed is a huge issue for me this time around!
I’m testing to game with around 60,000 objects spread over a galaxy roughly 2,000,000 x 2,000,000 ’squares’ big. (That’s 4,000,000,000,000 squares!!). If it can cope with that, it can cope with a substantially smaller universe when we go live. But, it’s having issues - it has to do collision detection on a very large universe with a large number of simultaneously moving objects - and that puts it under a lot of stress. To alleviate this, I’ve reduced the number of coordinates by a factor of 10 - so each ship now occupies a tenth of the ’squares’ it used to, but it’s scaled up by the client to still look as smooth as it was before. Actually, it helps the client->server communication, because instead of having to transmit:
Ship 15 movingĀ fromĀ 3,5 to 3,6
Ship 15 moving from 3,6 to 3,7
Ship 15 mov….
It just sends:
Ship 15 moving from 3,5 to 3,16 over 11 seconds
And the client handles the rest. Much smoother!
This reduces the number of coordinates in the game down to 40,000,000,000- 100 times less. Still too much to store at once, so it’s stored in a different way (making use of 2 STL::map container’s, a vector of objects and a touch of magic!) but that’s where we are now
Onwards as ever.