AI recruitment query

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Spannerbag
Posts: 540
Joined: December 18th, 2016, 6:14 pm
Location: Yes

AI recruitment query

Post by Spannerbag »

Hi,
I'm balancing a scenario (v1.16.10 on Windows 11) and would like to tweak the AI recruitment but can't get the exact behaviour I'd like.
I have an AI that has a fairly extensive recuit list but I really want 2 types to be favoured (i.e. have more of them being recruited).

I've tried recruitment_more but even with the code below it doesn't seem to have any effect?
The frequency of the specified units doesn't seem to change?
The units are minor variants of the normal unit type with an extra possible trait: weak-willed.

Code: Select all

  [side]
...
    recruit=Novice Orcish Shaman,lsb_Orcish Archer,lsb_Orcish Assassin,lsb_Orcish Grunt,lsb_Orcish Crossbowman,lsb_Orcish Slayer,lsb_Orcish Warrior,lsb_Wolf Rider,lsb_Goblin Pillager,lsb_Goblin Knight,lsb_Orcish Leader,lsb_Orcish Ruler,lsb_Goblin Spearman,lsb_Goblin Impaler,lsb_Goblin Rouser
...
    [ai]				# Default aggression (0.4) and caution (0.25) always
      grouping=offensive
       recruitment_more="lsb_Orcish Crossbowman,lsb_Orcish Crossbowman,lsb_Orcish Crossbowman,lsb_Orcish Crossbowman,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager"
...
Then I thought I'd try ai recruitment using pattern=yes but what I'd ideally like to be able to do is specify a "wildcard" type so that most of the recruits are a spread of the recruit list but then bump up the frequency of a few by specifying their type a few times - but I can't seem to do that?

That is have this:

Code: Select all

      [aspect]
        id=recruitment_instructions
        [facet]
          turns=""
          [value]
            [recruit]			# More pillagers (recruitment_more didn't make enough of a difference)
              pattern=yes
              type=",<anything>,<anything>,<anything>,<anything>,<anything>,lsb_Orcish Crossbowman,lsb_Goblin Pillager,lsb_Goblin Pillager"
            [/recruit]
          [/value]
        [/facet]
      [/aspect]
Where <anything> is the wildcard so the AI recruits any unit from the recruit list (so not a specific level or usage etc.).
I tried using an asterisk (*) and nothing at all between the commas but in both cases the AI ignored those entries and only recruited Xbows and pillagers.

So, if anyone can advise me if:
  1. There is a wildcard character for "any unit" in the type= key and if so what it is, and
  2. if not, is there another way to do this?
    (For example changing the unit type's score directly in WML?)
Thanks in advance for your time and trouble,
cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Spannerbag
Posts: 540
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: AI recruitment query - update

Post by Spannerbag »

Tried various options without any success.
Then tried using composite format and specifying all values.
I'm not certain but the AI did seem to recruit more of the preferred unit types, but I'm thinking I might use total instead.

Anyway, as I say, this seemed to work:

Code: Select all

      [aspect]
        id=recruitment_more
        invalidate_on_gamestate_change=no
        invalidate_on_minor_gamestate_change=no
        invalidate_on_tod_change_change=no
        invalidate_on_turn_start=no
        name=composite_aspect
        [facet]
          engine=cpp
#          id=				# Not needed
          invalidate_on_gamestate_change=no
          invalidate_on_minor_gamestate_change=no
          invalidate_on_tod_change_change=no
          invalidate_on_turn_start=no
          name=standard_aspect
          time_of_day=dawn,morning,midday,afternoon,dusk,midnight
          turns=""
          value="lsb_Orcish Crossbowman,lsb_Orcish Crossbowman,lsb_Orcish Crossbowman,lsb_Orcish Crossbowman,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager,lsb_Goblin Pillager"
        [/facet]
      [/aspect]
Maybe changing the invalidate_on_... keys helped?

Might try the original (simple) syntax again, it could be I was just unlucky - even with the multiple pillager entries above the ai seems to recruit only slightly more pillagers and Xbows (and not significantly more pillagers than Xbows).

Or, maybe,the ai just decided to recruit these units purely by chance.
I'll run a few more turns and see what happens.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Spannerbag
Posts: 540
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: AI recruitment query - update 2

Post by Spannerbag »

Hmmm... having run more turns I don't think the above code is doing anything after all.
Oh well, might try total instead.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Spannerbag
Posts: 540
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: AI recruitment query alternative solution

Post by Spannerbag »

Tried the following:

Code: Select all

    [ai]
      ...
     recruitment_pattern="archer,fighter,fighter,mixed fighter,scout,lsb_Orcish Crossbowman,lsb_Goblin Pillager"
      ...
It worked rather well :)

Would still like to know if I used recruitment_more correctly and if there's a wildcard character for type= in [recruit] (I suspect not).

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Celtic_Minstrel
Developer
Posts: 2253
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: AI recruitment query

Post by Celtic_Minstrel »

As far as I can tell, you used recruitment_more correctly and it should have caused the AI to heavily favour recruiting the two unit types listed. That said, I don't fully understand how the type score for a unit is calculated, so it's possible that there are circumstances where adding 100 or 250 to that score isn't all that significant? I'd have to look into the recruitment algorithm in more detail.

There is no wildcard character for types in the recruitment instructions. I believe there's actually an open issue for that on GitHub.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: AI recruitment query

Post by gnombat »

#6006

Apparently, there is actually a wildcard character already: the empty string.
User avatar
Celtic_Minstrel
Developer
Posts: 2253
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: AI recruitment query

Post by Celtic_Minstrel »

However, Spannerbag mentioned that using two consecutive commas with nothing between them didn't have any effect, so it's likely that the empty strings are stripped out when splitting the list. That would mean the empty string only works as a wildcard when it's the only entry.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply