My journey of improving the AI
Posted: Tue Jan 06, 2015 12:26 pm
I was curious if some people might want to know what exactly this voluntary-fan-developer-guy is doing with his privilege of having access to the source-code and what you can probably expect to come out of it.
So I decided to make this thread, where I talk about the things I'm experimenting with and will try to keep the intrigued reader informed.
Since talking about everything I've done so far would be a little lengthy, I'll, as of now, limit it to what I've done yesterday.
I had been experimenting with a different way of how tile-improvements are selected to be built and continued with that yesterday.
I redid a lot of what I tried before and the result was comparatively satisfying.
The AI now knows to build suburbs and pollution-processors and it values forrests higher, especially as Terra Salvum. If someone builds a farm now depends on their amount of farmers compared to total population.
There's still an issue with higher-yield-fields not having a higher priority for their top-yield being improved. This sometimes results in mines on food-resource-hills and habitats on the top of mountains.
But I believe that should be easy to fix by giving improvements a slightly higher value if they are on a field that already has a high amount of this improvement.
Since the hardest part of the game for players and AI alike, probably is managing an economical crisis, I put some effort into trying out crisis-management-techniques for the AI.
These include: Lowering Taxes, reducing pollution by using fewer factory-workers, an emergency-program for unhappy cities where it's either: build buildings or focus on research but don't just spam more troops. First get out of the crisis. For even more imergent cases, where a city is unhappy and has to put most of their population to farmers just to stay alive, I've allowed the AI to make use of razing.
Since some of the things for these emergency-plans affect population-management I also had another look at that. The hardest part about it, clearly is balancing out mines+workers vs. scientists. I changed how miners are assigned. Should be much more efficient now. However, it is hard to come up with a good algorithm to find a good balance between production and research. Ideally it should consider all sorts of stuff:
Need for military, unbuilt buildings/advancements, if there are techs left to research(ok, that's a no-brainer), how efficient the mining-sources are, what the pollution looks like.
So basically imagine: You have Population-Farmers, and now you determine how many of those you want to use as scientists. The rest will be used as miners and workers. (Luckily there's no need to find an algorithm to balance miners vs. workers, there is one in place that already is really, really, good)
This rest can be anywhere between "0" and "all".
You have access to all the data above. How would you go about it? Or just imagine you are the player and play the game (duh!) how do you determine it in this case?
My tests were quite pleasing. I let "very easy" AIs play against "very hard" aliens. They all survived the initial rush and the eclipse and built up their economy afterwards. However, they are technological behind to what you are supposed to have to face "very hard"-Messari-Invasion. This probably is mostly because my current production vs. science-algorithms are too much in favour of production... but then again this seemed necessary to stop the early aliens.
"Very easy" AI is best to test the crisis management since morale-boni of higher levels usually mean: There won't be any crisis for them to cope with.
Once very-easy-AI can deal with the Messari on "very-hard" alien-aggression, I'll be very confident.
Btw. the biggest mistake of the unaltered AI in crisis-management with aliens around is that they always try to replace their formers without making sure they can keep them alive. Just changing it to: "Require at least cities+1 military-units before making formers" already meant a dramatical improvement.
The second biggest was to apparently ignore Aliens in their counter-designs. Having them consider the aliens right away and thus using Flamethrowers meant another big leap.
My goals for this evening are:
Fix the ignorance about high-yield tiles when selecting improvements.
Finding a competent algorithm to evaluate production vs. science.
Fix a bug I must have made somewhere with building-selection. For an unknown reason there is some circumstance, that can make the evaluation go negative despite me thinking that all factors are positive. oO.
So I hope this was an interesting read for everyone interested. Please share your thoughts and let me know if you want to see more updates like that.
Hints about science vs. production management are much appreciated!
So I decided to make this thread, where I talk about the things I'm experimenting with and will try to keep the intrigued reader informed.
Since talking about everything I've done so far would be a little lengthy, I'll, as of now, limit it to what I've done yesterday.
I had been experimenting with a different way of how tile-improvements are selected to be built and continued with that yesterday.
I redid a lot of what I tried before and the result was comparatively satisfying.
The AI now knows to build suburbs and pollution-processors and it values forrests higher, especially as Terra Salvum. If someone builds a farm now depends on their amount of farmers compared to total population.
There's still an issue with higher-yield-fields not having a higher priority for their top-yield being improved. This sometimes results in mines on food-resource-hills and habitats on the top of mountains.
But I believe that should be easy to fix by giving improvements a slightly higher value if they are on a field that already has a high amount of this improvement.
Since the hardest part of the game for players and AI alike, probably is managing an economical crisis, I put some effort into trying out crisis-management-techniques for the AI.
These include: Lowering Taxes, reducing pollution by using fewer factory-workers, an emergency-program for unhappy cities where it's either: build buildings or focus on research but don't just spam more troops. First get out of the crisis. For even more imergent cases, where a city is unhappy and has to put most of their population to farmers just to stay alive, I've allowed the AI to make use of razing.
Since some of the things for these emergency-plans affect population-management I also had another look at that. The hardest part about it, clearly is balancing out mines+workers vs. scientists. I changed how miners are assigned. Should be much more efficient now. However, it is hard to come up with a good algorithm to find a good balance between production and research. Ideally it should consider all sorts of stuff:
Need for military, unbuilt buildings/advancements, if there are techs left to research(ok, that's a no-brainer), how efficient the mining-sources are, what the pollution looks like.
So basically imagine: You have Population-Farmers, and now you determine how many of those you want to use as scientists. The rest will be used as miners and workers. (Luckily there's no need to find an algorithm to balance miners vs. workers, there is one in place that already is really, really, good)
This rest can be anywhere between "0" and "all".
You have access to all the data above. How would you go about it? Or just imagine you are the player and play the game (duh!) how do you determine it in this case?
My tests were quite pleasing. I let "very easy" AIs play against "very hard" aliens. They all survived the initial rush and the eclipse and built up their economy afterwards. However, they are technological behind to what you are supposed to have to face "very hard"-Messari-Invasion. This probably is mostly because my current production vs. science-algorithms are too much in favour of production... but then again this seemed necessary to stop the early aliens.
"Very easy" AI is best to test the crisis management since morale-boni of higher levels usually mean: There won't be any crisis for them to cope with.
Once very-easy-AI can deal with the Messari on "very-hard" alien-aggression, I'll be very confident.
Btw. the biggest mistake of the unaltered AI in crisis-management with aliens around is that they always try to replace their formers without making sure they can keep them alive. Just changing it to: "Require at least cities+1 military-units before making formers" already meant a dramatical improvement.
The second biggest was to apparently ignore Aliens in their counter-designs. Having them consider the aliens right away and thus using Flamethrowers meant another big leap.
My goals for this evening are:
Fix the ignorance about high-yield tiles when selecting improvements.
Finding a competent algorithm to evaluate production vs. science.
Fix a bug I must have made somewhere with building-selection. For an unknown reason there is some circumstance, that can make the evaluation go negative despite me thinking that all factors are positive. oO.
So I hope this was an interesting read for everyone interested. Please share your thoughts and let me know if you want to see more updates like that.
Hints about science vs. production management are much appreciated!