AI Recruitment Deficiency

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

AI Recruitment Deficiency

Post by Insinuator »

This is for 1.8.6. I've been recently playing a lot of games versus the AI on a variety of multiplayer maps. Now, I know the AI is stupid in general. So I give them large bonuses for their starting gold and income to make it more challenging. But one thing that has been bugging me lately is the homogenenous nature of the units two AI teams recruit.

Against the Knalgan Alliance, the AI ALWAYS starts off with a flood of Gryphon Riders, followed by a smattering of Dwarves. Rarely, if ever, do I see them recruit Footpads, Thieves, or Poachers. This gives them a very strong initial offense, but when that blows over, they're pushovers. Against the Loyalists, the AI refuses to recruit Spearmen or Horsemen, instead heavily emphasizing Mages and Heavy Infantry. This puts a lot of damage dealers on the field, but they're weak defense and obvious vulnerabilities leave them open for horrific counterattacks.

I'm just wondering why the AI ignores some units during recruitment? Particularly the overlooking of the Spearman offends my sensibilities. Spearmen should be the bread and butter of Loyalists army versus virtually any foe, yet they seem to consistently favor higher cost units. My theory is actually that the AI searches for the "best" units it CAN afford, so when income bonuses are given, this artificially skews it towards more expensive (and often less effective) units.
Velensk
Multiplayer Contributor
Posts: 4002
Joined: January 24th, 2007, 12:56 am

Re: AI Recruitment Deficiency

Post by Velensk »

These are the things I know:
It starts by looking at the number of villages on the map and recruits what it considers to be an appropriate number of units with the 'scout' usage picking its favorite of the available.
It will then recruit according to either a predefined or random usage pattern picking it's favorite of the available for each type.

I am not entirely sure how it picks a favorite but I know that it both checks a units movement/defense relative to the map and checks a units resistances and compares to the enemy unit attacks and vice versa. I suspect this is one of the big reasons why heavy infantry are so favored because when you look at it mathmatically, their resistances are quite intimidating. If your enemy has grunts then the heavy infantry would earn a double score vs them or something like. Almost every unit has some attack or another (blade or pierce) that a heavy infantry very good against. I'm pretty sure that damage is factored in as well and I'm nto sure what else.

EDIT: Interesting experiment I just preformed on 1.9. I choose undead against loyalist computer and recruited only dark adepts to see if it might prefer spearmen to HI under those conditions. The AI recruited no fighter types at all, instead apparently believing bowmen, mages, and cavalry to be the ideal counter.

EDIT2: And if I do the exact same thing except with a skeletal leader (had a dark wizard last time), he will throw in an occasional heavy infantry. I suspect that the AI in this case is working differently than it does in campaigns (which is what I have the most experience with) but operating on principles similar to the ones I outlined.
Last edited by Velensk on September 19th, 2011, 11:31 pm, edited 2 times in total.
"There are two kinds of old men in the world. The kind who didn't go to war and who say that they should have lived fast died young and left a handsome corpse and the old men who did go to war and who say that there is no such thing as a handsome corpse."
Caphriel
Posts: 994
Joined: April 21st, 2008, 4:10 pm

Re: AI Recruitment Deficiency

Post by Caphriel »

Ninja'd by Velensk, who covered almost everything I was going to say, and then some.

On unit "usage": If you examine the WML for the Loyalist units, for example, you'll see that both the HI and the spearman have usage=fighter in the unit data. Same thing with the gryphon and footpad: they're both usage=scout. So when Velensk says "It will then recruit according to either a predefined or random usage pattern picking it's favorite of the available for each type." those are the types he is talking about.

If you already knew about that, then I can't help you :-? I don't know much about how the units are ranked, and what I do know is from 1.6 or older.
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

I already know about the usage pattern, I've manipulated it in WML for several scenarios. On a custom scenario, where you tweak the pattern you can get good recruits to fight against. But in a standard one, not so much.
Velensk wrote:I am not entirely sure how it picks a favorite but I know that it both checks a units movement/defense relative to the map and checks a units resistances and compares to the enemy unit attacks and vice versa. I suspect this is one of the big reasons why heavy infantry are so favored because when you look at it mathmatically, their resistances are quite intimidating. If your enemy has grunts then the heavy infantry would earn a double score vs them or something like. Almost every unit has some attack or another (blade or pierce) that a heavy infantry very good against. I'm pretty sure that damage is factored in as well and I'm nto sure what else.
This is interesting, and does help to explain why. It is not good, however, and seems to lead to an overabundance of HI & GR (Gryphon Riders).
Kolbur
Posts: 122
Joined: April 29th, 2009, 9:33 am

Re: AI Recruitment Deficiency

Post by Kolbur »

HI should have usage = useless trashcan... :wink:

I thought that thre AI has already been improved in 1.9. Wasn't there an AI project from someone going on?
Generally I think the AI could be much better if it wasn't a poor attempt at strong AI and instead was designed like an expert system, trying to apply the experience from skilled players to it.
Rya
Posts: 350
Joined: September 23rd, 2009, 9:01 am

Re: AI Recruitment Deficiency

Post by Rya »

The irony of it all is that the game is more challenging against an AI set to recruit completely randomly rather than the standard AI pattern.
Wesnoth
The developer says "no".
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Have you tried that often? I have a hard time believing a random order would be more challenging. It might be a little unexpected and suprising, but harder? If so, though, I'd be interested in trying it out for future MP matches.
User avatar
TheBladeRoden
Posts: 168
Joined: July 16th, 2007, 8:01 am

Re: AI Recruitment Deficiency

Post by TheBladeRoden »

how do you get it to recruit completely randomly?
Founding Father of Columbia
Rya
Posts: 350
Joined: September 23rd, 2009, 9:01 am

Re: AI Recruitment Deficiency

Post by Rya »

If you want the AI to recruit randomly you need to add some XML code to the map and run it as "vs AI" scenario rather than just a map.

Here is the code snippet you need for random recruit:

Code: Select all

      [modify_side]
        [ai]
          recruitment_pattern=
          recruitment_ignore_bad_combat=yes
          recruitment_ignore_bad_movement=yes
        [/ai]
      [/modify_side]
I always use this in my "vs AI" scenarios which I'm observing quite often and I can tell you that it's quite noticable that players seem to have more problems beating the AI that recruits randomly than beating the AI that only recruits 1-3 different units depending on map and enemy. The biggest gap is with Loyalists. They are so much better when recruiting randomly.
Wesnoth
The developer says "no".
Atz
Art Contributor
Posts: 313
Joined: August 21st, 2008, 2:22 am

Re: AI Recruitment Deficiency

Post by Atz »

Insinuator wrote:Have you tried that often? I have a hard time believing a random order would be more challenging. It might be a little unexpected and suprising, but harder? If so, though, I'd be interested in trying it out for future MP matches.
Yes, it's noticeably better when recruiting randomly. Most Wesnoth factions are designed to operate with a mixture of unit types, and although random recruitment is not optimal it will generally mean you have a balanced mix of units capable of handling various situations. The AI's normal recruitment, on the other hand, tends to result in a hugely unbalanced force with glaring weaknesses which can be easily exploited, because it thinks certain units are so good that it should recruit a truckload of them and nothing else. And it's terrible at judging which units are actually "good" or can be spammed. It's like a newbie who thinks that Drake Burners are super-cool because they're, like, big dragon dudes who breathe fire, so surely an army of nothing but Drake Burners will be totally awesome and beat everything!
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

That sounds reasonable. I am curious, then, why is unit recruitment set the way it is currently? It seems that someone put some well-meaning effort into making the system work the way it does now. There must be some reason it is the way it is.

For now, I'm going to use a WML "patch" akin to Rya's to affect random recruits. But unless someone has compelling evidence to suggest otherwise, I'd like to humbly suggest that random recruitment be made the default selection for MP scenarios.
Rya
Posts: 350
Joined: September 23rd, 2009, 9:01 am

Re: AI Recruitment Deficiency

Post by Rya »

I suggested reworking the AI recruitment pattern a long time ago even explaining ways to improve it and the reply I got was basically "You don't know how complicated it really is, if you insist you know how to improve it then just do it yourself.", after that I just gave up and decided to just use that WML script in all my scenarios.

The script I posted is not the only way to improve it. It is also possible to limit the number of units the AI can have of each unit-type at the same time (e.g. only allow it to recruit 4 scouts at max, only if one scout dies it can recruit one again), then the AI gets forced to recruit something else if it tries to recruit the same unit over and over.
Wesnoth
The developer says "no".
User avatar
Temuchin Khan
Posts: 1800
Joined: September 3rd, 2004, 6:35 pm
Location: Player 6 on the original Agaia map

Re: AI Recruitment Deficiency

