Line of Sight is now in Real-Time! :p


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

Advertisements

4 thoughts on “Line of Sight is now in Real-Time! :p

  1. This game looks really cool. I take it keeping your leader mobile yet alive must be very important in battle. Also will it be possible to send small scout forces to learn more about enemy unit positions?

    • Yes to both. Scouting is going to be a manoeuvre like everything else. For most Armies it will only be available to Cavalry, and maybe some skirmishes. However, in both cases, you won’t know what they see, until they report back!

      • So, you are implementing friendly fog of war? I didn’t catch that in your post, but certainly didn’t miss it in this reply! Can’t wait to hear more.

      • The game supports three Line Of Sight modes. Leader based (friendly FoW), Side based (enemy FoW) and none at all.

        The game will provide the best experience with the full Leader based line of sight as shown on this post.

        When I get some time, I will put up an updated video that will show off the nuances of the different modes 🙂

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