AI Recruitment Deficiency

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

Moderator: Forum Moderators

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 »

Here's an update on my ongoing AI experiment:

I've now played 12 turns on the randomly generated 100 x 100 map. After having drafted Fencers, Mages, and one Cavalryman on the first turn, the AI Loyalists have been drafting mainly Fencers and Bowmen, with the occasional Mage or Cavalryman. Not even one Heavy Infantryman, Spearman, Horseman, or Merman Fighter has been hired by the AI so far. The lack of Mermen isn't a surprise, though, because the map has very little water.

As for the AI Knalgans, after having drafted all Poachers on the first turn, they have been drafting mainly Thieves and Poachers, with the occasional Thunderer. Not even one Gryphon Rider, Fighter, or Ulfserker has been hired by the AI so far.

Interesting how the AI recruits differently on a larger map than on a smaller one, isn't it?
Velensk
Multiplayer Contributor
Posts: 4002
Joined: January 24th, 2007, 12:56 am

Re: AI Recruitment Deficiency

Post by Velensk »

You know what it might be, it might be the weight of the terrain defense overtaking the other considerations. This would explain why its favoring elusive.
"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."
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 »

Velensk wrote:You know what it might be, it might be the weight of the terrain defense overtaking the other considerations. This would explain why its favoring elusive.
That could be.

Anyway, my experiment raises the question of whether some or even many of the common complaints about the Wesnoth AI are based on only a limited experience of how it operates.
User avatar
Coffee
Inactive Developer
Posts: 180
Joined: October 12th, 2010, 8:24 pm

Re: AI Recruitment Deficiency

Post by Coffee »

Maybe this will be useful to someone. I noticed that the AI was recruiting badly in my Campaign (The Great Quest) -- mainly HI/mages for loyalists, gryphons for dwarves, ogres for my outlaw bunch, and woses for elves. It just had a huge preference for expensive recruits, but did sometimes choose some recruits such as horsemen and sometimes not. It plain never recruited thieves for me when I made the outlaw recruit list Thieves,Thugs,Young Ogres,etc. It always recruited thugs and ogres and mostly ogres. The maps I'm talking about are pretty balanced maps in terms of terrain. They also attack at bad times and don't have a sense of time of day or offensive/defensive play.

I think I worked around this well and made some pretty tough AI. I did this in 3 or so workarounds (none should ideally be necessary).

First, I did was change the AI recruitment_pattern for each faction and sometimes the map (eg. no mixed fighters for elves in cave means no fish). This was based on play and by type of map and starting gold it might vary.

Next I changed it so that there would be a random chance of a unit not being available for the AI to recruit (i.e. 1/2 chance of no HI and 2/3 chance of no horsemen, etc.). Then I made it for some units that they would come only after turn 1 (thieves, so they don't scout to their doom before the others are ready to attack). Also, WC's available 1/4 chance after turn 2 (by switching off ghoul and skeleton for a turn). Of course they will recruit whatever unit is next on its own version of the recruitment_pattern (it will modify yours slightly or reorder it).

Lastly I made it so that the enemy has defensive groupings before and during bad time of day and slightly increased offense before good time of day, and more aggression in good time of day with offensive grouping. This works well. You need to tweak the scouts_per_village, leader aggression and (importantly) radius to save AI leader. The right variables will have AI try flanking maneuvers, steal your open village at bad time of day and make a standoffs on good terrain :D Of course in my campaign they are turned more than normal to aggression too :)
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Temuchin Khan wrote:Anyway, my experiment raises the question of whether some or even many of the common complaints about the Wesnoth AI are based on only a limited experience of how it operates.
I am sorry, but that is not at all what your experiment shows. I don't know what "common complaints" you are referring to, but you are not disproving anything by watching a game on an abnormally large map. How the AI responds on a map of that size is interesting and enlightening, but it certainly does not invalidate the experience of playing on the overwhelming majority of smaller maps.

