AI behavior with the "replaces others with this flag" flag

Predator145

Prince
Joined
May 22, 2020
Messages
443
Powerplants in stock game have the "replaces others with this flag" flag in the editor. Every time you build a new powerplant, the old one automatically gets sold off. Does the AI make the mistake of loop building powerplants in stock game? Imagine the AI building a Coal Plant first, then replacing it with a Hydro Plant, then a Solar Plant and then a Coal Plant again, crippling its Industrial and Modern performance.

This is very hard to test. But knowing how half baked stock game is, this major late game performance sabotage error may be present.

I've just tested how the AI behaves with heavy perfuming via Flintlock's patch. Coal Plants and Solar Plants have no requirements and cost 0 shields. Both are perfumed at 10000. The AI in the WW2 Pacific scenario instantly build them in their cities with Factories. It seems to value both the Coal Plant and Solar Plant equally, not factoring in pollution. Some cities chose Coal, some chose Solar first.

But here's the kick in the teeth. Both got built right after another, triggering a loop. Of course things are accelerated with the heavy perfuming and 0 shield cost. But this makes me think this error exists in stock game as well. It's just that the AI is too busy building other stuff to often be harmed by it.

I've decided to not use this flag in any of the scenarios I play. Now I see why many hate it. In stock game, a city could have up to 8 production bonus (x4) with fresh water and 6 bonus (3x) without. You could achieve the same numbers by scaling down each production boosting improvement and let them accumulate. Here's what I do:
Factory: +2, maintenance 3, 240 shields, pollution 2 , does not require Iron to not gimp AI's unfortunate with RNG.
Coal Plant: +1, maintenance 1, 120 shields, pollution 2, requires Factory and Coal.
Hydro Plant: +1, maintenance 2, 120 shields, no pollution, requires Near River and Factory.
Solar Plant: +1, maintenance 2, 160 shields, requires Factory
Nuclear Plant:+1, maintenance 2, 160 shields, no pollution, can meltdown, requires Factory, Fresh Water and Uranium
Manufacturing Plant: +2, maintenance 3, 320 shields, pollution 2, requires Factory

All of them are heavily perfumed, esp the Factory and Coal Plant, making sure that the AI industrializes ASAP. Shield investments, pollution and maintenance are not a heavy departure from stock game.
 
This is very hard to test. But knowing how half baked stock game is, this major late game performance sabotage error may be present.
With the Flintlock mod such a test in Debug mod could be done with the original C3C game as a base. Give all civs all techs that are needed to produce all powerplants in the game. You can even preplace one of the better plants in a city and have a look into that AI city, if there is still a chance (point value) that the AI replaces the better plant with a not so good plant. If the AI gets into a loop, the chance of production the not so good plant should be greater than zero. Unfortunately at present I don´t have the time to do such a test.
 
Both got built right after another, triggering a loop. Of course things are accelerated with the heavy perfuming and 0 shield cost.
The perfume is definitely distorting the AI's behavior here. Perfume is a pretty blunt tool, the points are simply added into the AI's judgement of the building/unit's value. Also they're added at the very end so the AI can't weigh or override them in any way. (I did that so that they'd work in a consistent way. Initially I inserted perfume in the middle of the AI's evaluation but then I discovered the AI was applying a weight to that intermediate value which was making the value of perfume vary unpredictably.) That means if you add a huge amount of perfume to something, the AI will always choose to build it if possible.
 
Testing stock game will be extremely time consuming as the AI doesn't put any priority to timing sensitive improvements like anti-corruption, production, pop growth enablers and fortification esp during war time. It's very easy to prevent the AI from ever industrializing and growing past size 12 by playing them against each other from industrial age onwards. They will go to war with each other for peanuts.

It takes a massive perfume value to override the desire for the war time AI to make units instead.

Even if stock game conditions aren't broken, they're far from ideal.
 
I don't think you can draw conclusions about behaviour in the stock game, from a modded game where there's no difference between the Coal and Solar Plants (other than their pollution-value). Reducing pollution in itself is certainly not an AI priority (how often have you seen a Pop20+ AI-metro surrounded by multiple polluted tiles, because that AI did not prioritise researching Ecology/ building Mass Transits?).

I suspect that the AI might be smart enough to recognise that a more expensive (/less polluting) powerplant is 'better' than a cheaper (/more polluting) one, simply because of the higher shield-cost, and in the stock game, there is a substantial difference in shield-cost between the 4 powerplants. But the Coal Plant (160 shields) is available a lot earlier than both the Hydro (240 shields) and Solar Plants (320 shields), so will likely be built first — if any plant is built at all.

However, I do not know whether it will ever go on to build one of the more expensive plants afterwards (apart from 'accidentally' via the Hoover GW). Certainly in my games (mostly at Emperor–DG, mostly on Standard Continents/Pangaea Maps, mostly aiming for Domination/ Space/ Diplo), I cannot recall ever capturing any powerplant more advanced than a Coal Plant.

I suspect that this is, as you say, due to the AI-Civs' tendency to spend the late Industrial and Modern eras pretty much permanently at war (frequently due to the MPPs that it will sign at the drop of a hat, with anyone), either as a runaway AI, or an increasingly desperate defender against that runaway — which means that it will be pouring all its shields and gold into Tanks/ModernArmor and Infs/TOWs/MechInfs (and/or whipping/drafting its population to death under Fascism), rather than investing in the late-game techs and infrastructure.
 
