Many suggestions are based on how I think certain mechanics work and thus there might be huge differences between how they appear to work for me and how they actually work. I beg your pardon for wrong assumptions caused by that in advance.
I will cover 4 major points of which I think the AI could be easily improved on. I will start with the ones that can be taken conclusions about the easiest when observing the game and will proceed to the more complicated and less comprehensible ones later.
Algorithms are written in pseudo-code, calling variables what I think is recognizeable as what is meant.
1. AI-Tax management
Current state:
There is no such thing as AI-Tax-Management right now. This can be easily seen when watching them play the game in observer-mode. All cities will run at the default of 50% or if they were captured from the player will stay at the value the player set them.
What this means:
Credits are a very useful resource to speed up the development of newer cities. Not reaping its full benefits is a big disadvantage.
Algorithm-suggestion on a city-per-city-basis:
Code: Select all
if(Science-Bonus*people_on_science + Mining-Bonus*people_on_mines + farming-bonus*people_on_farms + production-bonus*people_on_industry > tax-bonus*people_in_city)
{
Taxrate=0;
while(Income<0)
{
Taxrate+=5;
Recalculate_Income();
}
}
else
{
Taxrate=100;
while(Happyness<0)
{
Taxrate-=5;
Recalculate_Happyness();
}
}
Depending on wheter the cities economic-benefit from more happyness or more taxes is bigger, the city should either use:
a) the lowest tax where the empire does not run into deficit
or
b) the highest tax where the people are not unhappy
2. AI-Production management
General observations:
The AI seems to hold a set of multipliers to determine how much it needs what.
Those are for example:
food, minerals, happyness, pollution, expansion, build, combat, bio, mechanical, flight, etc.
Most of those seem to be calculated by algorithms. For example "combat" is higher if less units are there and gets lower the more units the AI produces.
"build", seems to be an exception. I think it is a static multiplier.
Every buildable item, by which I mean the entireity of buildings, advancements and unit-components, has a "strategy-score" which can be composed of any combination of compartments matching the global multipliers.
For example:
A Trooper consists of 0.5 bio and 0.5 combat.
A Mining-Refinery consists of 0.5 minerals and 0.5 build.
A research lab consists of 1.0 build
Those are multiplied by the multipliers and the city then builds whatever has the best ratio of highest value in relationship to building-time.
The exact corelation with the building-time is not clear to me but it was observable, that the AI avoids things that take too long to build.
Current state:
Right now almost all items have a sum of 1.0 in strategy-score. In my Mod and the thread about that, I've explained why that currently produces very bad results. With the current configuration the AI will, most of the time, just build cheap units and neglect it's economical buildup with buildings.
This makes them fall behind dramatically in the later stages of the game and it's more or less: Either you die in their early-game-unit-swarm or you kinda got the game.
Modifying the strategy-score-values to a) increase the importance of buildings and b) set different-tiers of unit-components apart from each other, as I have done in my Mod, already dramatically improves overall and especially mid- and lategame performance of the AI. It is the easiest and most efficient way to improve the AI right now!
Value-tweaking:
I think that some value-tweaking is unavoidable here because certain implications from the devs when using certain strategy-scores doe not work out as they should.
Note that stuff mentioned here already is in my mod. I also won't go over specific values but just mention where I think the kind of strategy-score is wrong.
Happyness-Buildings:
Strategy-score for happyness seems to be multiplied with something depending on unhappyness. This causes happyness buildings never to be build while the city is not unhappy. But since happyness always boosts either your tax-income, productivty or both, it would be stupid to not build it just because you are not unhappy. Thus the happy-score should be replaced with "build"-score for advancements and buildings affecting happyness.
Barracks-buildings:
Barracks right now scale with "build" and "combat". I disagree with that. They should be entirely scaled with "combat" and their score should be higher than that of all units. Building units without the extra ranks provided by barracks is a huge waste of ressources.
Certain Advancements:
The advancements you unlock by killing a Leviathan and an Aspioch don't have any score at all, resulting in the AI ignoring them, even if unlocked. This apparently is stupid and can easily be fixed by just adding some.
As a general tweaking rule, I have made sure that building-scores are higher than unit scores. But for handling that I have a better idea based on an algorithm I'll get to next.
Also I have tweaked unit-components to gradually have a higher score for the newer ones. I know that 1.4.2 introduced a mechanism with the same purpose but my tests leave me in doubt it works. However, since production time also is a massive factor, the AI still not building good units could also be caused by it's lacking economy caused by ignoring buildings too much.
Algorithm to dynamically determine combat-value depending on cities development-state:
Code: Select all
Combat-multiplier=Combat-multiplier*(Existing Buildings total production-cost+1/(Unbuilt available Buildings total production-cost+Existing Buildings total production-cost)+1
(+1 on both sides to prevent division by 0)
The multiplier for combat should undergo an additional modification based on the cities development state as follows:
The higher the value of existing buildings compared to the value of possible buildings is, the higher should the combat-multiplier and thus the likelyness of this city building units be.
This should result in new cities not trying to pointlessly build combat-units but focus on their economy first.
Example:
City 1 has a Mine(16), a Farm(16) and a Lab(24), which are all buildings currently available.
56/(56+0)=1
City 2 has a Mine a Farm and no Lab.
32/(32+24)=0.57, if it really wants units badly, it might still build them, but not as likely as City 1
City 3 only has a Mine...
16/56=0.29, very unlikely that this city will build units
City 4 has no infrastructure at all.
0/56=0, city will have to get some buildings first before considering to make units
3. AI-Tile-improvement-management
Current state:
Based on my observations it appears that tile-improvements to build are determined by nothing else but what kind of tile the Former is dealing with.
This clearly is a huge waste of potential as tiles which add production and research can tremendously boost a cities output.
According to the files in the "Features" folder, there is some kind of priority list in which order tile-improvemtns are built.
I've tried to give a conditional-increase in priority to groing fungus if the the fungus-improving advancements have been built. Not sure if it works but at least it doesn't crash upon starting. ^^ If it works as I think, I can post the modified contents of the according file.
However, I would definately add some algorithsms to change the tile-improvement behavior:
Algorithms in words:
For Grassland and Tropical Plains:
If in the whole empire no food is produced on a tile with less than 3 food and food-income is positive, then don't build another (useless) farm. Build instead:
One of the things that you would otherwise build on the non-tropical/grassland-plains. Those that passively boost the city like labs, factories, trading-posts or suburbs, if pop. There certainly also is a possibility to determine which of those the city would benefit from most.
For forrests:
If less than 33% of the empires non-farmer-population are mine-workers, then leave the forest there! This is especially meant to care about something like this: viewtopic.php?f=268&t=51307 where they chopped down their only sources of minerals.
For hills:
If more than 50% of the empires non-farmer-pouplation are mine workers, then don't build additional mines.
Yes, this case might be rare, but I've seen it happen before.
Build instead:
One of the things that you would otherwise build on the non-tropical/grassland-plains. Those that passively boost the city like labs, factories, trading-posts or suburbs, if pop. There certainly also is a possibility to determine which of those the city would benefit from most. Most likely factories in this case.
Fungus: As I said already: If the AI has all the fungus improving advancements built, it should replace all mines and farms with fungus but still consider that it doesn't need to have more food than pop or more production than it can spend.
4. AI worker-management
Worker management is perhaps the most difficult part for the AI and the player as well, of course. I think many things already work perfectly fine here. For example, I'm pretty sure that the AI does correctly pick the right amount of farmers and uses the best available tiles for farming.
However, the incident shown here:
viewtopic.php?f=268&t=51307, where the AI first chopped down all forests and then used more workers than minerals were available of course needs to be fixed.
One of the key things, however is the ratio between science and minerals/production. It is a no-brainer when minerals are scarce, then you obviously will just mine and sepend all minerals available and put the rest on science.
But in many circumstances there's plenty minerals and then it becomes a difficult question how many exactly you should mine and spend.
In this regard the algorithms need to consider diplomatic relations, military-strength and current state of research compared to the competition.
I would introduce a global and a local science-thirst-factor.
Let's say a factor of "1" means that in an avarage city the AI would aim for a 1:1:1 ratio of minerals, production and science
A factor of "2" means that it would aim for a 1:1:2 distribution.
Local affections of this factor could be similar to the "combat"-willingness but in addition consider the relationship of the science-bonus and the production-bonus as generated by existing buildings and a possible observatory.
Code: Select all
Local Science-factor=Global Science-factor*(Existing Buildings total production-cost+1/(Unbuilt available Buildings total production-cost+Existing Buildings total production-cost)+1
Local Science-factor=Local Science-factor*(Science-bonus+1/Production-Bonus+1)
(+1 on both sides to prevent division by 0)
As for the global science-factor it could start at 1 and be modified like this:
*2 if behind in science
*1/2 if behind in military
*1.5 for each faction with a good relation
*0.66 for each faction with a bad relation
and of course, if all techs are discovered it should be set to 0