The reason you are seeing something different is because of the parameters of your experiment. Because the parameters are abnormal, the results are abnormal. The only question I see being raised is why you even chose such a huge map to experiment on. It should not come as a big suprise that on a map of vast proportions, the AI behaves differently than it does on a more modest map. As Velensk pointed out, if the AI has among it's unit selection criteria the map terrain, than a huge random map will be a heavy modifier. Random maps tend to clump terrain and can be easily influenced into producing an excess of a particular terrain.

Do you have any reason to infer that your abnormal experiment shows something that those of "limited experience" are overlooking?
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:Anyway, my experiment raises the question of whether some or even many of the common complaints about the Wesnoth AI are based on only a limited experience of how it operates.
I am sorry, but that is not at all what your experiment shows. I don't know what "common complaints" you are referring to, but you are not disproving anything by watching a game on an abnormally large map. How the AI responds on a map of that size is interesting and enlightening, but it certainly does not invalidate the experience of playing on the overwhelming majority of smaller maps.

The reason you are seeing something different is because of the parameters of your experiment. Because the parameters are abnormal, the results are abnormal. The only question I see being raised is why you even chose such a huge map to experiment on. It should not come as a big suprise that on a map of vast proportions, the AI behaves differently than it does on a more modest map. As Velensk pointed out, if the AI has among it's unit selection criteria the map terrain, than a huge random map will be a heavy modifier. Random maps tend to clump terrain and can be easily influenced into producing an excess of a particular terrain.

Do you have any reason to infer that your abnormal experiment shows something that those of "limited experience" are overlooking?
Actually, what you just said is more or less what I meant to say. I'm sorry I didn't say it more more clearly!

In other words, you have said in a more detailed and precise way what I had intended to say, but ended up expressing in an awkward and clumsy way.
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Temuchin Khan wrote:Actually, what you just said is more or less what I meant to say. I'm sorry I didn't say it more more clearly!

In other words, you have said in a more detailed and precise way what I had intended to say, but ended up expressing in an awkward and clumsy way.
Oh. Ok. I guess I just missed that. :oops:
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:Actually, what you just said is more or less what I meant to say. I'm sorry I didn't say it more more clearly!

In other words, you have said in a more detailed and precise way what I had intended to say, but ended up expressing in an awkward and clumsy way.
Oh. Ok. I guess I just missed that. :oops:
Don't worry. It was my fault for not being clearer.

Anyway, I've conducted two more experiments.

First, I made a 100 x 100 map with two castles, twenty-eight villages, and no terrains except grasslands. I played AI Knalgans against AI Loyalists, and both factions acted pretty much the way they did on a 100 x 100 map with a regular assortment of terrains, with one exception - the AI Loyalists drafted more cavalrymen than usual.

Then, I made a 40 x 40 map that was exactly the same as the 100 x 100 map except for its size, and set the same two factions against each other. This time, the AI Knalgans and the AI Loyalists behaved mostly the way they do on a typical, balanced 40 x 40 map - except, again, the AI Loyalists drafted more cavalrymen than usual.

This seems to suggest that for the AI map size outweighs all the other considerations, even terrain defense.
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Temuchin Khan wrote:First, I made a 100 x 100 map with two castles, twenty-eight villages, and no terrains except grasslands. I played AI Knalgans against AI Loyalists, and both factions acted pretty much the way they did on a 100 x 100 map with a regular assortment of terrains, with one exception - the AI Loyalists drafted more cavalrymen than usual.

Then, I made a 40 x 40 map that was exactly the same as the 100 x 100 map except for its size, and set the same two factions against each other. This time, the AI Knalgans and the AI Loyalists behaved mostly the way they do on a typical, balanced 40 x 40 map - except, again, the AI Loyalists drafted more cavalrymen than usual.

This seems to suggest that for the AI map size outweighs all the other considerations, even terrain defense.
Hmmm. That is interesting. Could you be a little more specific about the recruitments of each faction and what is "normal" AI recruitment behavior to you? I'm curious to see how much more the Cavalrymen were recruited.

I again find it strange that the Knalgans (if I'm understanding you correctly) would recruit Footpads in favor of Gryphon Riders on a large map, yet reverse it in a small one. If the deciding factor was terrain, the Footpad would seem always win out, yet it is inconsistent. I wonder if there is an algorithm the AI uses to determine village distance from the keep and the most cost-effective means of putting a unit on it. Something like distance vs unit cost vs movement speed. That might explain a change in behavior with map size.
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:First, I made a 100 x 100 map with two castles, twenty-eight villages, and no terrains except grasslands. I played AI Knalgans against AI Loyalists, and both factions acted pretty much the way they did on a 100 x 100 map with a regular assortment of terrains, with one exception - the AI Loyalists drafted more cavalrymen than usual.

Then, I made a 40 x 40 map that was exactly the same as the 100 x 100 map except for its size, and set the same two factions against each other. This time, the AI Knalgans and the AI Loyalists behaved mostly the way they do on a typical, balanced 40 x 40 map - except, again, the AI Loyalists drafted more cavalrymen than usual.

This seems to suggest that for the AI map size outweighs all the other considerations, even terrain defense.
Hmmm. That is interesting. Could you be a little more specific about the recruitments of each faction and what is "normal" AI recruitment behavior to you? I'm curious to see how much more the Cavalrymen were recruited.
Actually, all I meant was that it hired several cavalrymen instead of just one or two.
I again find it strange that the Knalgans (if I'm understanding you correctly) would recruit Footpads in favor of Gryphon Riders on a large map, yet reverse it in a small one. If the deciding factor was terrain, the Footpad would seem always win out, yet it is inconsistent. I wonder if there is an algorithm the AI uses to determine village distance from the keep and the most cost-effective means of putting a unit on it. Something like distance vs unit cost vs movement speed. That might explain a change in behavior with map size.
Yes, that is strange. A few days ago, however, I conducted another test that points to something even stranger:

I made a 100 x 100 map that consisted of nothing but two castles, 28 villages, and mountains. The AI Knalgans started out hiring Gryphon Riders and dwarves, but then switched to hiring mostly outlaws, even though the map would have been a dwarf paradise.

The AI Loyalists relied mainly on Mages, Fencers, and Bowmen. Oddly enough, however, they also hired four cavalrymen, even though on a map like this they were virtually useless.
Last edited by Temuchin Khan on October 17th, 2011, 12:35 am, edited 1 time in total.
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Temuchin Khan wrote:I made a 100 x 100 map that consisted of nothing but two castles, 28 villages, and mountains. The AI Knalgans started out hiring Gryphon Riders and dwarves, but then switched to hiring mostly outlaws, even though the map would have been a dwarf paradise.
I can explain this one. The AI has no capacity to save for future units. After their gold & income begins to drop, they go for the cheapest units they can afford.

This actually matches the pattern that I'm beginning to form about AI recruitment style. My hypothesis is that it revolves around money. This starts by using the best units for capturing villages on the current map. That's why you saw Gryphon Riders when it was all Mountains, and why they would use Footpads when the terrain is all Grassland. Initially, they recruit the most expensive units too, particularly if they've been given a boost to income or gold. Now, once they run out of gold, AND if they do not have a sizeable income, they'll start switching to cheaper units.

I think other considerations, such as the resistance/damage calculations that Velensk mentioned early on in this thread are secondary. I am also leaning to the belief that these calculations are very simple, tending to maximise damage without regard to retaliation, as shown by Velensk's DA strategy and the AI's moronic reaction. Instead they focus on the resistances.
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:I made a 100 x 100 map that consisted of nothing but two castles, 28 villages, and mountains. The AI Knalgans started out hiring Gryphon Riders and dwarves, but then switched to hiring mostly outlaws, even though the map would have been a dwarf paradise.
I can explain this one. The AI has no capacity to save for future units. After their gold & income begins to drop, they go for the cheapest units they can afford.

This actually matches the pattern that I'm beginning to form about AI recruitment style. My hypothesis is that it revolves around money. This starts by using the best units for capturing villages on the current map. That's why you saw Gryphon Riders when it was all Mountains, and why they would use Footpads when the terrain is all Grassland. Initially, they recruit the most expensive units too, particularly if they've been given a boost to income or gold. Now, once they run out of gold, AND if they do not have a sizeable income, they'll start switching to cheaper units.

I think other considerations, such as the resistance/damage calculations that Velensk mentioned early on in this thread are secondary. I am also leaning to the belief that these calculations are very simple, tending to maximise damage without regard to retaliation, as shown by Velensk's DA strategy and the AI's moronic reaction. Instead they focus on the resistances.
That would seem to work for the most part, but I don't think it would explain why AI Knalgans would draft Gryphon Riders on a 40 x 40 map, where a larger number of cheaper but still fast units would arguably get more villages more quickly.

On the other hand, maybe it's an example of the AI getting the most expensive unit it can afford, so maybe you're right after all.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: AI Recruitment Deficiency

Post by Mabuse »

imo, the recruitment of ai could perform better, if it would not be based on some calculations taking whatever factors into account, instead based on RULES that HUMAN PLAYERS use for recruitment.
(for that these "rules" would need to get analyzed and implemented in the most optimal way)

as i see it now, the ai recruitment is triyng to make a "self-running" recruitment based on some calculations.
of course the advantage of such a "CALCULATING" system is clear to me:
it is extremely versatile and can handle recruitment lists even of unkown units and unkown factions and unkown maps.

the downfall is the overall bad performance.

imo, if a random recruitment shows better results then the calculated recruiment then the ai should be overworked in that part. if i would be an ai designer (and i also scripted ai back in the past - not for wesnoth) then this would be something i would not accept. (still i think that CALCULATIONS could be the better solution since they are able to handle unkown unts, unknown factions and unkown maps)

the calculations may need to get adjusted and probaly more factors need to get added.
The best bet is your own, good Taste.
Insinuator
Posts: 706
Joined: January 6th, 2004, 10:42 pm
Location: Portland, OR

Re: AI Recruitment Deficiency

Post by Insinuator »

Mabuse wrote:imo, the recruitment of ai could perform better, if it would not be based on some calculations taking whatever factors into account, instead based on RULES that HUMAN PLAYERS use for recruitment.
(for that these "rules" would need to get analyzed and implemented in the most optimal way).
What rules?
Mabuse wrote:as i see it now, the ai recruitment is triyng to make a "self-running" recruitment based on some calculations.
What calculations?
Mabuse wrote:imo, if a random recruitment shows better results then the calculated recruiment then the ai should be overworked in that part. if i would be an ai designer (and i also scripted ai back in the past - not for wesnoth) then this would be something i would not accept. (still i think that CALCULATIONS could be the better solution since they are able to handle unkown unts, unknown factions and unkown maps)
So, you're proposing a complete overhaul of the AI recruitment style, but you have no specifics and no proof that it would even be better. Additionally, you're already refusing to do any of the work for this completely hypothetical setup. What did you add here?
Rya
Posts: 350
Joined: September 23rd, 2009, 9:01 am

Re: AI Recruitment Deficiency

Post by Rya »

What rules?
I guess he means like:
"Never waste more than 50% of the starting gold on scouts."
and
"If you are loyalist you should at least spend 20% of the gold into Spearmen."
and
"Try to keep the variety of different units high so you can counter all units of the enemy."
and
"If you are playing rebels and play against a noob only recruit Woses and laugh at him when he says they are OP."
Wesnoth
The developer says "no".
Post Reply