User avatar
Posts: 25405
Joined: Wed Oct 19, 2005 7:37 am
Location: Lyon (France)

Modding Naval AI

Tue Feb 18, 2014 4:09 pm

Hi gents,

There was some serious revisions of the code used to determine the 'Naval Map' for the AI (seas but also rivers regions). This abstracted map gives to each water region an interest value and is used by the AI to determine where Naval Superiority missions are made (this include blockading enemy ports, protecting own ports or patrolling seas).

Practically, the calculations have been revised and several bugs removed. Plus, these calculations now fully support the usage of the script command AI.SetLocalInterest / AI.chgtLocalInterest / AI.SetAreaLocalInterest / AI.ChgAreaLocalInterest. Before it half worked.

The Naval Map takes into account several factors, like the current relative strength of the naval units compared to the enemy, if the regions are bordering a friendly or enemy harbor, the number of links of the region (giving more important to straight/bottlenecks), the presence of enemy forces in an adjacent harbor or the presence of friendly forces. The values change depending if the AI is in superiority or not. For example when stronger (120% plus of the enemy combat power), less emphasis is put on friendly harbors and more on enemy harbors, particularly the ones harboring land units (the AI will want to blockade these harbors). On the contrary, if weaker (119% or less) then friendly harbors will be more protected and less importance will be given to enemy harbors (less propensity to go into enemy waters).

If you let the AI processes, you'll see some logs files appear in the Logs\AI folders, some will be named with 'Naval' in their name. This gives the interest value of any water regions (in a naval theater but also in land theaters, as rivers are part of land theaters).
Using a saved game for CW2, you can get these kinds of values:

CSA Deep South Naval evaluation
Theater: 100 Deep South Nav Ratio: 1.28
2267 Charles River NavalVal:28
2268 Upper Savannah River NavalVal:5
2269 Middle Savannah River NavalVal:6
2270 Savannah Mouth NavalVal:19

or for the naval theater 'Seas'
USA _Seas_NavalEvaluation
Theater: 111 Seas Nav Ratio: 1.93
2616 Cape Henry NavalVal:35
2617 Hampton Roads NavalVal:189
2618 James Estuary NavalVal:248
2619 York Estuary NavalVal:36
2620 Rappahannock Estuary NavalVal:7

These values are very contextual to a given game, but still, there are sometime where you want to put a particular emphasis (or de-emphasis) constantly on some regions (or groups of regions). Don't go overboard here, because an 'interesting' region, like a straight or a coast nearby a big harbor will already be determined as interesting by the code, still, you can influence significantly the AI by scripting a bit what 'she' should see.

As this is done with scripting commands, you can add conditions of your own. For example don't bother with the coasts nearby Texas before 1863, or emphasis protecting Hampton Roads IF only there are a 2 to 1 ratio in land units for the USA, the conditions are what you want.

You do that using the commands I spoke about at the start of this text, for example if you always want to de-emphasize the Golden Gate Bay for USA in CW2 (as the generic code will believe the region is very interesting, given it has a big harbor) you can script:
AI.SetLocalInterest = $Golden_Gate_Bay|20

20% of the calculated interest.

I took examples from CW2, but these code changes will be in all AGE games from now on, so don't hesitate to use them in others games projects & mods, for a better naval AI.

Hofstadter's Law: "It always takes longer than you expect, even when you take into account Hofstadter's law."

Return to “Modding AGE engine games”

Who is online

Users browsing this forum: No registered users and 1 guest