Last edited:
I suspect that the easiest way to use that flag is to have the Improvement that is being replaced go obsolete in the same turn (this also opens up the possibility of multiple uses for this Flag.)
 
I suspect that the easiest way to use that flag is to have the Improvement that is being replaced go obsolete in the same turn (this also opens up the possibility of multiple uses for this Flag.)
That way you can have things city fortifications require maintenance while being replaced with newer ones. Still, the AI would need to keep paying maintenance on an obsolete improvement until the new one has been constructed. But Flintlock's next patch may change that.
 
That way you can have things city fortifications require maintenance while being replaced with newer ones. Still, the AI would need to keep paying maintenance on an obsolete improvement until the new one has been constructed. But Flintlock's next patch may change that.
I think that would be beneficial and truthful, especially for fortifications.
 
One more thing about this flag. In base Conquests, don't the power plants only offer a production bonus if a factory is in a city? So, if a factory were to be sold off, or destroyed by bombing, or if you get hydro plants from the Hoover Dam but there's no factory in a city, then you don't get the production bonus. How is this triggered from the biq, then? Does that mean if an improvement has a building prerequisite, the prerequisite must be present for the improvement to work? Or does it only apply to improvements that have both a building prerequisite, and have the "replace all" flag? This would need some testing. We know that a building won't work if it doesn't have required resources, but will it also not work if it doesn't have required prerequisite buildings?
 
One more thing about this flag. In base Conquests, don't the power plants only offer a production bonus if a factory is in a city? So, if a factory were to be sold off, or destroyed by bombing, or if you get hydro plants from the Hoover Dam but there's no factory in a city, then you don't get the production bonus. How is this triggered from the biq, then? Does that mean if an improvement has a building prerequisite, the prerequisite must be present for the improvement to work? Or does it only apply to improvements that have both a building prerequisite, and have the "replace all" flag? This would need some testing. We know that a building won't work if it doesn't have required resources, but will it also not work if it doesn't have required prerequisite buildings?
It's only for improvements with the "replace" flag. Research labs generated by the Internet works just fine without libs and unis.
 
I'm a bit late to the thread, but what is this perfuming thing?
 
A feature of Flintlock's patch to increase the AI's likelihood of building something. When jacked to the wazzoo, even worthless things in the AI's eyes will be built.
I'm a bit late to the thread, but what is this perfuming thing
 
I suspect that the easiest way to use that flag is to have the Improvement that is being replaced go obsolete in the same turn (this also opens up the possibility of multiple uses for this Flag.)
I apologize for the necro bump, but it's only been a couple of months so not too bad... Anyhow, you can only make building go obsolete by a tech advancement right? Or is the some technique I am unaware of that makes the improvement being replaced go obsolete in the same turn as you mentioned? I have been experimenting with "attribute buildings" similar to the Worldwide mod. It would be very interesting if once one building with this flag was built the previous building with this flag was obsolete and couldn't rebuilt again.
 
Certainly in my games (mostly at Emperor–DG, mostly on Standard Continents/Pangaea Maps, mostly aiming for Domination/ Space/ Diplo), I cannot recall ever capturing any powerplant more advanced than a Coal Plant.
Followup on this: in my current game (Carthage, Large Random-Continents, DG), I actually found a Solar Plant in one captured Ottoman town (Osman had made it into the Modern Age shortly before I finished conquering him, and I think he got Ecology as his freebie).
 
I apologize for the necro bump, but it's only been a couple of months so not too bad... Anyhow, you can only make building go obsolete by a tech advancement right? Or is the some technique I am unaware of that makes the improvement being replaced go obsolete in the same turn as you mentioned? I have been experimenting with "attribute buildings" similar to the Worldwide mod. It would be very interesting if once one building with this flag was built the previous building with this flag was obsolete and couldn't rebuilt again.
This is a still hot thread as Flintlock's patch keeps opening up new possibilities. But for now only tech advancements can obsolete city improvements. There is still no way to prevent the AI from being stuck in a loop.
 
This is a still hot thread as Flintlock's patch keeps opening up new possibilities. But for now only tech advancements can obsolete city improvements. There is still no way to prevent the AI from being stuck in a loop.
I liked the concept of "attribute" buildings that were used in the Worldwide mod. The ability to give each city a unique flavor based on available resources instead of following the same ole usual build sequence. I created several improvements similar to Worldwide, but if the AI is just going to loop build maybe I'll ditch them. Instead, maybe I can do some kind of reverse capture the flag like with resource shipments like Age of Imperialism and CCM2. The unique "attribute" buildings was more interesting to me as a concept, but if doesn't work well with the AI then I don't know.

Plus, maybe with supply shipments, it can increase the Naval aspects of the game that I really like. Age of Imperialism is a great scenario.
 
One way to combat that behavior is to increase the bonus incrementally with each flagged building as the game progresses. This will at least reduce the incidence of the computer overbuilding the flagged improvements. Also, that mod was made with the philosophy that the game is there for the player's enjoyment, not the AI's. I understand the desire to level the playing field and reduce AI disadvantages, but ultimately I didn't want to cure the headache by decapitation and that is why things like armies, attributes, etc. were left in. The upside is that different mod configurations give people the opportunity to play or develop mods to their taste. Perhaps Flintlock or another intrepid modder will tackle this behavior in the future.
 
Top Bottom