AI Development Discussion and Feedback


  • Admin

    This will be the new thread to discuss AI development and collect feedback. For historical purposes here is the old thread: http://tripleadev.1671093.n2.nabble.com/AI-Development-Discussion-tp7585227.html

    I'll keep high level information around the AI development in this first post for now. Please only post AI related discussion, testing, bugs, and questions in this thread. I always need lots of people to help test the new AI on various maps. If you do find a bug or poor AI play when testing please describe the issue and attach the save game in a post.

    Status

    • Rewritten all core phases (combat move, noncombat move, purchase, place, retreat)
    • Most testing has been done on revised maps and v3 maps (WW2 revised, WW2v3, NWO, etc)

    Backlog

    • Improve Performance on Large Maps
    • Consider Purchasing 0 Movement Units (Static Defenses)
    • Valuing Objectives
    • Consider strafing and defending against strafing
    • Consider V3 rule around subs not blocking naval movement
    • Consider V3 rule where fighters don't defend against subs
    • Rewrite bid purchase/place
    • Consider victory city points
    • Improve AA gun movement
    • Defending capital against multi-turn amphib attacks
    • Improve USA purchases on Great War
    • Improve unit production consideration to always use TripleAUnit.getProductionPotentialOfTerritory()
    • Add per map XML AI configuration
    • Add purchase 'value' for resources besides PUs
    • Transport mobile factories
    • Consider air/naval bases strategic value and purchasing
    • Consider value of saving at least 1 land unit when selecting casualties
    • Consider capital farming when determining whether to take back an allied capital
    • Add support for 'upgrading units' (consuming an existing units)
    • Consider interceptions and escorts
    • Consider value of canal territories and blocking enemy fleets
    • Consider kamikaze attacks and defending against them
    • Consider using cheap ships to block enemy naval attacks
    • Consider limited battle rounds (Civil War, Age of Tribes, etc)
    • Consider purchasing non-isInfra factories: https://forums.triplea-game.org/topic/892/ai-ignores-destructible-factories

    Bugs

    • (0 known bugs)

    ---Hard AI Overview---

    Summary

    • Mostly based on trying to optimize TUV gains and minimize TUV loses based on the battle calculator.
    • It does some strategic consideration in regards to where to move units towards and whether to be defensive if threatened.
    • It performs pretty well on maps based on revised/V3/V1 rules in that order
    • Should not crash on any map that is considered stable

    Combat Move

    • Check if capital is threatened and if so enable defensive stance (tends to attack less)
    • Find max number of my units that can attack each territory
    • Prioritize attack territories based on value
    • Loop through prioritized attack territories and see how many I can actually attack
    • Find max enemy counter attackers for each attack territory
    • Determine which attack territories can possibly be held
    • Remove any attack territories that aren't worth attacking (neutrals, low value, etc)
    • Determine which units to attack each attack territory with
    • Determine final sea territories for transports making amphibious assaults
    • Determine if I can defend those transports and if not then possibly abort that attack
    • Determine if I can hold my capital after attacks and if not then slowly remove attack territories
    • Actually send all combat moves to delegate to update game data

    Non-Combat Move

    • Find list of all allied territories that I can move units to and how many I can move to each one
    • Find units in move territories that can't move (allied, no movement, etc)
    • Separate out non-combat infra units (mobile factories, AA guns, etc)
    • Try to move at least 1 defender to each territory to block blitz attacks
    • Find max enemy attackers for each move territory
    • Determine which move territories can possibly be held
    • Prioritize territories to try to defend
    • Determine which units to defend each prioritized territory or if it can't be held
    • Determine strategic value for each move territory based mostly on distance to valuable enemy territories
    • Determine where to move remaining units to safe territory with highest strategic value
    • Determine were to move non-combat infra units
    • Actually send all non-combat moves to delegate to update game data

    Purchase

    • Simulate all phases until place is reached
    • Find all purchase options
    • Find all territories that units can be placed and how many
    • Find max enemy attackers for each place territory
    • Prioritize place territories that need defended
    • Determine best defender and purchase necessary amount for each prioritized territory
    • Determine strategic value for each place territory based mostly on distance to valuable enemy territories
    • Prioritize land place territories by strategic value
    • Determine whether to purchase AA for any land place territories
    • Purchase best land units combinations for prioritized land territories (based on available purchase options and enemy distance)
    • Purchase land factory if any 'good' candidates
    • Prioritize sea place territories based on strategic value
    • Purchase naval defenders, transports, and amphib units for prioritized sea territories
    • Purchase high attack and high movement (preferrably air) with any remaining production
    • Replace purchased land units with more expensive units with any remaining PUs
    • Purchase factory if any 'decent' candidates with any remaining PUs
    • Actually send purchase map to delegate to update game data and save map of where to place them

    Place

    • Place units based on purchase phase result or if no purchase map then try to place in best possible territories

    Code Organization

    • games.strategy.triplea.ai.proAI.ProAI - main AI class which extends AbstractAI and overrides many of the methods, orchestrates the 'Hard AI'
    • games.strategy.triplea.ai.proAI - has core AI phases and data containers
    • games.strategy.triplea.ai.proAI.logging - has logging utils and UI
    • games.strategy.triplea.ai.proAI.simulate - has simulate utils used to simulate combat move, battle, and non-combat move for purchases
    • games.strategy.triplea.ai.proAI.util - lots of utilities, matches, etc


  • my first post on this forum is to say hello and restate to the devs that I totally love battling the AI and I am here to follow the AI development!

    redrum knows that I await "tactical" improvements and I would appreciate update posts when tactical improvements are made to the AI so that I can test the updated AI and post my results. On the old forum I had 62 AI defeats submitted on the WWIIClassic map ... 31 defeats of the Axis AI and 31 defeats of the Allies AI

    I only post on 2 forums now (I used to post on a history forum but it shut down). basically I'm on 2 video game forums and also for fun I started posting 8 week updated "war/gaming" youtube video picks and that is all I do pretty much although I did make comments in game mod threads on the other forum but that forum was easy to find the threads because it was all on the front page ... but anyways I await AI updates here to test and now continue my war/game youtube song picks on this forum - which sometimes will be dedicated to a dev!



  • sorry for the long post but this is my "war/gaming" youtube song list to date (updated every 8 weeks) ... to be my personal gaming music to be burned to a cd at some point!;

    Power and the Passion by Midnight Oil;
    http://www.youtube.com/watch?v=6pKPNnk-JhE

    Games Without Frontiers by Peter Gabriel;
    https://www.youtube.com/watch?v=3xZmlUV8muY

    Hey Matthew by Karel Fialka;
    https://www.youtube.com/watch?v=O1Jb9aTSoSc

    Two Tribes by Frankie Goes To Hollywood;
    https://www.youtube.com/watch?v=K2QAMqTgPKI

    Nineteen by Paul Hardcastle;
    https://www.youtube.com/watch?v=oSGvqjVHik8

    Automatic Weapons of the World by Lederhosen Lucille;
    http://kristamuir.bandcamp.com/track/automatic-weapons-of-the-world

    War Pigs by Black Sabbath;
    https://www.youtube.com/watch?v=UogPgnYoJ0M

    The Warrior Song by The Global Military version;
    https://www.youtube.com/watch?v=0QjOdZCfGvM

    Sink the Bismark by Johnny Horton;
    https://www.youtube.com/watch?v=KecIdlEAKhU

    Tuskegee Airmen by A Band Called Pain;
    https://www.youtube.com/watch?v=iWUHqgsYL_s

    Ballad of the Green Berets by Barry Sadler;
    https://www.youtube.com/watch?v=m5WJJVSE_BE&index=1&list=RDm5WJJVSE_BE

    This pick goes out to the AI dev redrum!:
    More Human Than Human by White Zombie;
    https://www.youtube.com/watch?v=E0E0ynyIUsg

    Battle of New Orleans by Johnny Horton;
    https://www.youtube.com/watch?v=50_iRIcxsz0

    American Patrol by Glenn Miller;
    https://www.youtube.com/watch?v=odEQ0Di-tn8

    Buffalo Soldier by Bob Marley and the Wailers;
    https://www.youtube.com/watch?v=uMUQMSXLlHM

    This week we have a special edition double treat ... "retreating"!:
    I Ran by Flock of Seagulls;
    https://www.youtube.com/watch?v=iIpfWORQWhU

    The Tale of Sir Robin by Monty Python;
    https://www.youtube.com/watch?v=cFdgjYoBMIg

    This installment a little viking/thrash rpg music:
    Warrior's Quest by Ensiferum;
    https://www.youtube.com/watch?v=YyhSllQtQzs


  • Admin

    Awesome 🙂
    my 2 cents worth



  • @redrum so any "tactical" AI updates happening?? I have not had an AI to test in almost 6 months lol

    I know the list of "to do" for the AI is long but its a lot of map specific stuff but anyways this development thing has kinda slowed ... so I'm just posting to say I'm here and ready for battle!!


  • Moderators

    For the AI cheats, that really need some refinements, my suggestion is to firstly improve the "AI Bonus Income Percentage"; the three main items are, all of them necessary:

    • Having it given upon collecting PUs and any resources, based on what received, also from capture, NOs and whatever sources adding resources, not based on the PUs you have, because it currently keeps multiplying the saved income.

    • Having it detracted when capturing income from the AI (meaning that if it is 25%, I will only capture 80% of the income AI players have, upon taking capitals) (AI capturing AI would get all income; as above, AI capturing not-AI would be get the bonus, instead).

    • Having it increasing the AI placement abilities of the same percentage (very important, imo).


  • Admin

    @Captain-Crunch I have lots of ideas though I think the next thing on my list is improving AI bonus settings.

    @Cernel I'm going to start a separate thread on AI bonus settings to discuss this and lay out what I'm thinking. I strongly agree with your first point. I see what you are getting at for the second point though I don't think its really that important. For the third point, I haven't really thought about increasing placement limits by the same amount but that does make sense (otherwise the AI often struggles to spend the additional income). I'll have to think about that some and take a look at the code to see how easy that would be to do.



  • I think priority for targeting or defending VCs should definitely be at the top of the list. Basically where the AI does everything it can to capture VCs or prevent the enemy from doing so in a given round.

    Since many games have Victory conditions that are based on controlling a certain number of VCs at the end of the game round, it seems like a pretty important feature for the AI. There would also be some overlap there with prioritizing capitals and objectives (since those are often VC territories) so would be a nice place to start.


  • Moderators

    @Black_Elk said in AI Development Discussion and Feedback:

    I think priority for targeting or defending VCs should definitely be at the top of the list. Basically where the AI does everything it can to capture VCs or prevent the enemy from doing so in a given round.

    Since many games have Victory conditions that are based on controlling a certain number of VCs at the end of the game round, it seems like a pretty important feature for the AI. There would also be some overlap there with prioritizing capitals and objectives (since those are often VC territories) so would be a nice place to start.

    Maybe it could be hacked that the AI doesn't actually think about it, but when, at start turn, it has a major chance to get the needed VC and keep till end round, then it goes for it. I tend to think VC should not make you play very differently, until the last moment. Actually, VC driven victories got very little favour both with custom maps and players, as I believe most mapmakers and players just prefer to fight till someone is obviously the winner, for raw stats (in custom maps, often VC are totally absent or set at a value to just formalise an achieved victory, like we did in the new WaW (I believe any games should have some kind of victory conditions, even if not supposed to be ever reached, before the other side surrenders)).
    There is also the consideration that the game is usually about beating the AI, not being beated by it, so I'm not sure how many people would ever play on till seeing the AI actually winning by VC. Probably a bigger item would be the AI making the last stand for not losing by VC too early.


  • Moderators

    @redrum I think support for land and air transports (which is a subset of tech, but you can have it without tech development) should be in the list; I think that land transports are really cool (look at the trains of Domination WeltPolitik), except that they are not used much, maybe also because not AI supported (Feudal Japan is meant to be played with AI and has horse transports, as an assigned tech, while not having tech development).


  • Admin

    @Cernel said in AI Development Discussion and Feedback:

    @Black_Elk said in AI Development Discussion and Feedback:

    I think priority for targeting or defending VCs should definitely be at the top of the list. Basically where the AI does everything it can to capture VCs or prevent the enemy from doing so in a given round.

    Since many games have Victory conditions that are based on controlling a certain number of VCs at the end of the game round, it seems like a pretty important feature for the AI. There would also be some overlap there with prioritizing capitals and objectives (since those are often VC territories) so would be a nice place to start.

    Maybe it could be hacked that the AI doesn't actually think about it, but when, at start turn, it has a major chance to get the needed VC and keep till end round, then it goes for it. I tend to think VC should not make you play very differently, until the last moment. Actually, VC driven victories got very little favour both with custom maps and players, as I believe most mapmakers and players just prefer to fight till someone is obviously the winner, for raw stats (in custom maps, often VC are totally absent or set at a value to just formalise an achieved victory, like we did in the new WaW (I believe any games should have some kind of victory conditions, even if not supposed to be ever reached, before the other side surrenders)).
    There is also the consideration that the game is usually about beating the AI, not being beated by it, so I'm not sure how many people would ever play on till seeing the AI actually winning by VC. Probably a bigger item would be the AI making the last stand for not losing by VC too early.

    This is essentially what I plan to do. Have checks if the AI is either close to losing or winning in terms of VCs and only then take it into account.

    @Black_Elk @Cernel I think VCs actually aren't that important as most games either don't really use them or the game is already decided by the time they come into play (but there are a few that do actually use them especially in unbalanced map where say the Axis needs to try and win quickly). I think the bigger impact would be objectives as those make a major difference on lots of maps but are fairly complex as they very a lot across maps.



  • Perhaps something to be considered would be some sort of AI.properties where certain AI objectives could be laid out on a map by map basis without affecting human vs. human gameplay. I've heard it said in the past that AI shouldn't go into the XML (perhaps that isn't true anymore), but it might be nice for some maps to have something to manipulate that would increase the AI's valuation of a territory even if it cannot understand why that territory is valuable. Just some food for thought...


  • Admin

    @theredbaron Yep, I haven't decided if it would be in the game XML or a separate properties/XML file but it is already on the list as "Add per map XML AI configuration".



  • Yeah I guess what I was driving at would be some kind of VC related climax, where the AI would try to make a last stand (the way a human player might) before totally giving up the ghost haha. Right now they will usually just withdraw to preserve TUV, even if it's a capital territory being contested. Similarly with ships, the AI will often move away from home waters to try and save their existing naval TUV, even if doing so is ultimately futile, since without coastal production they have no way to reinforce themselves on the water or make use of their transports. Like, as sometimes happens, Japan will bounce away from Tokyo with their fleet only to try and pointlessly switch places with the USN somewhere off the coast of North America hehe.

    I tend to agree though, most who play vs the AI are in it for the ultimate stomp down, not to eek out a technical win. So there's a limit to how useful VCs can be as a motivator for the AI.


  • Admin

    It would be nice to see the AI value territories that controls canals, but maybe this is included in theredbarons proposal.


  • Admin

    @Frostion I added value canal territories to the list. Best case would be to just have some default valuing for all canal territories but also potentially provide the ability per map to add 'value' to strategic territories like certain canal territories.


  • Moderators

    Since land and air transports (like trains and paratroopers) are tech (but you can give them to any players, since start, while having no tech development), would that mean that they have to wait since the AI is able to handle tech?
    I've always believed that was wrong, as I think you should be able to say that something is able to trasport something without this having necessarily to be a tech (tho, it is easy getting around it, since you can just assign those techs since start to all, thus working just like normal unit attachment options).
    It's kinda lame to play a game in which there are paratroopers if the AI can't use them.



  • @theredbaron said in AI Development Discussion and Feedback:

    Perhaps something to be considered would be some sort of AI.properties where certain AI objectives could be laid out on a map by map basis without affecting human vs. human gameplay. I've heard it said in the past that AI shouldn't go into the XML (perhaps that isn't true anymore), but it might be nice for some maps to have something to manipulate that would increase the AI's valuation of a territory even if it cannot understand why that territory is valuable. Just some food for thought...

    That would be pretty cool. In a lot of instances you could accomplish quite a bit with just few critical tiles flagged as the "key to winning" on a given map. This might be better than making say all VCs a critical priority at all times, since, as was pointed out earlier, they are not always the most important thing going on. But some sea zones or territories are always going to be critical on a map (the choke points, or core production regions) so it would be cool if we could use them to push the AI into certain play patterns. It would also be awesome if you could set a threshold for these, so that the AI would try to hold them even if they are clearly outgunned. Like for Moscow or Berlin, or any capital that is adjacent to another land territory (the AI is better about stacking island capitals, since the they don't have a way to walk off haha.) Then map makers could tune the AI to the needs of the map, or try to adjust opening behavior by tweaking with the priority target territories, to see if they can make the machine play in different ways.



  • It's my 8 week updated war/gaming Youtube pick!;

    How Heavy This Axe by The Sword

    https://www.youtube.com/watch?v=m9KbmRTgigQ



  • It's my 8 week updated war/gaming Youtube pick!;

    Emerald Sword by Rhapsody of Fire (the song rox!!!!)

    https://www.youtube.com/watch?v=P2PDxwuphcA