Dom Pedro II
Modder For Life
1. First and foremost: It's time to conquer the beast. The AI_bestTech function has been allowed to stand for far too long. I dunno how Firaxis screwed up this function so much while getting it right for other things.
There should be an AI_techValue function or something like that, and the only thing that the AI_bestTech function should do is loop through the techs calling the AI_techValue function for each and then picking the one with the highest value.
Why? Aside from the fact that it's neater, it a AI_techValue function would let modders easily compare the tech values of two techs, or allow the AI to measure how significant it's tech lead or tech lag might be. In fact, it would be even better if the AI_techValue function was itself made up of smaller functions perhaps measure the military value, economic value, etc. independently allowing for even more precise comparisons in other parts of the code. Sure, we could create new functions that do essentially the same thing and leave AI_bestTech untouched, but this would be redundant.
2. More XML tags to control AI behavior. There's already tags to help the AI decide what units, buildings, projects etc. to build, techs to research, and civics to adopt, but I think we can go beyond those.
There's a couple of reasons: One is that the more values that are exposed to the XML, the more the unwashed masses can easily tweak AI behavior to try to find that magical sweet spot instead of leaving it to the SDK gods to hand them down a new DLL every now and then that changes value X from 10 to 20 or something. Not that I'm saying all values have to be pulled from the XML since this would not be feasible, but certainly there are a number of important multipliers and divisors that could stand to be read from the XML.
The second is that one of the advantages the human player has over the AI is the human ability to take a lot of different values and create an abstraction. For example, when considering whether a city is in danger, the AI doesn't seem to take into account the real risk the city faces. If I move a Warrior against a city defended by Infantry, the AI will still register a threat... now, the AI will probably send somebody to kill the Warrior, but how many units will drop what they were doing to go defend the city instead of defending a place that's actually in jeopardy? But simply comparing base strengths would be insufficient, and running through all of the potential max combat strengths of defenders and attackers would be ludicrous. So having some kind of AI city attack value to compare against an AI defense value would allow the AI to make smarter decisions without adding needless layers of precision and processing time.
Other tags for civics, for example, could modify the AI's behavior. If a civ happens to be running a strong building set of civics, maybe it should be less inclined for war? Or if its running a strong military set of civics, more inclined? I mean, an AI's plans will influence its civics choices, but should maybe its current civic choices influence its plans?
3. Centralized planning is something that I think is sorely needed. Human players set goals and then find the cities or units to accomplish those goals. The AI, on the other hand, examines on a unit-by-unit or city-by-city basis and sees what needs doing. This tends to lead to redundancy (sending two units when only one is needed), indecisiveness (units running back and forth not committing to any one course of action), or important goals simply not being done at all.
I was playing a WWII mod the other day where I had an advancing tank army moving on the enemy capital. I expected the AI to reinforce the city (which they did), but then on the next turn, pulled nearly as many units out of the city. Only to move them back in again on the next turn. Why? I wasn't moving on any of their other cities. This was it. This was where the showdown would be. If they'd kept those defenders when I was finally in position to attack, I might've been forced to give up the campaign. But instead I attacked on one of those turns when they shuttled troops out of the city again and took it.
There should be an AI_techValue function or something like that, and the only thing that the AI_bestTech function should do is loop through the techs calling the AI_techValue function for each and then picking the one with the highest value.
Why? Aside from the fact that it's neater, it a AI_techValue function would let modders easily compare the tech values of two techs, or allow the AI to measure how significant it's tech lead or tech lag might be. In fact, it would be even better if the AI_techValue function was itself made up of smaller functions perhaps measure the military value, economic value, etc. independently allowing for even more precise comparisons in other parts of the code. Sure, we could create new functions that do essentially the same thing and leave AI_bestTech untouched, but this would be redundant.
2. More XML tags to control AI behavior. There's already tags to help the AI decide what units, buildings, projects etc. to build, techs to research, and civics to adopt, but I think we can go beyond those.
There's a couple of reasons: One is that the more values that are exposed to the XML, the more the unwashed masses can easily tweak AI behavior to try to find that magical sweet spot instead of leaving it to the SDK gods to hand them down a new DLL every now and then that changes value X from 10 to 20 or something. Not that I'm saying all values have to be pulled from the XML since this would not be feasible, but certainly there are a number of important multipliers and divisors that could stand to be read from the XML.
The second is that one of the advantages the human player has over the AI is the human ability to take a lot of different values and create an abstraction. For example, when considering whether a city is in danger, the AI doesn't seem to take into account the real risk the city faces. If I move a Warrior against a city defended by Infantry, the AI will still register a threat... now, the AI will probably send somebody to kill the Warrior, but how many units will drop what they were doing to go defend the city instead of defending a place that's actually in jeopardy? But simply comparing base strengths would be insufficient, and running through all of the potential max combat strengths of defenders and attackers would be ludicrous. So having some kind of AI city attack value to compare against an AI defense value would allow the AI to make smarter decisions without adding needless layers of precision and processing time.
Other tags for civics, for example, could modify the AI's behavior. If a civ happens to be running a strong building set of civics, maybe it should be less inclined for war? Or if its running a strong military set of civics, more inclined? I mean, an AI's plans will influence its civics choices, but should maybe its current civic choices influence its plans?
3. Centralized planning is something that I think is sorely needed. Human players set goals and then find the cities or units to accomplish those goals. The AI, on the other hand, examines on a unit-by-unit or city-by-city basis and sees what needs doing. This tends to lead to redundancy (sending two units when only one is needed), indecisiveness (units running back and forth not committing to any one course of action), or important goals simply not being done at all.
I was playing a WWII mod the other day where I had an advancing tank army moving on the enemy capital. I expected the AI to reinforce the city (which they did), but then on the next turn, pulled nearly as many units out of the city. Only to move them back in again on the next turn. Why? I wasn't moving on any of their other cities. This was it. This was where the showdown would be. If they'd kept those defenders when I was finally in position to attack, I might've been forced to give up the campaign. But instead I attacked on one of those turns when they shuttled troops out of the city again and took it.