Thunderbrd
C2C War Dog
I'm currently working on trying to gain a full understanding of the Naval AI structure of C2C as a whole.
This is a project along the path of the Naval Rework Project. I'm at first here just trying to get a full picture of what AIs to set our naval units to. I know there's a few new 'roles' being thrown in as well so I'm also looking to see if a new AI setting or two is necessary and how to set them up properly if needbe. In particular, the Corvettes, Cutters, Merchant Ships and Troop Transport units may require some new AIs and/or adjustments to existing AIs.
Along the way I think there may also be other edits we might wish to make to the Naval AI structures. We have some strategic matters that aren't currently being addressed... Surround and Destroy, ZoCs etc...
There are a number of issues I want to investigate here. This was really sparked off because I don't really the way the XML is supposed to work. We have, for example, the Torpedo Boat with the following XML settings:
Steam Industrial DefaultUnitAI UnitAIs NotUnitAIs
x62-x65 centers on x64
Torpedo Boat UNITAI_RESERVE_SEA UNITAI_PIRATE_SEA UNITAI_ESCORT_SEA
UNITAI_SPY_SEA UNITAI_RESERVE_SEA
UNITAI_ASSAULT_SEA UNITAI_ATTACK_SEA
UNITAI_EXPLORE_SEA
I asked Koshling about this and he expressed that it's probably a bug that the primary AI of UNITAI_RESERVE_SEA is also a NotAI setting as well... but also said a lot of these XML settings were somewhat mysterious to him as well. He said, in fact:
So I felt I should really begin to investigate the full picture of the Naval AI here.
Although I want to make sure that I understand the 3 differing AI tags, their usage, and how they affect the unit's choices, I figured I'd start by attempting to breakdown exactly what a given AI setting is told to do.
To help some of you who are less code based understand, Groups are commanded by one AI setting at a time, the AI setting of its lead unit. When a Group's turn comes up and it doesn't have an assigned activity it's in the process of fulfilling already (if it does it'll continue to perform that activity) then it will run through a series of checks based on its unit AI setting.
So I figured I'd start with the first naval AI on the list, which for the list I'm going off of here is UNITAI_RESERVE_SEA. I'm simply evaluating the code and trying to put its process into as plain English as possible.
I'll be posting these one at a time and I'm inviting those who can read the code to point out where I may be wrong or may be overlooking details. I'm not breaking down all the functions that are called within the functions of evaluation in their entirety - just trying to summarize what lies down those roads as best as possible without a complete breakdown of every step of processing there. Some of those function calls are scanned rather than read in their entirety so I may well be a little wrong about some presumptions here and that's one of the motivators to post these breakdowns here.
The other motivation is to highlight problems, overlooked points at which to enact other strategies, and offer the entire community the opportunity to review the AI processes and add commentary and feedback since this affects all our games. An advanced player can review these breakdowns to spot potential weaknesses in the AI's approach to naval decisionmaking and if big weaknesses are found, it's appreciated if it's pointed out.
But in particular, this is a huge invitation to the other coders among us to input their thoughts on edits that should be made and their insights as to why the structure has been designed as it is.
I'll try to keep these 'English translations' as updated as possible as changes are made.
The next steps, after fully evaluating the AI processes for each AI will be to gain a full understanding for how units are chosen to be built, how they gain their initial AI settings, and then how to best assign (or create and then assign) AIs to our naval units.
So I'll make my next post here the English breakdown for the UNITAI_RESERVE_SEA setting.
This is a project along the path of the Naval Rework Project. I'm at first here just trying to get a full picture of what AIs to set our naval units to. I know there's a few new 'roles' being thrown in as well so I'm also looking to see if a new AI setting or two is necessary and how to set them up properly if needbe. In particular, the Corvettes, Cutters, Merchant Ships and Troop Transport units may require some new AIs and/or adjustments to existing AIs.
Along the way I think there may also be other edits we might wish to make to the Naval AI structures. We have some strategic matters that aren't currently being addressed... Surround and Destroy, ZoCs etc...
There are a number of issues I want to investigate here. This was really sparked off because I don't really the way the XML is supposed to work. We have, for example, the Torpedo Boat with the following XML settings:
x62-x65 centers on x64
Torpedo Boat UNITAI_RESERVE_SEA UNITAI_PIRATE_SEA UNITAI_ESCORT_SEA
UNITAI_SPY_SEA UNITAI_RESERVE_SEA
UNITAI_ASSAULT_SEA UNITAI_ATTACK_SEA
UNITAI_EXPLORE_SEA
I asked Koshling about this and he expressed that it's probably a bug that the primary AI of UNITAI_RESERVE_SEA is also a NotAI setting as well... but also said a lot of these XML settings were somewhat mysterious to him as well. He said, in fact:
Koshling said:This is no an area I ever well understood I'm afraid. I think having a unit AI and a not-unit AI of the same value is a bug really, and in that case the not will essentially be ignored - I cannot see why you'd WANT this situation at least.
UnitAIs have two functions:
1) A unitAI type determines which AI is applied to stacks lead by that unit (note - only the stack leader has any impact on how a stack behaves)
2) When choosing the unit to lead a stack it is done based on the unitAIs involved. For this reason you have to b slightly careful about what you allow to stack together, as the 'losing' unitAI will be totally subservient to the winning one (thus settlers command their stacks, so if you lt one get into a military attack stack it will lose all will to perform attack functions).
When a city chooses a unit to build (or put out a tender for), it is (usually) specified by requesting a unit of a particular AI type (i.e. - AI types map to 'purposes')
Changing a unit's AI type is one of those here-be-dragons areas
So I felt I should really begin to investigate the full picture of the Naval AI here.
Although I want to make sure that I understand the 3 differing AI tags, their usage, and how they affect the unit's choices, I figured I'd start by attempting to breakdown exactly what a given AI setting is told to do.
To help some of you who are less code based understand, Groups are commanded by one AI setting at a time, the AI setting of its lead unit. When a Group's turn comes up and it doesn't have an assigned activity it's in the process of fulfilling already (if it does it'll continue to perform that activity) then it will run through a series of checks based on its unit AI setting.
So I figured I'd start with the first naval AI on the list, which for the list I'm going off of here is UNITAI_RESERVE_SEA. I'm simply evaluating the code and trying to put its process into as plain English as possible.
I'll be posting these one at a time and I'm inviting those who can read the code to point out where I may be wrong or may be overlooking details. I'm not breaking down all the functions that are called within the functions of evaluation in their entirety - just trying to summarize what lies down those roads as best as possible without a complete breakdown of every step of processing there. Some of those function calls are scanned rather than read in their entirety so I may well be a little wrong about some presumptions here and that's one of the motivators to post these breakdowns here.
The other motivation is to highlight problems, overlooked points at which to enact other strategies, and offer the entire community the opportunity to review the AI processes and add commentary and feedback since this affects all our games. An advanced player can review these breakdowns to spot potential weaknesses in the AI's approach to naval decisionmaking and if big weaknesses are found, it's appreciated if it's pointed out.
But in particular, this is a huge invitation to the other coders among us to input their thoughts on edits that should be made and their insights as to why the structure has been designed as it is.
I'll try to keep these 'English translations' as updated as possible as changes are made.
The next steps, after fully evaluating the AI processes for each AI will be to gain a full understanding for how units are chosen to be built, how they gain their initial AI settings, and then how to best assign (or create and then assign) AIs to our naval units.
So I'll make my next post here the English breakdown for the UNITAI_RESERVE_SEA setting.