[BTS] AI Strategy - corporations

glider1

Deity
Joined
May 29, 2006
Messages
2,905
Location
Where animals hop not run
This would be the place to discuss the AI's behaviour regarding how it spreads and utilises corporations. These weakness as of Better BTS 0.36 seem to be real and practically solvable:

Comment by Roland Johansen:
"Maybe easier would be improving the AI's use of money to spread corporations. From my experience, the AI is not very capable at saving money to spread corporations. It spends its money to upgrade units and rush buy stuff (according to Bhruic) and nothing is left for using the corporate executives it has constructed. Bhruic taught the AI to not build an endless supply of corporate executives, but the heart of the problem is the AI's problem with saving money for spreading corporations."

Personally I have noticed these immediate practical issues of concern:
1) The AI will spread culture producing companies into the cities of it's rivals that are directly on it's borders. This helps the rival to gain territory sometimes as much as +15 culture per turn in certain cases at only a small negative impact on finances. This cannot be a good thing for the AI to do agree?

2) The AI will spread Aluminium Co into threatening rivals that have no aluminium but all the other required resources and tech's needed to build an airforce that can be used against it. Is that wise?
 
Maybe we need code like the spy code that attempts to generate a "target cash amount"?

And then do a prioritization of where to send cash based on the units that the empire has (ie, don't just spend it on the first unit you run into...)

...

What kind of future discount factor should the AI have? Ie, it has to decide if investing in a corporation is worth it at this point and time...
 
Hmmm ... we'd have to create some kind of budget planning or priority order for spending.

All unit upgrade spending seems to be done in CvPlayerAI::AI_doTurnUnitsPost which decides the priority order to call CvUnitAI::AI_upgrade based on some pretty simple rules (defenders > transports > other). This should be happening after settling executives it would seem.

A player's income for the turn is added in CvPlayer::doTurn, which (unless you're playing simultaneous turns ...) happens after units are moved. Looking at the order of things in a player's turn, it seems like the normal money flow is:

- get income (on turn i)
- cities (i)
- events (i)
- diplomacy (i)
- settle executives (i+1)
- upgrade units (i+1)
- get income (i+1)
...

Am I missing anything?
 
Well, that would be nice, and props to you if you get it down jdog. An AI budget allowence after or durring it's ugrade algorithm would probably work pretty well.

Also though, the AI needs to understand it shouldn't send culture corps to border cities. I think that's every bit as important (lordy I've seen the AI flip it's own city with creative construction). Also it needs to know not to send Mining Inc to a civ that is a threat. It's weird, because these are such simple principles, a novice player does them naturally, but teaching an AI these "simple" facts, seems sooo complicated.
 
Really, a global "how much is stuff worth" price might be worthwhile.

How much is a hammer worth? How much is a lightbulb worth? How much is a coin worth? How much is spreading a corp/religion to another city/civilization worth? How much is spreading a corp/religion to a specific city/civilization worth?

How much is food worth at city X? How much is culture worth at city X? How much is raw commerce worth at city X?

If I built a university at city X, how much increased worth could I squeeze out of the city?

But maybe that is pushing too hard.
 
Hmmm ... we'd have to create some kind of budget planning or priority order for spending.

All unit upgrade spending seems to be done in CvPlayerAI::AI_doTurnUnitsPost which decides the priority order to call CvUnitAI::AI_upgrade based on some pretty simple rules (defenders > transports > other). This should be happening after settling executives it would seem.

A player's income for the turn is added in CvPlayer::doTurn, which (unless you're playing simultaneous turns ...) happens after units are moved. Looking at the order of things in a player's turn, it seems like the normal money flow is:

- get income (on turn i)
- cities (i)
- events (i)
- diplomacy (i)
- settle executives (i+1)
- upgrade units (i+1)
- get income (i+1)
...

Am I missing anything?

@Jdog
Thanks for the clarification on the basic mechanics. I guess the priority order is dependent on circumstances too. If a civ is going for a peaceful victory condition with no big threats against it, unit upgrade priority could be lower than settling executives. However if there is imminent war, the priority would have to be the other way around.

Two questions:
1) is spending prioritisation a big alteration to the core code or is there already a prioritisation mechanism?

2) What about saving up the extra money needed to kick out rival corps? As yet I'm not sure if the AI is capable of doing this.

@Yakk
Yeah the question of worth would be nice if it could be sorted out via a deeper economic system modelled in game. A very simple example of this was the real time game "Rise of Nations" where the price of the basic commodities varied up and down in real time according to global supply and demand. It was fun.

Cheers.
 
2) What about saving up the extra money needed to kick out rival corps? As yet I'm not sure if the AI is capable of doing this.
You don't always WANT to kick out a rival corporation! If it is Mining Inc. or Civ Jewelers (hammers or gold), especially. Or what if you NEED that aluminum, food, or oil?
 
You don't always WANT to kick out a rival corporation! If it is Mining Inc. or Civ Jewelers (hammers or gold), especially. Or what if you NEED that aluminum, food, or oil?

That's true...but the AI's problem is that it doesn't seem to correctly save up the money to even have the option of doing so. Considering a typical human tactic is to send swarms of corporations (usually weaker/weakened ones) into foreign civs, that gets overplayed because the AI has little defense or counter-attack against it as currently designed. Right now it can only set to merc or SP to nerf the corps and can't easily buy its way out of what is effectively a strategy designed to bankrupt it.

I'd think that's a higher priority than getting it to properly evaluate the merits of each specific corporation within its empire, not to mention within each specific city within that empire.
 
@Jdog
Thanks for the clarification on the basic mechanics. I guess the priority order is dependent on circumstances too. If a civ is going for a peaceful victory condition with no big threats against it, unit upgrade priority could be lower than settling executives. However if there is imminent war, the priority would have to be the other way around.

Two questions:
1) is spending prioritisation a big alteration to the core code or is there already a prioritisation mechanism?

What I listed was just the order that the AI considers the different aspects of its empire, there's no explicit priority mechanism for where to spend gold. Many of the ways the AI can choose to spend gold have their own kind of ad-hoc considerations for whether the current consideration is important enough ... for hurrying buildings for example, there's a calculation involving AI_buildingValueThreshold for whether it's worth speeding up production by x number of turns and the building is only hurried if the cost is < 1/3 the AIs current gold. If a granary costs less than 1/16 of the AIs gold they just do it.

There is one built-in function which has the potential to play a role in determining whether the AI should spend money on non-crucial things (ie upgrading offensive units when they have no war plans) ... CvPlayerAI::AI_goldTarget. If the AI is near its target, spend away! The target is pretty high though.

Unit upgrade decisions seem to be the greediest right now ... there are priorities as to which units get upgraded first, but if the AI had enough gold to upgrade a unit it will. There is no inclination to stockpile gold or otherwise hold back on spending under any circumstances in the decisions in CvPlayerAI::AI_doTurnUnitsPost ... in war this may make sense, but in peace it's kind of ridiculous to spend down to your last dime on upgrades. This seems like the most important spot to improve.

2) What about saving up the extra money needed to kick out rival corps? As yet I'm not sure if the AI is capable of doing this.

It certainly doesn't attempt to save up money for any particular expenditure, this included. This could be added to CvPlayerAI::AI_goldTarget under particular circumstances to get the AI to try to pull in more money and with other changes to try to limit unnecessary spending could bring better results.
 
Back
Top Bottom