Olleus
Deity
I have been looking at the AI a bit and it seems that, although it is quite good, it lacks cohesion.
This is how I understand the CvUnitAI.cpp to work.
1) A unit is allocated 'tasks' (ie airbomb) based on its UNITAI_, chance and circumstances
2) The unit then iterates through all the squares in which the task (airbomb) can be done.
3) It then does that task on the most suitable square
4) Moves on to next unit
ATM the weakness of the AI is in the small amount of circumstances which it takes into account, having looked briefly at the code I could only see pCity->isDanger() and pCity->numPotentialAttackers(), we need a lot more.
If we could give the AI a general plan which it could stick to for a few turns, then it would also greatly improve. Maybe, when it declares war it could spot a weakly defended enemy city, and select that as its target. For the next few turns any units which are not on 'critical' duty (defending cities/key resources) are saved. When the stockpiled units gain x times the strenght of the units in the defending city, it moves onto the attack, and will only back away if it is obvious which it is loosing.
The other way to make it better would be to have feedback. In the top example, the unit has already decided that it will airbomb, even though it hasn't even looked at the different targets possible. This means that x% of the bombers will reduce the defences of a pointless tundra city, instead of attacking that nice, juicy SOD. A way of changing this would be to evaluate the effectiveness of airbomb and airstrike and only after decide which one to do.
Yet another way of improving the AI is in the order in which it does things. I propose this. It iterates through all the units once. If a unit can do an action which it rates to be 'very good' then it does it, otherwise it waits. Once it has looked through all the units once, it has another look. This time it will be satisfied with anything ranks 'Good'. Repeat.
Is this feasible?
This is how I understand the CvUnitAI.cpp to work.
1) A unit is allocated 'tasks' (ie airbomb) based on its UNITAI_, chance and circumstances
2) The unit then iterates through all the squares in which the task (airbomb) can be done.
3) It then does that task on the most suitable square
4) Moves on to next unit
ATM the weakness of the AI is in the small amount of circumstances which it takes into account, having looked briefly at the code I could only see pCity->isDanger() and pCity->numPotentialAttackers(), we need a lot more.
If we could give the AI a general plan which it could stick to for a few turns, then it would also greatly improve. Maybe, when it declares war it could spot a weakly defended enemy city, and select that as its target. For the next few turns any units which are not on 'critical' duty (defending cities/key resources) are saved. When the stockpiled units gain x times the strenght of the units in the defending city, it moves onto the attack, and will only back away if it is obvious which it is loosing.
The other way to make it better would be to have feedback. In the top example, the unit has already decided that it will airbomb, even though it hasn't even looked at the different targets possible. This means that x% of the bombers will reduce the defences of a pointless tundra city, instead of attacking that nice, juicy SOD. A way of changing this would be to evaluate the effectiveness of airbomb and airstrike and only after decide which one to do.
Yet another way of improving the AI is in the order in which it does things. I propose this. It iterates through all the units once. If a unit can do an action which it rates to be 'very good' then it does it, otherwise it waits. Once it has looked through all the units once, it has another look. This time it will be satisfied with anything ranks 'Good'. Repeat.
Is this feasible?