AI military strategy can we improve it?

Discussion in 'Civ5 - General Discussions' started by nokmirt, Jan 28, 2011.

  1. UWHabs

    UWHabs Deity

    Joined:
    Oct 10, 2008
    Messages:
    4,791
    Location:
    Toronto
    The real issue is the tactical AI needs help. My game, I got declared on by an AI (and their friend). Friend had no real troops to worry about, but Saladin, who DoWed me, actually came with a decent mix of guys. They came in, and set up around one of my cities. And then, proceeded to die. One by one. My 2-3 Keshiks plus the city itself was all that I needed to completely annihilate their army. They had a solid 6-8 troops, and not a bad mix of catapults, longswords, knights, pikeman, and so on. But they just never found a way to get set up, and actually bombard the city. I'm not sure where in the AI the flaw lay - the makeup of the army? positioning? reinforcements? when to retreat? When to run in guns ablaze?

    It definitely needs some tweaking. It was a semi-surprise DoW, and I really didn't have all that many troops in the area (of course, due to the keshik's movement and promotions, I reinforced it within about 3 turns), but they easily should have been able to take a city due to my weak defense but couldn't.
     
  2. MkLh

    MkLh King

    Joined:
    Jul 18, 2008
    Messages:
    905
    Location:
    Finland
    A combat bonus doesn't make AI any smarter or more interesting to fight against. It's just another AI bonus and there are plenty of them already. Besides it's probably worse than most as you must forget all you have learned from units relative strength as you climb up levels - in Deity spears can't kill horsemen anymore, suddenly warriors are a threat to your swords etc, everything needs to be relearned. If Deity is too easy, it's better to boost up bonuses there already is - for example, let the AI tech faster so that you will meet units that are naturally more powerful.
     
  3. esemjay

    esemjay Prince

    Joined:
    Jan 24, 2008
    Messages:
    386
    Location:
    USA
    I agree. In Civ4, the AI's control of troops was limited to:

    • Am I near a target?
      • Yes: Can I win this fight?
        • Yes: Let's do this!
        • No: Go pillage something!
        • Maybe: Let's do this!
      • No: Am I near a friendly unit?
        • Yes: Move onto that tile.
        • No: Move randomly.


    Simplification, yes... but not much of an exaggeration. It just melded better with Unlimited Units per Tile. I am under the impression that the AI is using a similar formula this time around, and they did a poor job of lateral grouping.

    What the AI needs is to be able to "associate" units A,B,C,D,E and F with other unit G as a "group." Then, issue orders to those units as a "Grouping of Units" or "Army" rather than a "Cluster****" of units running around with their own agendas.

    Then, the AI needs to be able to set goals for what it wants to accomplish. Something beyond attrition, because this is what causes the AI to fail.

    "I want to stop them from building tanks!" -> Destroy my oil wells with paratroopers.
    "I want to take a city!" -> Bring enough artillery to do the job, and don't put your units right up against a city that could own their face in 1 turn each.
    "A bunch of injured units from Japan!" -> Kill the strongest one, with the weakest health, first... just to maximize the ratio of effort->payoff.

    SOMETHING to make a declaration of war with the AI mean something other than, "Time to farm promotions" or "How am I going to feed 2 million prisoners???"
     
  4. nokmirt

    nokmirt Emperor

    Joined:
    Feb 14, 2009
    Messages:
    5,088
    Location:
    Iowa USA
    Then it should be redone. It should have been done right the first time but now they should know, and work to make the AI better. Teach it first how a human plays, and then program the data.
     
  5. Nares

    Nares Emperor

    Joined:
    May 2, 2006
    Messages:
    1,631
    It could very well be freezing up against poor combat odds.

    The standard tactical AI is programmed not to readily sacrifice units in general, and possibly not at all when invading.

    Two fixes for this are to add the offensive weight tag to the attrition "tactics," and to adjust those weights and many other weight modifiers.

    In fact, just adding the offensive or defensive weight modifiers to several of the tactics can produce some worthwhile results.

    Even with the changes I made to the tactical AI, I still felt a need to reduce many of the combat bonuses, in particular ones which the human player can use more effectively. Immediately put on the chopping block were the Oligarchy and Himeji Castle "promotions," as well as the Morale promotion from the Honor social policy tree and the Discipline promotion from the Heroic Epic.

    I'm not surprised the standard AI refuses to engage against 2:1 odds or worse; I wouldn't either. Of course, it makes the AI look pathetic when it continues to dance around in your territory as per the military strategy AIs demands, but refuses to actually engage in combat as per the tactical AIs hesitance to sacrifice units.
     
  6. lschnarch

    lschnarch Emperor

    Joined:
    Oct 7, 2010
    Messages:
    1,296
    Which would make the point of critisizing the AI (and the "programmers" behind it) even more valid.

    In the posting which you quoted, the AI was unable to attack an undefended city, although approaching it with a decently build combat group.
    Cities have been made even stronger with the last patches.

    Which in turn means that - if your theory would be correct - the AI is more and more helpless in determining what to do.

    This seems to be a quite good example of how not to create the AI, and even if you would have done so, how not to try to "fix" things.

    Bottom line: the more patches are released, the more one get's the impression that Firaxis is completely lost. They really don't know what they have to do, as they don't understand the genre, nor do they understand the game itself.
    What they do is to tweak a number here or there and then hope for the best. After all, it might be the solution, no?

    And I have even not yet mentioned the fact that with each "patch" so far they have managed to break things which were working before:
    * food display in city view
    * starvation caused by engaging the city manager
    * roads to city states no longer recognized
     
  7. Celevin

    Celevin King

    Joined:
    Jul 21, 2010
    Messages:
    919
    I wonder if I have ever lost any city that I've held for at least 20+ turns prior, even on Deity.
     
  8. lschnarch

    lschnarch Emperor

    Joined:
    Oct 7, 2010
    Messages:
    1,296
    This is a very interesting and helpful information. What was your point?
     
  9. Celevin

    Celevin King

    Joined:
    Jul 21, 2010
    Messages:
    919
    It's just an observation on how bad the AI is.

    (I'd also like to note that losing a city in Civ5 hurts much more than losing a city in Civ4 or Civ3 for numerous reasons)
     
  10. builer680

    builer680 eats too much Taco Bell

    Joined:
    Dec 14, 2010
    Messages:
    525
    Yeah, the Happiness your empire gains from losing the City, the maintenance you don't have to pay anymore on Buildings in that City, and the subpar tiles that you already have everywhere else anyway in your empire... those are really tough to lose.

    I guess the only real "hurts much more than 3 or 4" loss when you lose a City in Civ 5 is the inflated Social Policy costs if you ever annexed it, or if you founded it yourself.

    If it had Wonders in it, that wouldn't be any different from losing it in 3 or 4.
    If it had access to Resources you otherwise wouldn't have, that wouldn't be any different from losing it in 3 or 4.

    If it occupied a strategic position, it would be different from 3 or 4... if strategic positioning mattered when facing the AI. Unfortunately, it doesn't matter, because the AI will usually find a way to mill around outside ANY City long enough to get potshot to death, no matter what strategic position the City may or may not have.
     
  11. nokmirt

    nokmirt Emperor

    Joined:
    Feb 14, 2009
    Messages:
    5,088
    Location:
    Iowa USA
    I just had a similar situation in my Ancient Greek scenario. I am playing as Sparta and Mycanae attacks me with this huge army 4 hoplites, 4 warriors, 2 archers. I had one lone hoplite in the city. Probably 300 Spartans, anyway the AI puts an archer next to the city, and they start massing their hoplites and warriors around the city. First thing I did was bombard their archer and attack with my hoplite, destroying it. In the meantime, I had one warrior from the south I sent up. Sparta was building a hoplite. I ended up holding the city I lost one warrior and one hoplite, when they left I had been fighting with two hoplites using them in attacks when the oppurtunity presented itself. They lost 3 hoplites, 2 archers, and 2 warriors, before they retreated with about 5 units that were left. It truly was crazy. I thought I was history, finished. The AI just does not press the advantage. They had the city surrounded on three sides, but never attacked it with their infantry. If they had they would have won easily.

    The AI needs to be more aggressive when attacking a city that is defended by a unit. I have had them take cities that where undefended, and I could not get troops there soon enough. I had one instance when this happened in another game. But I got my army there and counterattacked, taking my city back and destroying their army, including two cannons that I seperated with an obvious move and defeated them in detail.
     
  12. kosak

    kosak Chieftain

    Joined:
    Dec 3, 2010
    Messages:
    19
    This kind of decision making is what a human player does although we usually also think about about how the battle will affect the outcome of the war as a whole (ie sure I can win this but is it necessary in the big picture?). This exactly why 1upt messes up the ai. It's easy to do the instant calculation on whether to attack or not but a lot harder to figure out whether it's a good idea in the long term.
     
  13. nokmirt

    nokmirt Emperor

    Joined:
    Feb 14, 2009
    Messages:
    5,088
    Location:
    Iowa USA
    We need an AI that understands hex warfare. 1upt does not mess up the AI, whoever programmed the AI messed up the AI.
     
  14. Nares

    Nares Emperor

    Joined:
    May 2, 2006
    Messages:
    1,631
    Six edits to three tactical AI XML entries can remedy this particular problem, though I agree that cities are too strong for the AI to handle currently.

    The problem is worse with stacking, as the AI always compares against the strongest defender.

    At least with 1UPT the AI can stumble into the "right place at the right time."

    Though the real problem here is a complete inability to contemplate sacrificing units when invading. Attrition combat is apparently only enabled for defensive warfare, despite being less of a necessity given the heavy slant towards friendly territory combat bonuses. Not engaging in attrition combat completely undermines the AIs production bonuses.

    If someone wanted to supply me with the tactical AI XML file I could run through more specific edits that I made. I've uninstalled and have no intention of re-installing.
     
  15. kosak

    kosak Chieftain

    Joined:
    Dec 3, 2010
    Messages:
    19
    Well yeah. I was referring to the ai in its current state not. Not ai in general.
     
  16. esemjay

    esemjay Prince

    Joined:
    Jan 24, 2008
    Messages:
    386
    Location:
    USA
    It's not the 1UPT that kills the AI. It's the fact that humans understand concepts like "Reinforcements" and "What am I trying to accomplish right now?" Each unit belonging to the AI basically runs around autonomously, with no real reason other than "Stack on Friendlies, Fight with Enemies." They need to expand the scope of how the AI thinks.
     
  17. lschnarch

    lschnarch Emperor

    Joined:
    Oct 7, 2010
    Messages:
    1,296
    It actually is the 1upt rule which kills the AI.

    Under such a rule, the AI has to understand grouping units horizontally and to take the fabric of the battle theatre (hex-wise) into consideration.
    As you correctly pointed out, the AI units at least very often seem to move and behave in a completely autonomous way. What unit A does is not linked to what unit B does, thus making them not work in combination.

    Now, due to 1upt, any movement of unit A does have implications to how the whole assumed "group" of units would work. It may block hexes for other units, although positioning these other units there would have been more advisable.

    Sure, one can say: "Then we have to make the AI understand all these concepts". Unfortunately, this requires much more sophisticated algorithms and much more computing power.
    As computing power at any given moment is limited, this means longer calculation times.
    And we already face the fact that many people are complaining about long interturns.

    The conclusion seems to be obvious: even if it were possible to create a decent combat AI, the needed calculation times would be unbearable for a big part of the players.
    As I've said elsewhere, 1upt exposes the weaknesses of the combat AI, whereas a stacked system would at least cover such weaknesses.
     
  18. qwerty25

    qwerty25 Prince

    Joined:
    Mar 24, 2010
    Messages:
    399
    I really do wonder why the AI fails at combat soo much. There are games out there that use 1UPT and work alright. Is it really that hard to program it with the resources that Firaxis has???
     
  19. Nares

    Nares Emperor

    Joined:
    May 2, 2006
    Messages:
    1,631
    I know from reading the XMLs that the AI is poorly setup to handle invading.

    It cannot consider unit attrition when attacking; unit attrition is only enabled for defending as per the XML file. With friendly territory bonuses being so large, practically any post-Ancient era AI invasion is dominated by this complete failure to consider attrition combat.

    I really wish I had the XML file to demonstrate exactly how poorly they limited the tactical AI. It's frustrating to see 1UPT blamed when I know from having looked through the XML files that, completely independent of 1UPT, the AI cannot handle invading in any practical sense of the term, and would be just as crippled with these same XML settings even under a stacked units ruleset.

    Once again I ask that someone supplies me with the tactical AI XML file. It would take me all of 30 seconds to point out some minor edits that make the AI relatively dramatically more capable.
     
  20. MkLh

    MkLh King

    Joined:
    Jul 18, 2008
    Messages:
    905
    Location:
    Finland
    Depends on what you want it to be. If we look only at the tactical level, 1UPT resembles classical board games like chess. These can be computerized very well. There is one major difference though: while in chess the player only moves one of his pieces on his turn, in Civ5 it's possible to move any number of units during one turn. Because of this it may be impossible to calculate multiple turns into future like chess programs do as the number of possible combinations of moves would mathematically explode very fast. But it should be possible to look one turn ahead and find a decent combination of moves so that the AI would not move its catapults to positions where they are instantly killed on the next turn etc. It wouldn't be enough to beat a skilled human player with equal strength, but it should be much better than what we have now.
     

Share This Page