Home » MODDING HQ 1.13 » v1.13 Coding Talk » Realistic approach to replenish Queen's Army Reserve (New algorithm of increasing 'giReinforcementPool' counter)
Realistic approach to replenish Queen's Army Reserve[message #359872]
|
Fri, 01 May 2020 12:47
|
|
sun_alf |
|
Messages:7
Registered:April 2020 |
|
|
Hi everyone!
The problem.
'giReinforcementPool' is a counter representing size of Army's Reserve from where soldiers for new patrols and garrisons are taken. This counter is being updated when new soldiers are taken (decrease) and when a range of minor game events happen (increase). But Army does not do any continuous recruiting; once 'giReinforcementPool' is dropped to 0, a massive increase happens and that's all:
giReinforcementPool += <long formula>; // large increment
AddStrategicEvent( EVENT_EVALUATE_QUEEN_SITUATION, GetWorldTotalMin() + uiOffset, 0 ); // AI goes idling for next X days; it emulates "waiting for training completion"
If player is not lucky enough he will see huge Army parties generated from nowhere.
Proposed solution.
Current scheme of recruiting is as follows:
??? --> giReinforcementPool --> issued units
The scheme I'd like to see:
Volunteers + forced recruits* --> training camps --> giReinforcementPool --> issued units
ASD decides to hire "bad mercenaries" for money -->
* forced recruits -- people who were taken to the Army by the Army by force, against the will. Civilians regularly complain that oppression.
To be able to implement that, we have to introduce a few new options ("DifficultySettings.xml"):
<QueenPoolMaxSizePerDifficultyLevel>: this value is the max size of Reserve the Queen can have.
<QueenPoolIncrementDaysPerDifficultyLevel>: Interval in days for training of a new recruit group.
<QueenPoolBaseIncrementSizePerDifficultyLevel>: it is amount of recruits which can be trained on training camp at a time. Basically, it is capacity of one training camp (Meduna), the same capacity provides the second camp (Alma). AI tries to fullfil all available training capacity each day.
<QueenPoolRecruitPercentPerDifficultyLevel>: percent of a sector population the Army takes as recruits each day.
General idea is Queen's Army HQ tries to recruit new people each day morning. AI algorithm in pseudo code is:
// <QueenPoolMaxSizePerDifficultyLevel> is MAX_POOL_SIZE for short
// <QueenPoolIncrementDaysPerDifficultyLevel> is TRAINING_DAYS for short
EVENT_DAILY_EARLY_MORNING_EVENTS_subroutine()
{
if giReinforcementPool < MAX_POOL_SIZE then
{
new_recruits_taken = 0
if training_camps have free space then
{
new_recruits_taken += Take_volunteers()
}
if training_camps have free space then
{
new_recruits_taken += Take_recruits_by_force()
}
if new_recruits_taken > 0 then
{
PutStrategicEvent(current_day + TRAINING_DAYS, new_recruits_taken)
}
}
}
And when time comes to that event be happened, we do:
EVENT_NEW_RECRUITS_TRAINED_subroutine(new_recruits_taken)
{
giReinforcementPool += new_recruits_taken
}
Now let's see how volenteers can be taken:
// <QueenPoolRecruitPercentPerDifficultyLevel> is RECRUIT_PERCENT for short
Take_volunteers()
{
volunteers = 0
iterate over all city sectors
{
if sector is controlled by Army
and sectors' player_loyalty < (100 - sectors' townRebelSentiment) then
{
volunteers += (sectors' usCivilianPopulation * RECRUIT_PERCENT) / 100
}
}
return volunteers
}
And there is take by force finally:
Take_volunteers()
{
recruits = 0
iterate over all city sectors
{
if sector is controlled by Army
and sector has garrison then
{
recruits += (sectors' usCivilianPopulation * RECRUIT_PERCENT) / 100
if sectors' player_loyalty >= (100 - sectors' townRebelSentiment) // drawback of forced recruiting is
{ // percent of unresting people increases
increase sectors' player_loyalty by RECRUIT_PERCENT
}
}
}
return recruits
}
I though about use of MILITIA_VOLUNTEER_POOL logic, but threw away that idea as this establishes hard dependency on MILITIA_VOLUNTEER_POOL option: if the option is disabled, we cannot use related INI parameters freely.
Open question is: in what way we can decrease ASD's money as equipment for new soldiers costs money.
Another open question is: how rich Queen-loyal cities (Balime, Meduna) can help the Army with money (or something else) until they are loyal to player.
Anyway, open questions are fully optional things.
New feature for ASD.
ASD can buy new soldiers ("bad mercenaries") as well as jeeps or tanks. It is one more optional thing for proposed solution, but I believe we must introduce it.
[Updated on: Fri, 01 May 2020 13:14] Report message to a moderator
|
Private
|
|
|
Re: Realistic approach to replenish Queen's Army Reserve[message #360484 is a reply to message #359872]
|
Wed, 01 July 2020 00:18
|
|
Kitty |
|
Messages:473
Registered:October 2017 Location: Germany |
|
|
sun_alf wrote on Fri, 01 May 2020 12:47
...
<QueenPoolBaseIncrementSizePerDifficultyLevel>: it is amount of recruits which can be trained on training camp at a time. Basically, it is capacity of one training camp (Meduna), the same capacity provides the second camp (Alma). AI tries to fullfil all available training capacity each day.
<QueenPoolRecruitPercentPerDifficultyLevel>: percent of a sector population the Army takes as recruits each day.
General idea is Queen's Army HQ tries to recruit new people each day morning. AI algorithm in pseudo code is:
[font=Courier]
// <QueenPoolMaxSizePerDifficultyLevel> is MAX_POOL_SIZE for short
// <QueenPoolIncrementDaysPerDifficultyLevel> is TRAINING_DAYS for short
EVENT_DAILY_EARLY_MORNING_EVENTS_subroutine()
{
if giReinforcementPool < MAX_POOL_SIZE then
{
new_recruits_taken = 0
if training_camps have free space then
{
new_recruits_taken += Take_volunteers()
}
if training_camps have free space then
{
new_recruits_taken += Take_recruits_by_force()
}
if new_recruits_taken > 0 then
{
PutStrategicEvent(current_day + TRAINING_DAYS, new_recruits_taken)
}
}
}
....
This sounds pretty cool and I like that it is added to the trunk now. But to make use of this, I need some further explanation,
because:
To no surprise, I don't understand this fully
What is particulary puzzling me is: "training camp" and "Alma". Is Alma also a STRATEGIC_AI_SPAWN_SECTOR , like the Palace (according to mod_settings.ini) in Meduna ?
Or is "training camps" refering to something else (not Spawn-Sector) ? And if, what am I gonna do, if I use changed maps with no Alma ?
Is this checking for Town-ID or Garrison-ID or Sector coordinates instead ? Any definition I can change (like I can change the Spawn Sector in mod-settings.ini) ?
Basicly, I'm trying to ask: What is the definition of "Training Camp" ? Can I look up where those are located ? Can I change those places ?
Would be very kind, if you could explain this, I would realy like to use this with different maps as well.
How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN
I need more details. (Didi Hallervorden) Report message to a moderator
|
|
|
|
Re: Realistic approach to replenish Queen's Army Reserve[message #360503 is a reply to message #359872]
|
Mon, 06 July 2020 00:29
|
|
sun_alf |
|
Messages:7
Registered:April 2020 |
|
|
Thanks to Flugente, the feature is in /trunk now (for a couple of weeks actually). And now I found some free time to write this user guide to make clear all the aspects.
0. Before we start
The only file you need you to do basic setup is "DifficultySettings.xml". If you are a meticulous modder you probably want to look into "SectorNames.xml" for more specific tweaks.
1. Enable or disable the feature
To disable the feature:
* Set <UnlimitedPoolOfTroops> to 1, or
* Set <QueenPoolIncrementDaysPerDifficultyLevel> to 0.
To enable the feature, accordingly:
* Set <UnlimitedPoolOfTroops> to 0, and
* Set <QueenPoolIncrementDaysPerDifficultyLevel> to a positive non-zero value at your taste.
2. Basic settings
There are 5 options to tune-up the feature. I won't duplicate description in "DifficultySettings.xml", I will describe it in terms of source code instead.
* QueensInitialPoolOfTroops -- initial value of g_ReinforcementsPool.
* QueenPoolMaxSizePerDifficultyLevel -- max value of g_ReinforcementsPool to grow up in this way.
* QueenPoolIncrementDaysPerDifficultyLevel -- all newly taken recruits should pass the training before being added to g_ReinforcementsPool. "newly taken recruits" is nothing more than a number like g_ReinforcementsPool is. So basically, this option is delay in days before g_ReinforcementsPool will be increased.
* QueenPoolBaseIncrementSizePerDifficultyLevel -- capacity of one training camp, or how many recruits can be in "delay" simultaneously. Training camp is non-material thing. We just know the fact there are 2 of it in Arulco, one in Alma and one in Meduna. Having full control of a town == having control of a camp. So in the game beginning total capacity is this option multiplied by 2.
* QueenPoolRecruitPercentPerDifficultyLevel -- no more than % of sector population. Keep in mind, it can applied twice (volunteers, then by force) per each appropriate sector.
3. Examples (and my working values)
To understand continuous replenish better, let's imagine the war just begun, total training camps capacity is 100, training duration is 3 day, and we have a piece of events log:
day 1, 4:00 >>> Recruits taken: +25 Recruits in training: 25 / 100
day 2, 4:00 >>> Recruits taken: +15 Recruits in training: 40 / 100
day 3, 4:00 >>> Recruits taken: +13 Recruits in training: 53 / 100
day 4, 3:59 >>> Reinforcements pool: +25 Recruits in training: 28 / 100
day 4, 4:00 >>> Recruits taken: +17 Recruits in training: 45 / 100
day 5, 3:59 >>> Reinforcements pool: +15 Recruits in training: 30 / 100
day 5, 4:00 >>> Recruits taken: +8 Recruits in training: 38 / 100
day 6, 3:59 >>> Reinforcements pool: +13 Recruits in training: 25 / 100
day 6, 4:00 >>> Recruits taken: +11 Recruits in training: 36 / 100
... and so on.
On the practice this probably won't be so beatiful though, as it needs some time to reveal handy numbers for comfortable, balanced game. The replenishment should be effective and noticeable on one hand, and it should be limited enough on other hand, or you will spot orkish hordes otherwise.
After some experiments, I picked the following numbers for my AIMNAS variant for Medium difficulty (Experienced level). I hope these will be helpful initial numbers to play with.
* QueensInitialPoolOfTroops = 600
* QueenPoolMaxSizePerDifficultyLevel = 1000
* QueenPoolIncrementDaysPerDifficultyLevel = 3
* QueenPoolBaseIncrementSizePerDifficultyLevel = 40
* QueenPoolRecruitPercentPerDifficultyLevel = 1; in case of AIMNAS 1% is definitely enough for decisive replenishment. It is so because AIMNAS has more towns than original Arulco, and much more populated sectors overall.
It is probably not the worst idea to set <QueenPoolIncrementDaysPerDifficultyLevel> to 1 and limit camps capacity to guarantee more or less constant replenishment.
4. Advanced tweaks
The feature affects only 3 things in total:
* g_ReinforcementsPool, of course.
* Strategic AI never goes sleep. Normally, it goes sleep for up 8 days once ran out of reinforcements (g_ReinforcementsPool == 0). And now it keeps pushing until ran out of controlled population.
* Player loyalty across all towns.
Any other strategic aspects are not changed. In terms of source code, of course. There are still only one spawning sector (the Palace).
If your mod transforms original Arulco to something other with completely different map, please keep in mind the game checks Alma ID (= 3) and Meduna ID (= 11) when counting up training camps under Queen's control, i.e.:
if ( IsTownUnderCompleteControlByPlayer( ALMA ) == FALSE )
{ take into account this training camp }
That means a player has to take control over all Alma sectors to break this camp down. Once one or more Alma sectors are re-taken by Army, the camp is active again.
If you are not satisfied by tuning the 5 basic options, you can give a try in "SectorNames.xml". Increasing/reducing of <usCivilianPopulation> or making extra sectors be populated can affect replenishment very well. But remember, <usCivilianPopulation> can also affect other game features like Strategic Decease.
Now, I reached the end of this manual suddenly. So I will update it if I find something to add.
Thank you.
[Updated on: Tue, 07 July 2020 00:00] Report message to a moderator
|
Private
|
|
|
Goto Forum:
Current Time: Wed Nov 27 04:43:26 GMT+2 2024
Total time taken to generate the page: 0.00845 seconds
|