Per-Region AIPARAMS files

Have a question about how to mod something? Or have an issue with one of our mod tools? Post here.

Moderators: Balthagor, Moderators

User avatar
George Geczy
General
Posts: 2688
Joined: Jun 04 2002
Location: BattleGoat Studios
Contact:

Per-Region AIPARAMS files

Post by George Geczy »

In the next update (for reference, any version of SRU greater than 9.0.20 or any version of SR1936 greater than 8.3.20) this feature will be available.

This is in response to the suggestion to be able to specify customer AIPARAMS data per-region. I will document it here for now (because the supremewiki is a bit in disarray right at the moment), though hopefully it will get copied somewhere a bit more findable at some point.

---- What's in the AIPARAMS.CSV File:

&&BUILDSEQUENCE - this specifies what equipment classes will be built by the AI and Ministers, with options for Offense/Mixed/Defense preference

&&UNITWEIGHTING - this specifies the weights given to different unit stats when the minister is considering building new units. Again there is an offensive and defensive preference (mixed will average the two)

&&MISSILEWEIGHTING - same thing for missiles

&&AIREQRESPONSE - this specifies what classes of units the AI will use to respond to different unit requests (such as garrison, attack, air support, etc)


---- How the file gets loaded:

AIPARAMS.CSV is loaded by the "ALLLOAD.INI" file. ALLLOAD has two different ways of being loaded: 1) For scenarios, sandboxes and campaigns that ship with the game, it is specified in the .scenario file. 2) For Modded games, it is loaded based on the file name specified in an "inclfile:" line in the .scenario file. All of our .scenario files do not have this line, and so the default - "ALLLOAD.INI" is used.

If you simply replace the ALLLOAD.INI or the AIPARAMS.CSV with a custom version that has values for additional regions, that will work, but then that new file will be used for ALL the existing sandbox/scenario/campaign games and savegames the player starts.

The data in this file is NOT "baked in" to a cache or savegame. This means that you need to take extra steps to make sure it is loaded with savegames - and if a savegame file is emailed to someone else, they will use the default original file if they don't have your file on their system.

For Multiplayer Games, this data *should not* be sync critical - that means different players can use different AIPARAMS files without causing sync errors. This has not been well tested, however, and may not in fact be true. In Multiplayer games, each local player uses their own AIPARAM files, and all the AI regions use the file of the host machine.


---- How to specify a different file in your sandbox/scenario:

You will need to provide your own custom file to replace ALLLOAD.INI. I suggest you don't overwrite the existing one, unless your intention is to change all the existing sandboxes/scenarios/campaigns that ship with the game. Otherwise, to use a different file, simply add the following to the bottom of your .scenario file for your custom game:

inclfile: "MYFILE"

By default, this file will be loaded from the \INI directory. There is a limit of 18 characters to this file name, so it is not feasible to add a directory override to the file name. This file is a list of non-cached data files, one of which is "AIPARAMS.CSV". If you create a custom MYFILE.INI, make sure you still load all the other elements that are in the default file !

In this file you can specify a full path for your stuff, so you can do something like:
#include "MYAIPARAMS.CSV", "SCENARIO\\CUSTOM\\MYMOD\\"


---- How to specify AIPARAMS for different regions

First of all, every game MUST have those sections for default regions - which means the region number is 0 or blank. Any region without its own custom section will use the default section.

To add new custom sections per region, just do it the same way as the default sections but add the region number at the end of the && line, for example:
&&AIREQRESPONSE 1188

That specifies region 1188, SR1936 Germany


---- Warnings!

This is untested at present. Caveat Modder.
User avatar
Zuikaku
General
Posts: 2394
Joined: Feb 10 2012
Human: Yes

Re: Per-Region AIPARAMS files

Post by Zuikaku »

What a great news :D

Can you ,please, explain unit weighting?? How does it work? Especially regarding unit cost or build time. If we want AI to produce cheaper units, do we have to enter higher or lower value? tried to test this but results were rather strange...
Please teach AI everything!
Fistalis
General
Posts: 3315
Joined: Jun 23 2009
Human: Yes
Location: x:355 y:216
Contact:

Re: Per-Region AIPARAMS files

Post by Fistalis »

:D YAY me.. i can now create scenarios/mods with countries who follow specific Military doctrines. Thanks george this has been on Top my modding wish list for a VERY long time, and near the top for the game itself since you guys can now try to put some personality into each nation and/or leader.

I'll start poking at it for testing purposes as soon as i get modding time. This will be used extensively in MWU.

As an aside is there any plans to make use of these in the Default scenarios.. there is certainly a huge amount of potential here. (Getting the AI to research/build more historical units should be easier)

(now if we only could use strategic bombers in the AIRESPONSE.. :wink: )
Si vis pacem, para bellum
my Supreme Ruler mods Site - May it rest in peace
User avatar
George Geczy
General
Posts: 2688
Joined: Jun 04 2002
Location: BattleGoat Studios
Contact:

Re: Per-Region AIPARAMS files

Post by George Geczy »

Re Unit Weighting - Ideally a "normal" weight for a spec is 1.0. This is multiplied by an internal value that is used to combine all the specs together and create a master unit value that the AI uses to decide what is the best unit to build. A higher value makes that spec 'more important', a lower value less important, and a zero will ignore it entirely.

In practice, the 'normal' values have been tweaked to get a better balance of AI decisions - so for example the build days weighting values seem to range from 1.6 to 3.0, indicating that it has been seen to be more important to account for build time than we had at first thought. In another example, recon units have spotting weighted at 4.0, while infantry it's 0.1.

Re use in our default scenarios - It would be nice, but this isn't on our development short list. If some interesting progress comes through from modding, we could certainly incorporate that back into the core sandboxes :wink:

And about airesponse, I wouldn't mind expanding that area myself, but again it's not one of the priorities right now.
User avatar
Zuikaku
General
Posts: 2394
Joined: Feb 10 2012
Human: Yes

Re: Per-Region AIPARAMS files

Post by Zuikaku »

George Geczy wrote:Re Unit Weighting - Ideally a "normal" weight for a spec is 1.0. This is multiplied by an internal value that is used to combine all the specs together and create a master unit value that the AI uses to decide what is the best unit to build. A higher value makes that spec 'more important', a lower value less important, and a zero will ignore it entirely.

In practice, the 'normal' values have been tweaked to get a better balance of AI decisions - so for example the build days weighting values seem to range from 1.6 to 3.0, indicating that it has been seen to be more important to account for build time than we had at first thought. In another example, recon units have spotting weighted at 4.0, while infantry it's 0.1.
Thank you for taking time to explain this :-)
Please teach AI everything!
Fistalis
General
Posts: 3315
Joined: Jun 23 2009
Human: Yes
Location: x:355 y:216
Contact:

Re: Per-Region AIPARAMS files

Post by Fistalis »

George Geczy wrote:Re Unit Weighting - Ideally a "normal" weight for a spec is 1.0. This is multiplied by an internal value that is used to combine all the specs together and create a master unit value that the AI uses to decide what is the best unit to build. A higher value makes that spec 'more important', a lower value less important, and a zero will ignore it entirely.

In practice, the 'normal' values have been tweaked to get a better balance of AI decisions - so for example the build days weighting values seem to range from 1.6 to 3.0, indicating that it has been seen to be more important to account for build time than we had at first thought. In another example, recon units have spotting weighted at 4.0, while infantry it's 0.1.

Re use in our default scenarios - It would be nice, but this isn't on our development short list. If some interesting progress comes through from modding, we could certainly incorporate that back into the core sandboxes :wink:

And about airesponse, I wouldn't mind expanding that area myself, but again it's not one of the priorities right now.
We'll I certainly appreciate this addition and any other obscure thing I want you decide to do. I do understand that there are always going to be larger priorities when changes/fixes etc to the core game improve the experience for everyone. (although having the AI actually use strategic bombers outside of Nuclear war would fall into that category :D )


edit: Also you never answered the question as to whether higher weighting = cheaper units or more expensive ones when it comes to unit cost. I would assume cheaper but..
Si vis pacem, para bellum
my Supreme Ruler mods Site - May it rest in peace
User avatar
George Geczy
General
Posts: 2688
Joined: Jun 04 2002
Location: BattleGoat Studios
Contact:

Re: Per-Region AIPARAMS files

Post by George Geczy »

Fistalis wrote:edit: Also you never answered the question as to whether higher weighting = cheaper units or more expensive ones when it comes to unit cost. I would assume cheaper but..
For each of the weightings, a higher number means "more favorable". So for cost and build days, a higher weight would result in a preference for cheaper units or less days.

At least, that's how I remember it :-?
User avatar
Zuikaku
General
Posts: 2394
Joined: Feb 10 2012
Human: Yes

Re: Per-Region AIPARAMS files

Post by Zuikaku »

George Geczy wrote:
Fistalis wrote:edit: Also you never answered the question as to whether higher weighting = cheaper units or more expensive ones when it comes to unit cost. I would assume cheaper but..
For each of the weightings, a higher number means "more favorable". So for cost and build days, a higher weight would result in a preference for cheaper units or less days.

At least, that's how I remember it :-?
But if we weight one unit X with 30 build days and another unit Y with 60 build days and build day preference is 4... then 4X30 < 4X60 and I think AI will prefer unit Y... that is why I'm so confused about this. :o ???
Please teach AI everything!
Fistalis
General
Posts: 3315
Joined: Jun 23 2009
Human: Yes
Location: x:355 y:216
Contact:

