AI Development Discussion and Feedback
My reoccurring concerns and applause for AI have consistently been the following:
1: Rather foolish or completely suicidal Allied placement and/or movement of transports while under heavy pressure. The poor/suicidal choices seem to escalate the more AI struggles. (The worst I've seen was in Pact of Steel China added WWII V3 where AI placed 4 undefended transports in range of an enemy sub having no chance of being neutralized before the sub could attack (and no apparent better option for the sub or forseen means of defense to arrive before the sub could attack).
2: in some maps, poor analytical choices in regards to how much or if at all to repair an industrial complex. I've mostly not kept track of which maps/versions apply to repair decision quality (however the map Pact of Steel China added WWII V3 seemed to make decent decisions regarding repair or lack of repair of an industrial complex [unlike most other maps] since they often just repair max damage despite the repair being either futile or a poor decision).
The poor placement/use of transports is by far #1 crippling the AI. I've noticed this issue often arises when France/Western Europe are well defended, Algeria isn't a good option and the allies will send undefended transports to attack Norway or other northern territories. I haven't read this whole thread and offer apology if this post is redundant as well as my lack of details regarding other maps. I play alot of various maps vs AI and have noticed these general patterns in various maps though have finally noticed a control group where more extreme aspects of both issues (good and bad) can be found in this single game attached (the map being Pact of Steel V3 China added) and hope the observation helps to either embrace and/or correct any scripts and apply changes to maps in general.
- list itemuse bad placement rd 4.tsvg
@pact_of_plastic Thanks for the feedback and save game. Here are some thoughts:
So the issue here is that the AI bought 4 transports and incorrectly anticipated killing the japanese sub off Alaska (this is essentially the AI not fully understanding v3 sub rules and that they can submerge before battle). Then after the japanese sub doesn't die, it has no safe place to put them since the US east coast is also exposed. So no real good option.
Yeah, the AI repair logic is very basic and essentially usually just repairs the full amount. This is something that just needs improved.
There are probably other cases of poor transport decisions but this one in particular is actually just a misunderstanding of v3 sub rules. If you have other save games showing examples please add them here.
Once that is merged, you can test with the latest pre-release but beware its not save game compatible with the current stable release.
Thanks for the timely reply and work on the issue fix. I look forward to it's full implementation and being able to save games with the fix in effect.
Here is another game where the US could have made a better decision. It seems the US took a VC or possibly national objectives as priority, despite projection of power and ojbectives being disabled. It's pretty clear the US xport should have taken undefended Australia instead of attacking a defended Borneo, and probably should have had plans to follow up by attacking undefended New Guinea, or attempting to take Borneo or East Indies. If not that strategy, the US could have sent in a fighter to aid the 2 infantry, consider a bombard in addition to the attack, as well and in turn protect it's xport with the rest of it's navy from the Japanese sub and it probably would have won the Borneo battle with New Guinea and Australia to follow up on easily. I understand the US was probably considering heading toward UK and didn't want to waste the movement, however in rd 6, they actually attempted an attack on Japan instead and they very well may have won that if they sent more power to Borneo and defended the xport in rd 4. It just seems they should have dealt with the whole situation a bit better. The US often bounces around and lacks focus. UK does it too and I'm sure it's hard as hell to script but in the end if they stayed focused a bit more they'd generally be more effective at least vs my play style. I really appreciate all the work you guys put into this game. Thanks a ton! us bad decision.tsvg
@pact_of_plastic Definitely an interesting choice by the US in this case. There are a few separate areas here around attacking Borneo vs Australia:
- The AI sees being in the Borneo sea zone as more strategic than down by Australia so that it has more options the following turn
- Borneo is worth more than Australia (4 > 3)
- AI believes its odds on Borneo are fairly good when it uses its cruiser to bombard
Now there is a bug where the AI aborts bombarding for v3 transport rules (transports having no casualty/defense) if enemy ships are within range. So the AI expects to attack borneo with 2 inf and bombard with the cruiser but the bug cancels the bombard leaving the odd behavior. I've put a PR to fix this: https://github.com/triplea-game/triplea/pull/5531
Ideally the AI would also use its fighter but this is more complex as the AI is overly conservative with landing on carriers and doesn't commit to moving its carrier til NCM so won't use the fighter since its can't guarantee its safe landing.
I think most human players go for Australia but Borneo with 2 inf, 1 fighter, and cruiser bombard is probably equal choice. The bombard bug will be fixed in the next release. The air is a much more complex problem is solve.
I've a game (derived from 270BC) with these main charateristics:
- There is a factory in every territory, capturable, able to place up to territory value (just your regular WW2 factory, except ubiquitous and granted). This factory is valued 0.
- Most units (all except 2, and half of the players don't have any of them) require a unit to be placed; the only thing this unit does is being required for placement, by most units; this unit is a costruction, you can purchase and place (at all effects, for the units requiring this unit to be placed, such unit acts exactly like a regular factory would), and all players start with one in a valuable territory.
- The unit not requiring any units to be placed (meaning only requiring those factories present in all territories) are absolutely or relatively weaker than the other units; so much that you would virtually never buy them, if they didn't have this placement advantage.
- There are no capitals.
The concept is, practically, the same as saying that you have many units you can place with factories, but you have also a few underpowered units that you can place with no factory in the territory.
For example, at the same price, you can place a att-def-mov=1-2-1 unit that requires a costly construction unit in the territory, for placement, or you can place a att-def-mov=1-1-1 unit that can be placed in any territories you owned since start turn (by factories that are simply present in each territory on the map).
The AI has 3 main problems with this game:
- It never purchases the unit required for most units to be placed (even in the case of those players that can only purchase units requiring such unit for placement).
- It way too much prefer purchasing the units that have no special placement requirement, if the player has any of them, even to the point of purchasing less other better units than what it could already place (as every player starts with such a required unit in a valuable territory), and often actually purchasing none of them.
- Eventually, it often starts stacking increasing quantities of units in some territories away from the enemy, never using them, unless enemy units get close enough.
Those problems are really very bad, and the AI gameplay is, at its current state, almost entirely broken.
@Cernel Correct. The AI doesn't currently support that because there are very few or no maps with those features.
Captain Crunch last edited by
wow now Cernel is sounding like Shulz amiright
AI - Can Purchase 0 move units: https://github.com/triplea-game/triplea/pull/5842
Any testing and feedback around this feature using the latest pre-release is welcome.
@redrum Sweet! At some point I would have ran into this limitation in my Warcraft map. Can you tell me upfront if the unit needs to have PUs included in the price or can the price also be only non PU resources?
Edit: And does the purchase mechanics just use the same logics when determining if a unit is worthy of purchase? And a no-mover is just worth less than a 1 mover?
@Frostion Good question. I believe the AI will essentially see the unit as "free" if it cost 0 PU as it divides its computed value by the PU cost which would essentially be infinity so consider it always the best defense option if its available. But I can't say I've ever tested it and there is a chance that 0 PU units could cause an error in some calculation.
Generally yes it uses the same logic but only considers buying 0 move units when trying to defend a territory. It uses a factor of 0.1 for 0 move units compared to a factor of 1 for 1 move units (essentially sees them as an order of magnitude worse) so will usually only buy them if they are the only option (or cost 0 PU). Examples are NWO/WaW where it will buy bunkers as they are isConstruction so is the only option after placing up to the factory value. Same with Dom NML where it'll buy trenches after purchasing 1+ move units up to the factory value. Napoleonic Empires it'll probably only buy mortella_towers if it happens to end up with 3 remaining PUs so would have no other options as they aren't isConstruction.
EDIT: Also it might be time to finally consider adding support for the AI to value other resources given we finally have a few maps that use multiple resources and seems like a few more in development. I'll need to try to dig up some of the initial thoughts I had around the best way to do it.
So digging through the chronicles of history...
Here was my original design around AI valuing non-PU resources (along with a bunch of related posts from @Frostion and myself): http://tripleadev.1671093.n2.nabble.com/AI-Development-Discussion-tp7585227p7590752.html
Here is the initial design:
- Find resource that I have the most of (A).
- Find unit cost in terms of A by converting all other resources (B, C, etc) to this resource using ratio of this resource to the most resource.
- Use this value instead of the PU value that is used today for finding unit efficiencies.
Current resources and amounts:
A - 50
B - 5
U1 - cost 1 B, very weak unit
U2 - cost 1 B and 10 A, stronger unit (3x 'power' of U1)
#1 purchase (50 A, 5 B | 1B is worth 10A)
U1 would be evaluated to cost 10A with efficiency (power/cost) of 1/10
U2 would be evaluated to cost 20A with efficiency of 3/20 (purchase this unit)
#2 purchase (40 A, 4 B | 1B is worth 10A)
U1 would be evaluated to cost 10A with efficiency of 1/10
U2 would be evaluated to cost 20A with efficiency of 3/20 (purchase this unit)
And so on, so the AI would most likely buy 5 U2's which is good in this case.
The AI’s bank has 52 PUs (A), 26 Manpower (B) and 13 Coal (C)
Infantry: 6 PUs/5 Manpower, power~7
Artillery: 8 PUs/2 Manpower/1 Coal, power~8
Tank: 10 PUs/1 Manpower/2 Coal, power~9
(power values are just approximate showing that units are in decreasing efficiency based on just PUs, tend to buy most inf then art then tank ignoring new resources)
#1 purchase (52 A, 26 B, 13 C | 1B is worth 2A, 1C is worth 4A)
Infantry would be evaluated to cost 16A with efficiency (power/cost) of 7/16
Artillery would be evaluated to cost 16A with efficiency of 8/16 (purchase this unit)
Tank would be evaluated to cost 20A with efficiency of 9/20
#2 purchase (44 A, 24 B, 12 C | 1B is worth 1.83A, 1C is worth 3.67A)
Infantry would be evaluated to cost 15.15A with efficiency (power/cost) of .46
Artillery would be evaluated to cost 15.33A with efficiency of .52 (purchase this unit)
Tank would be evaluated to cost 19.17A with efficiency of .47
.. 3 more artillery, I believe
#6 purchase (12 A, 16 B, 8 C | 1B is worth 0.75A, 1C is worth 1.5A)
Infantry would be evaluated to cost 9.75A with efficiency (power/cost) of .72
Artillery would be evaluated to cost 11A with efficiency of .73 (purchase this unit)
Tank would be evaluated to cost 13.75A with efficiency of .65
So it would end up buying 6 Artillery with remaining 4 A, 14 B, and 7 C. Though each time it will value B and C less since A is becoming worth more as it is spent too quickly as you can see in purchase #2. This makes infantry become more and more efficient in comparison to artillery since it has the lowest PU cost. The AI essentially tries to spend resources as evenly as possible but the unit set is weighted too much towards costing PUs in comparison to starting resources.
Follow up design (adding demand based):
The algorithm has relatively few steps based around resource supply but has lots of power due to the feedback loop in it. The feedback loop allows the AI to adjust valuation of resources as they are spent so at first a very sparse resource will be worth a ton but as the AI spends its other resources the very sparse resource value becomes less and less.
You bring up a good point about the available units. This algorithm so far is only a supply side algorithm as it only evaluates what/how many resources you have. To take the algorithm to the next level (more complex) you would then add in 'demand' ratios as well (how much of the resource is in the purchase options).
So if you had a very sparse resource (like B above) and it is needed for every unit available for purchase then B is really worth even more (you pretty much don't care about anything but B since its the limiting factor). The opposite is if you have say 100 units to choose from but only 1 cost some B then B isn't worth quite as much since you have lots of other options that don't need B.
Taking the above example with 1 unit that cost 10A and another unit (equal strength) that cost 1B. The average A cost across the unit set would be (10 + 0) / 2 = 5A per unit and B would be (0 + 1) / 2 = 0.5B per unit:
50A / 5A = 10 units worth, 1B / 0.5B = 2 units worth, so unit#2 cost 5 times unit#1 (50A) - no change to the above
Unit set skewed towards A: Now let's say we have 9 units that cost 10A and 1 unit that costs 1B. The average A cost across the unit set would be (109 + 0) / 10 = 9A per unit and B would be (09 + 1) / 10 = 0.1B per unit:
50A / 9A = 5.56 units worth, 1B / 0.1B = 10 units worth, so unit#2 cost 5.56/10 (0.56) times unit#1 (5.56A) - would definitely purchase unit#2 first
Unit set skewed towards B: Now let's say we have 1 unit that cost 10A and 9 units that costs 1B. The average A cost across the unit set would be (10 + 09) / 10 = 1A per unit and B would be (0 + 19) / 10 = 0.9B per unit:
50A / 1A = 50 units worth, 1B / 0.9B = 1.11 units worth, so unit#2 cost 50/1.11 (45.05) times unit#1 (450.5A) - would definitely purchase unit#1 first
You can see by adding this 'demand' ratio this then checks to see how much of the various resources are needed across the available unit set to take into account whether the unit set is 'balanced' across the various resources. It then adds more weight to resources that are needed the most in the unit set.
ok I finally downloaded the latest Triple A release 220.127.116.11.13066 on this awesome new computer running Windows 10 and I also read redrum's latest posts so I'm caught up on this thread when I was off the forum for a bit but anyways tonight I can finally battle redrum's nasty AI on the World War II Classic map again!
Not sure if I'll try to beat both the Allies AI and the Axis AI in one night but I'll get back to yous and who knows how long it's gonna take but is always fun!
Captain Crunch last edited by
already 1 loss to the Allies AI ... so this may take a while hehe
Side-note, FWIW, for the latest AI, you can check out the prerelease: https://github.com/triplea-game/triplea/releases
We could really use as many people playing through the prerelease as possible and reporting any bugs/problems that they encounter.
@LaFayette I just assumed the download at https://triplea-game.org/download/ had the latest AI upgrade ... I'm sure your link's AI update isn't much different from the 18.104.22.168.13066 version I am playing right now unless redrum knows of any tactical AI changes since 22.214.171.124.13066 but whatever this AI I am trying to beat is still gonna be tough! I'm not sure if I will test the AI again tonight or when I'll play during the week but I'll submit wins vs the Allies AI and Axis AI at some point
@Captain-Crunch There are some improvements in the pre-release that @LaFayette pointed to. If you are on Windows 10 then here is the direct link to the latest download: https://github.com/triplea-game/triplea/releases/download/2.0.17997/TripleA_2.0.17997_windows-64bit.exe
@redrum rofl thanks ok well I took 1 loss already but I do want to battle the latest AI so will install it and get back to you when I got a win vs the Allies AI and Axis AI ... so don't hold your breath because I may have to do many matches but I want to get it done over the week eh
@Captain-Crunch it works pretty well now, especially for ground wars. When i was getting back up to speed i noticed several weaknesses in its tactics, however.
Wouldn't want to spoil it for you though i'm sure you will find them for yourself before too long.
Anyway once you get the edge on AI i have found handicapping it allows you to really get back up to cruising altitude.
@ubernaut If you have feedback around a pretty recent pre-release version and the AI performance, I'd be interested in it. Feel free to post it somewhere or message me here on the forum. Some things are easier to improve then others but always welcome the feedback.