1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[BTS] AI Strategy - war

Discussion in 'Civ4 - Better AI' started by glider1, Jun 23, 2008.

  1. Yakk

    Yakk Cheftan

    Joined:
    Mar 6, 2006
    Messages:
    1,288
    *nod*, the AI still doesn't go exponential enough in the modern era. I find that I tend to have a handful of specialized high-production cities (that use mines and the like), which then build wonders that leverage that high production to make it ridiculous production (national epic for a unit factory, ironworks for a wonder factory, etc).

    The AI is horrid at city specialization.

    Part of this is that the 5th AI shouldn't value the tech that highly any more.

    The value of trading away a tech to an infinite number of clients should be roughly the value of researching the tech. But that isn't how the AI values technology.

    Suppose we revalued technology to be worth (1/2^n) times it's lightbulb value, where n is the number of empires that have the technology.

    So if you research a technology worth 1000, you can trade it away for 500 gold to the first person, 250 to the 2nd person, 125 to the 3rd person, etc.

    With a large number of other players "on side", you could tech up using only their gold paying for it -- they would also get the technology, however.

    In the case that two civilizations know different sets, we could use the average of what each civilization thinks it is worth.

    Dunno.

    Yes -- I think the AI's resource value code is still stuck in the pre-corporation model, where a 2nd resource isn't worth as much as the 1st by orders of magnitude.
     
  2. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    I'm not sure about that. The AI does seem to value resources that offer a lot for your corporation higher. I have experienced that an AI would ask more for a resource once I have more cities with the corporation that benefits from that resource. The AI would renegotiate the deal and I'd have to pay more.

    It could of course be a coincidence, but I really expect there to be some valuation formula for the AI where the value is dependent on the number of cities that hold a corporation that benefits from the resource.

    I'm not sure whether the valuation is correct, but do remember that there are many costs to a corporation: a great person, various technologies that need to be beelined, gold and production for spreading the corporation and most of all gold per turn for maintaining the corporation.

    Of course, once you've installed the corporation(s), there can be great benefits, but there is a significant investment. If buying resources from the AI's is expensive, then that cost plus the corporation maintenance could become too much to make it interesting. Now there is a benefit for the seller of the resource (gold per turn) and a benefit for the buyer (more corporation benefits). It would require a significant analysis whether both parties benefit similarly.

    By the way, the rest of Psyringe account of his game is interesting to read. I never use the vassal option myself because I don't like how it is implemented in the game (hard to get rid of a vassal) and also because I don't like the way the AI handles it. It seems that the AI cannot really adjust its empire for the extra maintenance cost of the vassals. I don't think it understands that an empire cannot maintain an unlimited number of vassal cities without going bankrupt. Also a single humongous army from a huge AI would be far more effective that 6 small armies from an AI + 5 vassals. There is no coordination of forces in the second case. And I guess that it is really too hard even for the betterAI team to make the various AI's coordinate their forces.
     
  3. Psyringe

    Psyringe Scout

    Joined:
    Dec 7, 2001
    Messages:
    3,394
    Location:
    Berlin, Germany
    Regardind the resource valuation: It's definitely difficulr to design a resource valuation formula that is working well. If there already is one in effect, I'm curious about its workings.

    What seemed odd to me was that the AI would continually offer gold together with the corporation-relevant resources, for one resource of mine. Since I already had 12 spare dye resources, and was trading dye to anyone who wanted it, the resource had about zero value for me. Of course, the resources that the AI traded to me had about zero value for the AI too. So I was trading something that wasn't worth much for me for something that wasn't worth much for the AI that traded it away. The "seller-value" of both resources was almost zero - seen from this perspective, the trade appears fair, and there's no need for the AI to throw in extra gold (something that the AI really *could* make use of instead of trading it to me).

    Of course, this "seller-value" isn't the only relevant factor in the equation, there's also the point of "buyer-value": How much is the traded resource worth for the civ that gets it? Personally I'm still uncertain how these *should* be valued though, it's certainly complicated.

    Side note: Keep in mind that I was playing a gigantic game with 34 civs - the size of the map and the number of resources might influence the availability and actual value of resources to a point where formulas that work well in stock setups can't adjust to it any more.

    Regarding the coordination of AI war efforts: There is this "We would like you to attack city x" option in diplomacy. If this is actually working, then it might be possible to hook into the respective functions in order to have an AI master coordinate war plans with his vassals. That's, however, supposing that the feature *does* indeed work, and I'm not so sure about that.
     
  4. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    As far as I know, Civ uses a purely buyer-based valuation. So the value of a resource is purely based on the use it has for the buyer. I guess, the AI didn't have your dyes yet, so they were very valuable to them as a luxury resource. Resources used purely for corporations (which is true for any 'second' version of a resource) aren't valued by the game as highly as a happiness increasing resource. So that's why the game values the first version of a resource higher than the second for the buyer.

    I don't know if the xml-values for various variables were adjusted for this gigantic map. Many, many things in civ are map size dependent. The increase in production/money/research/culture per corporation-resource for instance is also map size dependent.

    Even if this would work well, then still 6 independently controlled forces don't work as well as 1 centrally controlled force. Even if they were controlled with human intelligence. That's one reason why one strong army is better than 6 weaker forces.

    For example: one strong force might lead to three dangerous 30-unit SOD's. The six individual armies would individually only hold 15 units which might also be divided over several groups making them easy to defeat individually. Next to that 4 of these 6 groups hold obsolete units because these AI's haven't upgraded there troops yet because of lack of money while other civilisations in the vassal-group have left over money.

    The AI just doesn't go for optimal individual power. It always accepts a surrender even if the rest of the conquest could make it a lot stronger in the long run.

    It's all just the result of the increase in efficiency with size.
     
  5. Psyringe

    Psyringe Scout

    Joined:
    Dec 7, 2001
    Messages:
    3,394
    Location:
    Berlin, Germany
    Yep, but I'm not sure whether the valuation is working well. As an extreme example: Let's say I'm trading cows to a civ that doesn't have them yet, but that also has no unhealthiness in its cities. In return I want silver (which I already have) for my Mining Inc corporation, which I spread to five cities, all of which have a fotge, factory, power plant, and throw an ironworks and hero epic for good measure (actually it just occurred to me that I don't know whether hammers gained through corporations are affected by those buildings, I'll have to check that). Asuming the AI trades as I expect it to, is it really a fair trade if the AI gives me the silver and some gold per turn on top of it for my health resource that currently changes nothing in its empire?

    Granted, that's an extreme example and I don't even know whether it actually reflect current AI behavior. And I didn't yet take into account the costs to establish and maintain a corporation (a good point that you raised). But it shows that resource valuation may be worth discussing. :) However, we should probably do that in another thread, since it's not really on-topic here ... (my fault, I kind of got carried away when I wrote my report).


    The map size definitions are from a mod which, as far as I can see, extrapolated the values from those of other map size. Some may have been missed though and yet some might need some tweaking. For example, I already tweaked the research speed - in my previous games on XXL maps with 34 civs, space ships were regularly built in the 1700s. The scaling of the research speed simply didn't take into account that with 34 civs, there is a lot more tech trading (even without tech brokering) - it's much more likely that an AI can trade it's new tech for three or four others, which basically multiplies the benefit of each beaker put into researching it.

    Anyway, I'm digressing again. ;) What I'm saying is that my game setup is a work in progress and that it's very possible that some values still have to be adapted. I'd be very grateful for suggestions. :)

    Many values autoscale (for example, I think I got only 10% of the standard effect of corporation resources ... which might actually explain why the AI gave them so little value ...), but the autoscaling isn't always perfect.
     
  6. Roland Johansen

    Roland Johansen Deity

    Joined:
    Apr 29, 2003
    Messages:
    4,292
    Location:
    the Netherlands
    I also don't know whether the BetterAI programmers wish to improve the valuation algorithms for the resources. It could be considered an AI-issue...

    I just made a remark on this issue because it's just not so clear on how to improve them. Your other issues are much clearer as it is for instance clear that an AI shouldn't take another vassal when it would bankrupt it. Resource valuation is more subjective and I wanted to make that clear. For example, in civ3 resource valuation by the AI was based on the amount of usefulness the resources offered to the nations that were trading. This meant that a civilisation with 3 times as many cities had to pay three times as much for a resource because the usefulness of the resource effected 3 times as many citizens. While I consider this a perfectly fair mechanism, it was frowned upon by a majority (or a loud minority) of the community. Typically the human player was the one with the bigger empire and didn't think it was fair that they had to pay 3 resources to get 1.

    What is fair? It's very hard to answer that, not only because it's hard to calculate the values of all the effects of a corporate resource, but also because people don't have the same notion of fair.

    I think I have seen that mod, but wasn't it created before the BTS expansion was created? Maybe it was later updated. I don't know exactly what you mean with autoscale. I do know that various modifiers are based on the same xml-values, so if you change the value to balance some element in the game, then you're immediately balancing some other elements too. Sometimes that is a good idea, sometimes these modifiers shouldn't be exactly the same. But it is a known fact that this game doesn't perfectly scale with map size (and game speed).

    For the corporate resources: If in your game on the superhuge map with 34 civilisations, you'd expect that the corporation founding civilisations would control twice as many resources as on a huge map (at the moment of founding corporations which is a moment when some civilisations have already been destroyed), then I'd think that the effect of a single entity of a resource should be halved both in production (hammers, culture, gold, science) and in upkeep (gold upkeep in the cities). The valuation by the AI should also be halved (as the effect is halved).
     
  7. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Psyringe:

    Thanks for the very detailed report and analysis! It's very helpful to get that kind of detailed report back and you highlighted several important questions.

    On the question of stranded units on small islands, there are two related issues both surrounding the behavior of transports:

    1. Picking up surplus troops stranded on islands: My idea here is that if the AI has many idle transports hanging around, some of these transports could search for stranded troops. The AI will send empty transports to cities with enough extra troops to pick up, but it can take a long time for them to get around to it. The AI simply doesn't pick up troops off empty islands yet at all.

    2. Large transport flotillas stuck on islands: The AI is programmed to pull all its transports back to its main area, but there are a couple of ways they can get stuck. This one is tricky, I believe what is happening is that the AI ships are staying to try to pick up a unit that isn't getting on the ship because it's filling in on city defense. I'm still not sure yet though.
     
  8. Lone Wolf

    Lone Wolf Deity

    Joined:
    Dec 4, 2006
    Messages:
    9,891
    Is there a special code for units in recently captured cities in resistance? It apppears that the attacking stack in a resisting city moves out of the city only after the resistance ends, which can be not the optimal behaviour.
     
  9. Cybah

    Cybah Emperor

    Joined:
    Jun 22, 2007
    Messages:
    1,480
    Good point. The AI is indeed waiting too long to conquer the next city.

    edit: ...but I think it is some sort of healing behavior.
     
  10. Lone Wolf

    Lone Wolf Deity

    Joined:
    Dec 4, 2006
    Messages:
    9,891
    Well, here's some suspicious stuff (nothing modded except the terrain graphics and a custom Japanese leader).

    I am at war with Qin. My slightly outdated Rifles are advancing to Nanjing. The situation on the previous move was the same as now:

    Spoiler :


    His defences at Nanjing, as you can see, are weak (12 str Grenadier, Infantry at 7.2, Knight at 5.7 and a cat to be exact); meanwhile, here's his troops at recently conquered from the (weak) Khmer Angkor Thom:

    Spoiler :


    Ankgor Thom had been captured not on the previous turn, so Qin's Infantries should have some movement points yet.

    He can reach Nanjing with his infantries and reinforce it - Angkor Thom is in no danger - yet on the previous IBT he made no movements, and I razed the city. He agrees to peace next turn.
     

    Attached Files:

  11. jdog5000

    jdog5000 Revolutionary

    Joined:
    Nov 25, 2003
    Messages:
    2,601
    Location:
    California
    Lone Wolf: Do you still have a save for this behavior by any chance?
     
  12. armand453

    armand453 Chieftain

    Joined:
    Jul 25, 2007
    Messages:
    45
    There is something I've never understood in the AI behaviour when it is in defense.
    When the AI is completely inferior in power, sometimes the AI has all it cities gladly in research as if it don't care of what it will happen to it.
    In those conditions does the optimal behavior is not to change all cities in producing troops?

    Armand.
     
  13. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,788
    Location:
    Where animals hop not run
    It so much depends on context. Sometimes the AI needs to race to a required defensive tech like machine guns. If you have save's of this behaviour you have seen, it would be great to post them.

    Cheers.
     
  14. Yakk

    Yakk Cheftan

    Joined:
    Mar 6, 2006
    Messages:
    1,288
    Turn on cheat code. Alt and mouse over the territory.

    The AI strategy is probably "catchup" (I think that is the name) -- it considers itself so far behind, tech-wise, that it's only chance is to pump out research and hope not to be attacked until it catches up.
     
  15. BobTheTerrible

    BobTheTerrible Just Another Bob

    Joined:
    Jan 5, 2003
    Messages:
    927
    Location:
    Middle of Nowhere
    I was thinking, humans have that "Why don't you attack..." option for AIs in a mutual military struggle. Do the AIs make use of this amongst themselves? It could be useful to have the AI coordinate attacks with other AIs, but it might be difficult to say which cities should be attacked by whom (if there's a city in a good spot, one AI might not want the other to get it). Same goes for research and vassals, I guess (why don't you research...).
     
  16. glider1

    glider1 Deity

    Joined:
    May 29, 2006
    Messages:
    2,788
    Location:
    Where animals hop not run
    Yeah that is really high level stuff. That "why don't you attack" option actually works? It never has for me but could be wrong.
    At this stage what exactly happens in the AI's mind? Once the warplan is in effect and war declared, units form into stack's and other AI missions, and they decide an appropriate target location from a unit perspective. This is information is not fed up the chain to a "higher brain" is it?

    In the case where other AI allies or vassals join in, they will help the master with the war but not strategically. Units will flow into the area of warfare and decide targets locally. Occasionally, these cooperative efforts actually do coordinate quite well, but there is no "high level" commitment to it.

    In other war games like "Rise Of Nations" a few years ago, you could point and click a location on the map, then go and tell your AI partners to move troops to that location. They would do that without question and then begin attacking at that spot whatever they could find. Unfortunately, it didn't work well because the AI troops would get distracted along the way with other threats, and the whole initiative would dissolve away and very few if any troops would arrive at the scene.

    Cheers.
     

Share This Page