AI Development Discussion and Feedback



  • Hey I have an AI suggestion from a statisticians perspective.

    Basically - if you are in a desperate position, attacking when its a 25% chance of victory sort of thing can be a very good idea. If time is not on your side, a desperate attack is good. That said, if you could code hard AI to be more willing to attack when their alliance has lower production than their enemy does or in other definable desperate situations. Example - if you are backed up to your capital (or other strategically important position) and your odds of victory on attack are higher than on defense, attack no matter the odds of victory on attack.

    There's also often situations (when low luck is off) where defeat is probable or expected TUV swing is negative but expected TUV swing in round 1 is positive. In these circumstances an attack and then retreat maneuver is a good idea. This is especially the case with low luck off where if the first round goes very well, the second round might be worth attacking in and you can just keep going until you need to retreat.

    Anything to make hard AI harder


  • Admin

    @scallen1 So at a high level both suggestions are good. Thoughts:

    1. Its very difficult to determine when you are in a desperate position across all rules/maps. And even when you are, its hard to determine if its better to attack or delay. That being said from more limited scope, if say the AI realizes it has no where left to run and has better odds/TUV to attack rather than defend then it probably should. Overall, I don't think this happens that often in games but gathering some specific save games would be helpful.

    2. Yeah, this is usually referred to as 'strafing' by most players. The AI will do this already but only in the case where it is trying to setup one of its allies to then attack the weaken territory. It doesn't do it just for TUV trades yet and is something I'd like to add.



  • @redrum I don't know if I've ever clearly noticed a "nowhere left to run" scenario for the AI but every time I play as germany on any map I'm guaranteed to eventually run into this in the Baltic.

    Desperate may not be the best way to describe things. In a vanilla WW2 game, Germany should see a 50 50 as a time to attack. Russia should see it as a time to defend cause time is not on their side. And I think you can generalise "time is not on my side" when ratio of production is like Idk greater than 5/4. You could put some small tolerance of attack when slightly disadvantaged (say if TUV swing is > -5% of combined TUV under the condition that your PUs per turn are much lower.because this usually means the situation is the best it is going to get.

    However if the AI actively tried to bleed (straffe) the human player you might remove the need for this except in last stand scenarios. And Last stand scenarios aren't things that probably have much impact on the overall game more than very rarely.


  • Admin

    @scallen1 So TUV comparisons are a tough because of the variety of maps. Some maps have lots of infrastructure units or give free units or have units sets that some nations have more efficient units, etc. The TUV of alliances on those maps means very little at a high level. Open up Civil War if you want to see what I mean.

    But yeah straffing is much more applicable and more tactical to figure out.



  • @redrum Ok makes sense. (yes civil war is a great example. I haven't put in the effort to learn that entire game and I imagine the AI is pretty bad at it)


  • Admin

    @scallen1 Yeah, the AI can't really handle Civil War and some of the other complex maps. Mostly it doesn't understand the unit production facilities or limited round battles.



  • Ok, had some odd ai behavior in a couple places while playing the new Middle Earth Battle for Arda map.
    map version 2.0.6 I'm using engine version *.11715
    probably issues due to all the fanciness in the map ofc

    Scenario 1 (with attached save)
    0_1535910319428_Arda_AI_dragonattackelves.tsvg

    Angmar consistently (both times I tried it) sends two dragons to attack Rivendell; I have plenty of forces in place, so the dragons just die a horrible death while not accomplishing much. When I let the round play out there wasn't an attack from a subsequent nation to take advantage of it either, so it can't just be suiciding to setup another nation's successful attack.
    From the logs it seems to be marking it as a strafing attack though.
    my best guess is that the battle calc is screwing up the ai because you first have the one round air battle, which is just the two dragons and two eagles for one round; and the ai may only be pulling the calc from that battle, without considering the main battle that necessarily follows it. or something else about the air battle system is screwing it up.

    Scenario 2
    save wherein I noticed the issue had occurred: 0_1535911726380_Arda_AI_StarkhornUnsafe1.tsvg

    an earlier autosave which the ai usually repeats the same behavior from 0_1535911719927_Arda_AI_StarkhornUnsafeBeforehand.tsvg

    The ai often leaves some nazgul with inadequate defense in starkhorn. (4-5 nazgul with a couple snaga, while they're adjacent to 15 eagles).

    Looking through the logs, it seems like for some reason the ai doesn't recognize that the 15 eagles adjacent to it could attack starkhorn, and pose the biggest threat. Several other provinces nearby also don't show the prospect of being attacked by 15 eagles; instead the logs just show the biggest threat being some minor attack by Rohan.. so it's improperly marking territories as safe, then landing expensive units there. So the problem is in the routine that gets sets of different nations possible attackers; it's omitting the eagles as eligible attackers for some provinces. There aren't even kamikaze provinces, they're adjacent, so not sure why it's missing them.


  • Admin

    @zlefin There are some issues with AA units not being considered properly when strafing. This impacts BFA much more than most maps since so many units have an AA type attack. I'll look at adjusting this.


  • Admin

    @zlefin This PR should resolve the issues: https://github.com/triplea-game/triplea/pull/4110

    I also made some tweaks to taking empty or lightly guarded territories in certain situations. The AI was trying to sometimes use a very expensive unit like a wizard to take an empty territory then realizing it didn't want to sacrifice that unit so then not attacking it at all.