AI Development Discussion and Feedback
-
@frostion Do you have an example map that I can test this with so I don't have to make a bunch of fake conditions/triggers?
-
@redrum You can test the AI’s ability to place given sea units with the latest v0.2.5 release of Iron War downloadable from GitHub. Germany gets a submarine:
<attachment name="triggerAttachment_German_Submarine-Pens_produce_submarines" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachment_German_Submarine-Pens_produce_submarines"/> <option name="purchase" value="Submarine" count="1"/> </attachment>
So the Submarine is by default delivered in the beginning of the purchase phase, and this can also be seen in history, but it is never placed. Not even after a few rounds.
I hope you are able to figure out what is wrong?
-
@frostion Oh I know what's wrong already as I looked at the code yesterday. I never implemented having the AI place triggered sea units (only land/air). I think because I couldn't find any maps that actually did that so decided not to tackle it until someone did which looks to be now
-
Ahhh, OK. Well, thanks for fixing the code
-
@frostion Here is the PR: https://github.com/triplea-game/triplea/pull/3542
Here is a screenshot showing the Germans placing the sub:
The one limitation is that the AI only considers the extra triggered units after its purchase. So Germany's turn 1 if it buys 10 units then it doesn't have anywhere that it can place the sub (which happens sometimes). Ideally, the AI would consider any triggered units before making its purchases but that's a more significant change and this should handle most cases.
-
@redrum Couldn't you hack this by designing a special unit that doesn't require a placement? (Just an idea)
-
@hepps Yeah that would work. There are probably other ways to do it as well like triggering extra factories, production per factory, etc before the place phase.
-
Can be tested in this pre-release: https://github.com/triplea-game/triplea/releases/tag/1.9.0.0.10558
-
Hurra! Nice update
-
@redrum Just messing around with xml, experimenting... it seems that Hard AI doesn't recognize a production facility unless it is an infrastructure. I changed a factory to have canProduceUnits, canProduceXUnits=-1, immobile land noninfrastructure construction. Humans and Easy AI can produce units, but Hard AI only sees an empty list of territories for placement (according to the log).
-
@alkexr Hmm. I know the AI won't purchase non-infra factories but thought it could at least see them as potential placement spots. I thought I tested that on 270bc which uses legions but could be wrong. If you have an example map to test glad to take a look.
-
@redrum Calling it a map would be a bit of an exaggeration... this is a copied version of a map of mine for all sorts of xml experiments. I think I restored all previous experiments before trying this. https://drive.google.com/open?id=1T8QwATSzqb1SQgaSbDeqrZWwF5n2afTQ
-
@redrum So now the AI also places movement 0 units? Because legionaire in 270BC can place only forts.
EDIT: Actually, the legio of 270BC would be a peculiar example, in that such unit should really receive no bonus (or maybe like a 0.05) to its value for being able to place units (limited to fort). It is rather the fort that should be valued a little bit more for being placeable by the legio, thus not only in cities (main example is placing some forts in Messana without a city in it). It would be really wrong if the AI would build significantly more legios due to the fact that they have some placement ability, in this case (really, it boosts the fort, not really the legio).
-
@cernel Yeah, I had it mixed up. I had tested 270bc to make sure the AI didn't place legions as factories since they can only place forts. When purchasing/placing factories, the AI doesn't have a sense of 'what units a factory can build' yet since it was mostly created around A&A maps. Whether a factory is infra shouldn't really matter but that limitation was put in since a few maps have regular units that can build a very limited set of units like legions and I didn't want the AI to see them as factories.
That being said, if it has non-isInfra factory units then it should consider placing units on them so I'll have to look at that.
-
@redrum That sounds great and would really mean a lot for future maps and how compatible the AI is.
-
@alkexr Here is the PR: https://github.com/triplea-game/triplea/pull/3645
I tested your LAB map before the changes where the AI doesn't place any units since cities are non-infra and then after the AI places normally just like if they were infra factories.
I also tested 270BC since that was the main map that had non-infra factories that caused issues. I needed to add some additional checks when purchasing/placing sea units so that each factory adjacent to a sea territory is treated separately instead of just adding their production together. Otherwise the AI thinks legions add 1 production to sea territories to produce boats.
This change also should help support maps that have different types of factories (think barracks and shipyard) adjacent to the same sea territory as the AI should now consider each of their production and what they can produce separately.
-
With 1.9.0.0.11638, starting "Red Sun Over China" with Hard AI, the AI always attacks Liaocheng (that I think is a good decision), but does it with insufficient forces (basically a suicide).
I guess the AI correctly sees that is a good attack, with an over +20 swing, but then fails to actually send everything it can, in the moment of actually moving.
On top of that, it also retreats to Tsinan, that is the worst decision.
Not including a savegame as I believe you can see it by just assigning Nationalist to Hard AI and starting.
Probably this is such an unconventional map that people will want to try it out with AI before playing for real, so this may be worth figuring out.
For info, you can (IMO should) go in Liaocheng with:
6 infantry
1 conscript
13 elite
3 light artillery
4 heavy artillery
6 armour
1 fighter
So I believe that's what the AI should do all games. -
@cernel I think the AI doesn't handle land canals properly yet. So it ends up not being able to construct appropriate routes to move all the units so some of them fail.
-
@redrum That is probably the case for not sending the fighter, but for the remaining part what happens when I test it, nor it should matter in any ways as, even if the AI would know nothing about canals, canals are negative, so when they are all open the AI doesn't need to know they exist (thus only case is the fighter blocked by the rail canals). Also was surprised that the AI (differently from the autoselect) correctly picks the heavy_artillery instead of the elite for land transport.
All the times I've tested it, the issue is that the AI is not sending all units from Tsinan and Lungkow, that I think has nothing at all to do with canals (the canals are not allowing you to jump the city; they are possibly impeding you to do that).
Also I really believe the retreat choice is a separate issue, that can be a problem also in case of correct movement but getting diced, as it seems the AI is unable to see the safest spot to retreat to. -
@cernel Yeah, retreat is a separate calculation and does have some logic to pick which territory though never optimized it a ton as the AI doesn't end up retreating that often (usually only when things go really badly). I'll take a look at this eventually. First I want to work on improving the route finder as that impacts PvP games on it then I'll work on improving the AI.