Here the challenge I've been working on. A new function to assign unassigned units at the end of the move phase to redeploy towards the selected enemy nation. In the case of Russia to advance toward ally Austria or Prussia at war with France (think Austerlitz), or on to France if everyone is at war. How many forces? I created a function to check for factors on the map minus factors already deployed into an enemy nation and then assume some fraction of that remainder as a max to move, since you don't want everyone to move. Which units should move? I created another function to find the nearest eligible unit. That had a path-finding check that proved problematic, so I replaced that with a simpler distance check. Another function cycles through the eligible units and assigns them up to the max factors and that one requires path-finding. Complicated? You betcha. But after tracking down issues to individual lines of code and figuring out how to resolve things, it's working OK now. But again, still some issue at the end that isn't exiting the function correctly.
I have also made some improvements to auto-foraging and rolled them into the AI. Good news is that the AI is auto-foraging better now prior to paying for supply or risking losses during regular forage. Same as for human players. Bad news is that I'm noticing the game appears to hang while the AI goes through all those foraging checks, but it's just slow; players will have to have some patience with this. I need to verify if this is more because of the debug version I'm playtesting or if the optimized release version may be faster.
I am chugging along. Last weekend's playtests did not meet my satisfaction. I got to a point in the 1812 scenario where French forces were essentially bypassing Russians and not making attacks while the Russians were making some reckless attacks. One AI parameter I messed with was the requirement for units to be in supply to make attacks. Well, there could be some foraging risk so I loosened that requirement, and lo and behold the AI started being a bit more aggressive. So I needed to make some more adjustments. What follows below are some playtests from today 11/14 for the 1812 scenario. I'm basically playing neutral Austria and watching what the AI does.









