Skyre Noktis
Warlord
- Joined
- Apr 28, 2009
- Messages
- 271
Some observations and constructive criticism...
1. AI treasury management is insane
When I first started doing AI testing, I noticed that AI research rates all took a nosedive shortly after turn 200 (normal speed). At first I thought they must have been crashing their economy somehow (too many units?), but that turned out not to be the case. Even the bigger empires could research at around 40-50% and still turn in a net profit.
After some digging around, I found the source of the problems: AI_getGoldTreasury in CvPlayerAI.cpp. This function tells the AI to save up gold for trading with other empires -- rather a lot of gold, as it turns out. In my game, Jonas, with ten cities, felt like he needed a stash of 1,000 gold at all times. If it ever fell below this number, he turned down research to zero and waited for it to go up again.
I see what this is supposed to do in theory, but it all it does in practice is cripple the AI's research:
1. The amount of gold saved is excessive. You simply don't need that much. If you're buying techs for gold (rather than swapping them for other techs), you might as well just research them yourself.
2. There aren't any checks to see if you've discovered Trade or Currency yet, anyway.
3. Removing this (and the money being saved up for random events, which also doesn't really help the AI in practice) resulted in AI civs being in a much stronger position, technologically, by turn 300 (again, normal speed).
As I said, I understand what it's supposed to do and how it's supposed to help, but the current implementation is horribly broken and hurts the AI a lot.
2. Stack attacking could be better
Actually, there are tons of ways this one could be improved. Two things stuck out at me on first glance:
While there is the AI_stackAttackCity function in CvUnitAI, which works as it should, comparing one stack to another to see if it's worth attacking, there's also AI_cityAttack, which just compares the best attacker against the best defender and ignores everything else in both stacks. This doesn't seem sensible at all. AI_anyAttack works the same way, but for units in the field.
AI_compareStacks is pretty simplistic in general, actually. It could do with accounting for collateral damage, for example. On that note, CvUnitAI::AI_sacrificeValue could also do with giving units that 'explode' (i.e. Pyre Zombies) a higher value.
3. The way the AI chooses when to go to war is silly
Well, we knew it sub-optimal. I had no idea how bad it was until I checked the code.
The algorithm is completely backwards. The AI decides whether it wants to go to war (mostly at random) and *then* it picks the victim. Surely it should be determining the juiciest target first and then deciding whether it's worth going to war based on relative power ratios and how attractive the victim's lands are? That would make sense.
Ideally, an aggressive leader with double the power of his/her nearest neighbour would have no qualms whatsoever about declaring a 'max war' on them immediately and conquering their sorry empire. Why should they? They shouldn't be kept at bay by the random number generator when there's no good reason not to fight.
.....................................................................
That's all for now. More stuff as I spot it.
1. AI treasury management is insane
When I first started doing AI testing, I noticed that AI research rates all took a nosedive shortly after turn 200 (normal speed). At first I thought they must have been crashing their economy somehow (too many units?), but that turned out not to be the case. Even the bigger empires could research at around 40-50% and still turn in a net profit.
After some digging around, I found the source of the problems: AI_getGoldTreasury in CvPlayerAI.cpp. This function tells the AI to save up gold for trading with other empires -- rather a lot of gold, as it turns out. In my game, Jonas, with ten cities, felt like he needed a stash of 1,000 gold at all times. If it ever fell below this number, he turned down research to zero and waited for it to go up again.
I see what this is supposed to do in theory, but it all it does in practice is cripple the AI's research:
1. The amount of gold saved is excessive. You simply don't need that much. If you're buying techs for gold (rather than swapping them for other techs), you might as well just research them yourself.
2. There aren't any checks to see if you've discovered Trade or Currency yet, anyway.
3. Removing this (and the money being saved up for random events, which also doesn't really help the AI in practice) resulted in AI civs being in a much stronger position, technologically, by turn 300 (again, normal speed).
As I said, I understand what it's supposed to do and how it's supposed to help, but the current implementation is horribly broken and hurts the AI a lot.
2. Stack attacking could be better
Actually, there are tons of ways this one could be improved. Two things stuck out at me on first glance:
While there is the AI_stackAttackCity function in CvUnitAI, which works as it should, comparing one stack to another to see if it's worth attacking, there's also AI_cityAttack, which just compares the best attacker against the best defender and ignores everything else in both stacks. This doesn't seem sensible at all. AI_anyAttack works the same way, but for units in the field.
AI_compareStacks is pretty simplistic in general, actually. It could do with accounting for collateral damage, for example. On that note, CvUnitAI::AI_sacrificeValue could also do with giving units that 'explode' (i.e. Pyre Zombies) a higher value.
3. The way the AI chooses when to go to war is silly
Well, we knew it sub-optimal. I had no idea how bad it was until I checked the code.
The algorithm is completely backwards. The AI decides whether it wants to go to war (mostly at random) and *then* it picks the victim. Surely it should be determining the juiciest target first and then deciding whether it's worth going to war based on relative power ratios and how attractive the victim's lands are? That would make sense.
Ideally, an aggressive leader with double the power of his/her nearest neighbour would have no qualms whatsoever about declaring a 'max war' on them immediately and conquering their sorry empire. Why should they? They shouldn't be kept at bay by the random number generator when there's no good reason not to fight.
.....................................................................
That's all for now. More stuff as I spot it.