Commander Bello
Say No 2 Net Validations
Based on the discussion started in this thread (in the RaR subforum) I have created this thread here to discuss topics related to improving the AI which are not mod-specific.
I will first quote two postings from there to get you familiarized with the current state of the discussion.
Well, I don't know if it really is the coding part which would be so difficult. Actually, I think it is the concept which holds the most problems.
Let me give you some examples:
1) First example
There's a function AI_updateYieldValues (something like this, would have to look up the correct naming and placing) which loops over all yields to either value them with European buy or sell prices. Later it loops over all cities (of the player) and over all professions and tries to assign half of the estimated value of final products to the ingoing raw materials.
Here I see many parts which should be improved.
First of all, one may very well discuss if yields shouldn't be valued with the price for rushing them (emergency replacement costs, or whatever you would like to call it).
Second, looping over all cities is questionable. Even it one would regard it necessary, there's a CvCity::doTurn(), switching to various other functions in which most probably the looping over professions is already done. So, why not placing the valuation at a proper place there?
Third, and most important, as far as I have seen from short browsing over this function it doesn't take into consideration build orders, planning (Revolution_Preparation and so on, or however they may be called) nor current peacetime/wartime conditions.
Fourth, it may be nice to add value from clothes to cotton (just as an example), but that doesn't help us (better: the AI) at all, especially not in the vanilla environment of randomly changing prices for randomly selected yields.
If I have the capacity of producing say 6 items of clothes per turn, this doesn't make my capacity of producing 24 cotton more valuable. Not a bit. The only thing I should care for is to have at least the 6 needed cotton.
So, here I see big flaws in the valuation "concept" already (and the coding of course may be improved, too, as indicated above).
2) Second example:
At least when fighting the Natives, all you need is a little army of say 5 cannons and some infantry. March from native settlement to native settlement, bomb down the defences, kill the defenders, collect some treasure. Rinse and repeat.
The AI won't do anything against this approach. It will happily stay sitting in the settlements and get killed.
In fact it should check if there are units with city attacker capabilities in the attacking stack and counterattack this stack before it can start bombing the city.
On a sidenote: there aren't any incentives to make peace with natives, to make things worse. Latest after having destroyed the first settlement, the natives will be that furious that even after having made peace a new war at least will be quite likely. But since you've made peace, they are swarming across the countryside again and may be next to your own settlements then.
So, the best option just is to completely kill them. Genocide, anyone?
And as added bonus you now can happily spread your culture over the territory, as there isn't anyone left to complain.
3) Regarding you question about the chopping:
I currently don't have the slightest idea, either.
But my approach would be to count all lumber providing tiles in all city radii and their potential output (once again, CvCity::doTurn() comes to mind). Check this against the assumed demand for lumber (add some percents on it to stay on the safer of both sides) and now redistribute a "need for lumber tiles kept" to each city.
Then, when the AI assigns professions, it has to check this number of lumber tiles kept not to destroy a forest which is needed.
So, we already have three topics which might be worth looking at, no?
And I am not saying that my assessments are perfect... Others may have other ideas and may have identified better options for improving the AI.
But as I indicated above already: the most important part is the concept behind the AI - and that means that the modders need to have a proper idea, first.
Update:
Since Nightingale mentioned it, I add another example:
I will first quote two postings from there to get you familiarized with the current state of the discussion.
Originally Posted by Commander Bello View Post
Actually, I think combined efforts of modders would make more sense in the area of the AI - as it is in a terrible state, anyway.
That would be something from which all of us might gain a profit.
I too would like an improved AI. However improving the AI is quite unspecific. You might as well have said "I want to make the game better". The main question is how and who have the coding skills to do it? Coding the AI is quite hard.
I would like the AI not to cut down all forests, but I haven't figured out even where to start.
Well, I don't know if it really is the coding part which would be so difficult. Actually, I think it is the concept which holds the most problems.
Let me give you some examples:
1) First example
There's a function AI_updateYieldValues (something like this, would have to look up the correct naming and placing) which loops over all yields to either value them with European buy or sell prices. Later it loops over all cities (of the player) and over all professions and tries to assign half of the estimated value of final products to the ingoing raw materials.
Here I see many parts which should be improved.
First of all, one may very well discuss if yields shouldn't be valued with the price for rushing them (emergency replacement costs, or whatever you would like to call it).
Second, looping over all cities is questionable. Even it one would regard it necessary, there's a CvCity::doTurn(), switching to various other functions in which most probably the looping over professions is already done. So, why not placing the valuation at a proper place there?
Third, and most important, as far as I have seen from short browsing over this function it doesn't take into consideration build orders, planning (Revolution_Preparation and so on, or however they may be called) nor current peacetime/wartime conditions.
Fourth, it may be nice to add value from clothes to cotton (just as an example), but that doesn't help us (better: the AI) at all, especially not in the vanilla environment of randomly changing prices for randomly selected yields.
If I have the capacity of producing say 6 items of clothes per turn, this doesn't make my capacity of producing 24 cotton more valuable. Not a bit. The only thing I should care for is to have at least the 6 needed cotton.
So, here I see big flaws in the valuation "concept" already (and the coding of course may be improved, too, as indicated above).
2) Second example:
At least when fighting the Natives, all you need is a little army of say 5 cannons and some infantry. March from native settlement to native settlement, bomb down the defences, kill the defenders, collect some treasure. Rinse and repeat.
The AI won't do anything against this approach. It will happily stay sitting in the settlements and get killed.
In fact it should check if there are units with city attacker capabilities in the attacking stack and counterattack this stack before it can start bombing the city.
On a sidenote: there aren't any incentives to make peace with natives, to make things worse. Latest after having destroyed the first settlement, the natives will be that furious that even after having made peace a new war at least will be quite likely. But since you've made peace, they are swarming across the countryside again and may be next to your own settlements then.
So, the best option just is to completely kill them. Genocide, anyone?
And as added bonus you now can happily spread your culture over the territory, as there isn't anyone left to complain.
3) Regarding you question about the chopping:
I currently don't have the slightest idea, either.
But my approach would be to count all lumber providing tiles in all city radii and their potential output (once again, CvCity::doTurn() comes to mind). Check this against the assumed demand for lumber (add some percents on it to stay on the safer of both sides) and now redistribute a "need for lumber tiles kept" to each city.
Then, when the AI assigns professions, it has to check this number of lumber tiles kept not to destroy a forest which is needed.
So, we already have three topics which might be worth looking at, no?
And I am not saying that my assessments are perfect... Others may have other ideas and may have identified better options for improving the AI.
But as I indicated above already: the most important part is the concept behind the AI - and that means that the modders need to have a proper idea, first.
Update:
Since Nightingale mentioned it, I add another example:
The AI is very weak in assigning military professions. A typical behaviour is sending a promoted military unit to a city, dropping all weapons and working as field worker or whatever (I have even spotted general-lead troops as pioneers or worse, as missionaries in the past). As soon as the need for a military unit arises, it takes the unit which it thinks it can spare - which in many cases is not the military unit.
In the end you may have the promoted unit work somewhere and a weaker unit do the defense (in the worst case).