
Hi everyone,
Last week I initially worked on the combat calculations and managed to make some good progress on overhauling and optimising the way the calculations were handled. Then I inevitably kept thinking about the navigation and got drawn back into it.
So, let me talk (hopefully for the last time) about navigation once more. I never know how technical I should get in these updates, so I will try to keep it sensible here as well. When I talked about setting up graphs (mathematical representations of the terrain) before, I mentioned that they were both used for villagers to be able to “see” the world and calculate where to go, as well as a range of other things (e.g. validating where the player orders a soldier to go, colour of the map, etc). My ideal solution used a very cleaned up graph to do all of these - but there were many issues with actually creating or cleaning up a graph as the system wasn’t built for it to be updated manually.
My alternative solution was to find a middle ground between good pathfinding and addressing the other considerations - which would have worked for now, but sort of left a bad taste in my mouth for being very half-finished and not ideal on any one function. However, I now decided to essentially use 2 graphs to do what I wanted - one to validate orders, etc, and one for the actual pathfinding. This means that I needed to adjust quite a bit of the code, but as a result, we have a reasonably clean setup now, which should take no time at all to switch over to the ideal solution if that becomes viable - while performing pretty well on all functions.
Once this was set up, I switched the rest of the game to using the new solution (so plants and buildings would be recognised by the graph, etc), and things are working very well already. I’m sure there will be a few things I will have to adjust over the coming few days as I remember that they need to be switched over, but for the most part, performance of the villager and soldier pathfinding is much faster than it was before.
The new system also gives us much more flexibility for further optimisation and improvement if and when we need it, so I am overall very happy with where we have gotten.
Over the next week, I will hopefully finish the optimisation of the combat calculations - As usual, I will keep you posted.
Until next week!