Post by Temuchin Khan »

Insinuator wrote:[As] the Knalgan Alliance, the AI ALWAYS starts off with a flood of Gryphon Riders, followed by a smattering of Dwarves. Rarely, if ever, do I see them recruit Footpads, Thieves, or Poachers. This gives them a very strong initial offense, but when that blows over, they're pushovers. [As] the Loyalists, the AI refuses to recruit Spearmen or Horsemen, instead heavily emphasizing Mages and Heavy Infantry. This puts a lot of damage dealers on the field, but they're weak defense and obvious vulnerabilities leave them open for horrific counterattacks.

I'm just wondering why the AI ignores some units during recruitment?
Early this morning, as an experiment, I tried a game in Wesnoth 1.9.9 on a randomly generated 100 x 100 map with all the default factions and the khalifate. On the first turn, the AI Loyalists recruited mostly skirmishers and mages, with one cavalryman; while the AI Knalgans recruited all footpads and no gryphon riders.

I did this because I remember playing games on the monstrous old "Battle World" map in which the AI Knalgans relied mostly on footpads, poachers, thieves, and thugs, but drafted very few dwarves.

So does map size have something to do with it?

And out of curiosity what factions have you been playing as? Have you always been picking the same faction, or a variety of factions? Does that make a difference?

EDITS: I changed "poachers" to "footpads." I meant to say "footpads." I also changed a few other things to make my meaning clearer and eliminate superfluous comments.
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Temuchin Khan wrote:Early this morning, as an experiment, I tried a game in Wesnoth 1.9.9 on a randomly generated 100 x 100 map with all the default factions and the khalifate. On the first turn, the AI Loyalists recruited mostly skirmishers and mages, with one cavalryman; while the AI Knalgans recruited all footpads and no gryphon riders.

I did this because I remember playing games on the monstrous old "Battle World" map in which the AI Knalgans relied mostly on footpads, poachers, thieves, and thugs, but drafted very few dwarves.

So does map size have something to do with it?

And out of curiosity what factions have you been playing as? Have you always been picking the same faction, or a variety of factions? Does that make a difference?
Well, I've very rarely played on a map that enormous before. Most of the ones I play on are close to 40 x 40 or something like that. I find it amusing that on a map of that enormity, the AI would choose Footpads over Gryphon Riders. :lol2: The choice of Fencers (I assume that is what you mean by "skirmishers") and Mages doesn't suprise me; the AI doesn't appreciate Cavalrymen as much as it should.

I play every faction, for I usually pick Random. I haven't noticed a big difference in how the AI responds to my faction, but that pattern is more subtle than what I'm referring to. I am curious, does the AI know what units you have immediately or do they have to wait for them to be revealed via FoW?

Now I have a couple questions for you: What were your village settings on that map? Did you give the AI teams any bonuses to gold or income?
User avatar
Temuchin Khan
Posts: 1800
Joined: September 3rd, 2004, 6:35 pm
Location: Player 6 on the original Agaia map

Re: AI Recruitment Deficiency

Post by Temuchin Khan »

Insinuator wrote:
Temuchin Khan wrote:Early this morning, as an experiment, I tried a game in Wesnoth 1.9.9 on a randomly generated 100 x 100 map with all the default factions and the khalifate. On the first turn, the AI Loyalists recruited mostly skirmishers and mages, with one cavalryman; while the AI Knalgans recruited all footpads and no gryphon riders.

I did this because I remember playing games on the monstrous old "Battle World" map in which the AI Knalgans relied mostly on footpads, poachers, thieves, and thugs, but drafted very few dwarves.

So does map size have something to do with it?

And out of curiosity what factions have you been playing as? Have you always been picking the same faction, or a variety of factions? Does that make a difference?
Well, I've very rarely played on a map that enormous before.
And I don't do it very often myself. It can take weeks to finish a game on a map that size!
I find it amusing that on a map of that enormity, the AI would choose Footpads over Gryphon Riders. :lol2:
Strange, isn't it?
Now I have a couple questions for you: What were your village settings on that map? Did you give the AI teams any bonuses to gold or income?
I had the village settings at 25/1000, and I did not give the teams any bonuses to their gold and income.

However, I recently saw AI Knalgans behave exactly the way you describe on an experimental map I made ("Mountains and Valleys"), even without any bonuses to their gold and income. It's a map with a fair number of mountains, albeit scattered around, and I still trounced the AI Knalgans with Loyalists.
Post Reply