

In many respects, the time out that I’m taking to learn ASP.net MVC for my next job has proved to be a blessing in disguise with regard to Ancient Armies. It has meant that I am restricted to only ‘dabbling’ into existing sub-systems. I simply don’t have the time to carry out any full scale Ancient Armies development – at least not right now.

For today’s dabble I decided to take a close look at the line of sight subsystem. That subsystem had always been a little slow. So much so, that it ran asynchronously and it had to perform another run when a player’s turn was finished – just to make sure that all the units were updated correctly!

The above behaviour can be seen in this earlier post. I didn’t like this behaviour as it meant that the player had to hang around at the end of a turn whilst the system updated all the units’ line of sight status.

Over the last 6 months or so I had kind of made numerous tweaks to the line of sight system to make it faster, but as it turns out I was optimising the wrong thing! It’s amazing how one’s own prejudices can lead to one making the wrong assumptions.

In this case, I had naturally assumed that the slowness was down to my code, but in the event, it turned out to be a Microsoft Direct-X method that was very slow. When I discovered this I was very surprised, as I had kind of assumed that all the Microsoft stuff would be lightning fast!

Once I had made the discovery, I wrote my own home-grown routine for unit detection. My routine is lightning fast and leaves the Microsoft routine in the dust. To be fair to Microsoft, I could afford to make a number of assumptions specific to my map design. It is here where I eked out a fair bit of the performance.

I was expecting my new algorithm to be fast, but I was unprepared for just how fast! It is so fast, that line of sight in Ancient Armies now occurs in realtime! 😎

The video at the top of this blog shows off a little of this optimised line of sight system. I’m sure that you will agree that it is much better than the original!

I will film an updated line of sight video that will provide deeper coverage for all the nuances of the Ancient Armies line of sight system. But for the moment, that’s it for this week.

Laters

RobP