Re: Per-Region AIPARAMS files

Post by Fistalis »

Zuikaku wrote:
George Geczy wrote:
Fistalis wrote:edit: Also you never answered the question as to whether higher weighting = cheaper units or more expensive ones when it comes to unit cost. I would assume cheaper but..
For each of the weightings, a higher number means "more favorable". So for cost and build days, a higher weight would result in a preference for cheaper units or less days.

At least, that's how I remember it :-?
But if we weight one unit X with 30 build days and another unit Y with 60 build days and build day preference is 4... then 4X30 < 4X60 and I think AI will prefer unit Y... that is why I'm so confused about this. :o ???
only if all other weightings are 0 or the units have all the same stats. :wink:
Si vis pacem, para bellum
my Supreme Ruler mods Site - May it rest in peace
User avatar
Zuikaku
General
Posts: 2394
Joined: Feb 10 2012
Human: Yes

Re: Per-Region AIPARAMS files

Post by Zuikaku »

So, if we want AI to build cheaper units, we got to lower weigting number after all...
Please teach AI everything!
User avatar
George Geczy
General
Posts: 2688
Joined: Jun 04 2002
Location: BattleGoat Studios
Contact:

Re: Per-Region AIPARAMS files

Post by George Geczy »

OK, let's start this again :)

For three of the values, lower is better: Number of soldiers per battalion, cost, and build days.

Let's take a look at build days for a tank unit. The formula in use is :

weight = [ 100 - (days per tank)*100 ] * weightvalue

So lets compare two tanks: a fancy high tech tank with a build time of 2 days per tank (ie 88 days for a strength 44 tank battalion), compared to a basic discount special at 1/2 a day per tank (22 days for a strength 44 tank battalion)

Now, let's say in the AIPARAMS file you give it a weighting value of 4.0 in the UNITWEIGHTING section.

Fancy tank: weight = [ 100 - 2*100 ] * 4.0
Fancy tank weighting is -400.0

Basic tank: weight = [ 100 - 0.5*100 ] * 4.0
Basic tank weighting is +200.0


That weight gets added to the weight value of all the other specs in the list. Then the unit with the highest weight value wins, and gets built.

Looking at how this works with our tanks, assume all the other values except for build days give FancyTank a total of 1500, and BasicTank a total of 1000.
If the AIPARAMS weighting of build days was 0.0, then build days is ignored, and FancyTank is built (1500 to 1000).
If the weighting of build days is 4.0 as above, then BasicTank is built - FancyTank's final total is 1100 (1500 - 400), BasicTank's total is 1200 (1000 + 200)
If the weighting of build days is set to 2.0 instead, then FancyTank is built (final totals would be 1500-200 for FancyTank versus 1000+100 for BasicTank in the formula)


The "weightingvalue" in AIPARAMS is just used as a multiplier of the formula, to determine how important (the weight) of the value in the AI Minister's mind.
User avatar
George Geczy
General
Posts: 2688
Joined: Jun 04 2002
Location: BattleGoat Studios
Contact:

Re: Per-Region AIPARAMS files

Post by George Geczy »

Zuikaku wrote:So, if we want AI to build cheaper units, we got to lower weigting number after all...
Just to summarize, if you want the AI to build cheaper units, you need to specify a HIGHER weighting number.
User avatar
Zuikaku
General
Posts: 2394
Joined: Feb 10 2012
Human: Yes

Re: Per-Region AIPARAMS files

Post by Zuikaku »

Thank you, that was most helpful. And my last question regarding unit weighting:

- how to make AI build more armoured infantry and halftracks

- how to make AI to build transport choppers and not only airplanes
Please teach AI everything!
User avatar
George Geczy
General
Posts: 2688
Joined: Jun 04 2002
Location: BattleGoat Studios
Contact:

Re: Per-Region AIPARAMS files

Post by George Geczy »

Zuikaku wrote:- how to make AI build more armoured infantry and halftracks

- how to make AI to build transport choppers and not only airplanes
For infantry, I would set a higher weighting for speed and for defensive values to try to get it to build more armoured and mobile units. Can't really do much about halftracks specifically I think.

Regarding transport helicopters as a preference, I'm not sure about that. I'll need to look in to whether there is something that would make that possible.
User avatar
number47
General
Posts: 2655
Joined: Sep 15 2011
Human: Yes
Location: X:913 Y:185

Re: Per-Region AIPARAMS files

Post by number47 »

Necromancer has entered the building...

Is it possible to make country build more tanks and infantry and less (or almost none) artillery and AA units by modding the AIparams file? And if yes, how would I do it? :D
"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr
Post Reply

Return to “Modding Issues & Support”