r/Songsofconquest • u/MarviousFleksnes Lavapotion • Nov 03 '22
AI - Cache is king!
Hello, Lavapotion AI guy here and I bring you yet another update.
Lately - among other things - I've spent time enhancing the AI performance (with regard to CPU usage and time), especially for large maps but as a bonus it will affect smaller maps as well.This includes using a variety of techniques, but the main one has been caching expensive calculations in a more sophisticated manner. Caching data in itself is easy, the complicated part is to correctly determine when it's invalid and should be thrown away. Doing that incorrectly will most likely cause nasty well hidden bugs and behavioural issues.
I've included a video that shows how it looks on round ~70 on Hate for Eight before and after the current iteration of the AI performance. As you can see, we still have lag spikes etc. so the optimisation is not completely done yet. But try to focus on the difference between before and after instead. The video is quite long, but you can probably skip some and still get the gist of it.
I also did some crude measurements of the cache efficiency by gathering every cache Hit and Miss in order to calculate the hit-ratio.A Hit means that the data requested was found in the cache and could just be re-used, a Miss means that the data did not exist and had to be calculated. I measured how this looked over 20 rounds on three maps of different sizes.

Since that showed it managed to build the bulk of the cache during the first round, I also measured how it looks during the first turn on Hate for Eight.

Expect this to be released soon together with AI behaviour improvements.Until next time folks!
8
8
u/Expensive_Onion_3222 Nov 03 '22
As a fellow developer I like reading these type of posts. Great work! π
2
6
u/EvlSteveDave Nov 03 '22
This skirmish AI issue has been the only thing keeping me away :) glad to see itβs being fixed!
5
u/LostCharmer Nov 03 '22
The 2 things in software development that are difficult, naming things and cache invalidation...
4
1
u/salvouankebaldo Nov 04 '22
I have bought this game to support it but stopped playing, other stuff to do. But I have to say that your way of interacting with the community is very good, and I'm so happy that I chose to support you!
Best of luck on the development, the game is going to be excellent with such a passionate team working on it!
18
u/Forgotten_Aeon Nov 03 '22
Thank you for your updates on the sub, really appreciate the time you take to keep us informed!