Out of Time!

Initial stress testing of the system.

Initial stress testing of the system.

The screenshot above shows a number of semi-historical units in a mock battle to test how the system can deal with many units. It’s not the largest battle in the world, but it is a lot bigger than the ones that I have been testing up until now.

With this many units in play and moving about, there was a negative effect on framerates.

I can probably perform more optimizations to make things liquid smooth again, but I now think that the time is right to implement my fall-back plan *Muhahaha* 😈

Many of you know that the system runs using 30 second real-time turns. Some of you might have been wondering why I had gone down this design route instead of making the game fully real-time?

Well here are the answers:

  1. I wanted a game that could easily be played by email – a popular means of playing wargames on the internet.
  2. I also wanted to provide a back-up plan for potential future performance issues…

Answer 2 probably needs a little more elaboration.

Real-time games have one technical disadvantage, they are constrained by the fact that all the game calculations have to be performed at least 60 times every second. As a result each set of calculations must be finished before its 16 millisecond slot elapses.

Calculations can take longer, but at that point they will start to negatively impact the game’s frame-rate. Either that or the calculations will start to introduce significant lag to the gameplay.

Another obvious side-effect of this technical limitation is that it will ultimately restrict the maximum size of the battles that you can run before the system starts slowing down to a crawl. More units always equate to more calculations…

By designing the game with 30 second game turns, it has provided me with a fallback option of performing all the calculations for a turn up front. This will however result in a progress bar appearing with the words ‘Thinking…’, just before each turn starts.

I believe that this is a small price to play to enable one to have battles of any size and to allow one to have more leeway with regard to the calculation timings.

In fact, it will allow me to add complex Artificial Intelligence (AI) routines to the game without having to run into the 16 millisecond constraint. Of course, I can’t go completely nuts, as no one wants to wait for an hour whilst the computer works out the next turn! 😛

Having a progress bar between turns also has the advantage that it provides a cue to the user that they are about to switch from planning to operations – something that’s not readily apparent right now.

To implement the above system properly will be technically challenging, especially as I see it as an opportunity to add replay functionality to the system. Replays would essentially be leveraging very similar functionality to that used for a pre-processed game turn, so I might as well code the system so that it does both.

The upshot of this is that the next tranche of work is going to take longer than usual, as a result the next update on this blog may end up being some time away. But do not fear, I will be beavering away!

Before I go I’d like to thank ‘roaming111’ who has been submitting these blog posts to reddit, where they have been reaching number 1 on numerous occasions 😎

I don't know who roaming111 is - but thank you for submitting Ancient Armies to reddit and helping to get it to number 1! :)

Fleeting Fame from yesterday. I don’t know who roaming111 is – but thank you for submitting Ancient Armies to reddit and helping to get it to number 1! 🙂

I will leave you with a few more screenshots of the semi-historical units that were used for the current round of testing:

A close up of the pseudo Macedonian Army.

A close up of the pseudo Macedonian Army.

A close up of a Roman Republican legion.

A close up of a Roman republican legion.

A much closer look at the centre of the Roman legion.

A much closer look at the centre of the Roman republican legion. Note these are pseudo historical only. I just took a reference from one source. For the actual scenarios, I will be taking my time to get the units and their formations right!




5 thoughts on “Out of Time!

  1. Interesting post, it makes me curious about a couple of things. What kind of hardware are you developing on? And is the frame rate and update rate in sync? Does the game need to update at 60 updates per second? That seems rather high. Perhaps a constant, but lower UPS and an unbounded FPS is the way to go.

    • The hardware is an old PC from 2009. I think it’s a quad core 2.9Ghz machine, though I’d have to check.
      At the moment the two are in sync, but that’s simply because they are both running in the same thread (this is my first game, so I’m kind of learning things as I go 🙂 ).
      One thing I could do is move the calculation and update calls to its own thread. However, that would also take a bit of work as I would need to make sure everything is thread safe before I do that.
      I guess I have been targeting 60fps because I like the fluidity of the map, the u-tube videos really don’t do it justice, it’s completely liquid smooth.
      There are many technical approaches that I will be taking a look at, as I want to make sure I’m providing the best solution possible 🙂

      • Well that’s a relief, I use an older laptop with similar specs. I was afraid you were running a gaming beast :).

        With respect to the game loop, I would suggest playing with the updates per second to see how low you can go. For example 25 UPS is still only 40 ms/tick, which given human reaction/perception isn’t too bad IMO. This might improve the overall FPS (which you can allow to be 60 or even higher). Of course you’ll have to implement prediction/interpolation but it might turn out better in the end.

  2. Howdy. This is roaming111. I have been watching your game develop for quite some time and I thought others might find it interesting as well. So I thought I may link it onto the computer wargaming reddit. I haven’t been able to link every post you do because of life getting in the way but will when I get a chance.

    • Thanks Bly – it’s much appreciated. Rather coincidently I have been back in the code editor for the first time in a long while. Just got to fix some new LoS bugs, then we are good to go for the next development phase 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s