Ok, for now I stop work in my branch.
Danger hitmap will be good for detecting danger for towns and heroes. It will be good for implementing survival instinct. I really like this idea and thought about it myself. Also I think we can precalculate it for a few days to see danger early enough.
Regarding build in my branch I searched for each town the next building for economics and next dwelling. 6 - 7 day I also considered citadel/castle. I tried to enforce balance so I can afford all army grows. I use army = income/3 to have some money for building. What if I use balance army = income and some resource reservations? We can use balance state as a parameter to fuzzy. Kind of armyCost/income*7. If it is high we need more economics.
Can it be useful to have more army grows than you can afford? Probably yes because we can develop economy later and only if we have money to develop town. We can try to use fuzzy to decide what to build dwelling or economy building. We can use income, army grows, and current amount of gold. What else? Maybe alternative gold sources as not captured mines? Capturing mine is equivalent to building city hall but usually more cheap. Also some army pressure might shift as to build dwelling. Small area and strong desire to explore sectors blocked by monsters/enemy? Garrisons?
Guys, do you always use all 7 levels of creatures in town? Is there any sense to skip some?
Also I think that towns are not absolutely equal and some are better for army development than others. I try to calculate overall town development cost needed to build all dwellings. Also it might be worth to consider strength of creatures and disabled buildings and amount of towns with such alignment.
Any other ideas?
What do you think about AIValue? Could we trust it? Or is it also considered as a hardcode and should be calculated dunamically?