Maniac
Apolyton Sage
In the Planetfall mod, one of the biggest problems the AI is having, is fighting off naval native life units created by offshore fungal blooms, or just fighting off random naval native life wandering into its waters. From the Better AI code I saw that some code for naval blockade breaking was added. I hadn't examined it too closely yet at that point, but hoped that the naval situation would improve.
Unfortunately, after having added Better AI now, this doesn't seem the case. In good old fashioned Civ2 style, the AI just sends out single ships to attack the native life camping in its waters, the turn they're built on. What I do myself, is build up a numerical superiority, a critical mass, and only then move out of my coastal port cities to clear my waters from 'piracy' and hopefully establish a lasting dominance over my coastal waters. That way, with a numerical superiority, if I go one-on-one with a native life unit, and I lose, I still have other units to finish off the enemy unit, instead of just having given the enemy some free XP.
To try to improve the naval AI, it's useful to know the reasoning behind the current AI, in case I missed or misunderstand something.
So, jdog5000, would you be willing to share your thoughts on the current naval unit AI code?
I've had a look at the ATTACK_SEA unit AI, and I am confused about the eagerness of naval units to attack at bad odds.
(This is vanilla code for the record.)
If I understand this correctly, this means the AI is willing to attack any target if it has a 35% chance of success? Why would the AI want to do that??
They know they're likely to lose. Also, does the AI not look at all if the enemy is a single unit or part of a stack? Do they not look at the cost of its attacking unit? (Eg 35% odds with a 40 hammer unit is better than with a 80 hammer unit?)
The blockading code a bit lower I find even more confusing:
Why would the AI want to attack with 5% odds, unless it has really overwhelming numbers and the first units are just meant to soften up the target?
Also, I don't understand this part:
My understanding of AI_anyAttack and AI_searchRange is that with AI_anyAttack(2, x) for instance, the AI will look for enemy units within a 2 * baseMoves() range. Thus if the AI unit has only three movement points left and the enemy unit is more than one baseMoves range away from the AI unit, it's never gonna get back to the city, as you state is the intention of that code.
Hope to hear your thoughts!
Unfortunately, after having added Better AI now, this doesn't seem the case. In good old fashioned Civ2 style, the AI just sends out single ships to attack the native life camping in its waters, the turn they're built on. What I do myself, is build up a numerical superiority, a critical mass, and only then move out of my coastal port cities to clear my waters from 'piracy' and hopefully establish a lasting dominance over my coastal waters. That way, with a numerical superiority, if I go one-on-one with a native life unit, and I lose, I still have other units to finish off the enemy unit, instead of just having given the enemy some free XP.
To try to improve the naval AI, it's useful to know the reasoning behind the current AI, in case I missed or misunderstand something.
So, jdog5000, would you be willing to share your thoughts on the current naval unit AI code?
I've had a look at the ATTACK_SEA unit AI, and I am confused about the eagerness of naval units to attack at bad odds.
Code:
if (AI_anyAttack(1, 35))
{
return;
}
if (AI_anyAttack(2, 40))
{
return;
}
If I understand this correctly, this means the AI is willing to attack any target if it has a 35% chance of success? Why would the AI want to do that??

The blockading code a bit lower I find even more confusing:
Code:
if( iAttackers > (iBlockaders + 1) )
{
if( iAttackers > GC.getGameINLINE().getSorenRandNum(2*iBlockaders + 1, "AI - Break blockade") )
{
// BBAI TODO: Make odds scale by # of blockaders vs number of attackers
if (AI_anyAttack(1, 5))
{
return;
}
Why would the AI want to attack with 5% odds, unless it has really overwhelming numbers and the first units are just meant to soften up the target?
Also, I don't understand this part:
Code:
if( getMoves() > 2 ) // be able pull back to city
{
if (AI_anyAttack(2, 5))
{
return;
}
if (AI_anyAttack(3, 10))
{
return;
}
}
My understanding of AI_anyAttack and AI_searchRange is that with AI_anyAttack(2, x) for instance, the AI will look for enemy units within a 2 * baseMoves() range. Thus if the AI unit has only three movement points left and the enemy unit is more than one baseMoves range away from the AI unit, it's never gonna get back to the city, as you state is the intention of that code.
Hope to hear your thoughts!
