Currently Online

Latest Posts

Topic: are there still plans to teach the AI to micromanage level 10 soldiers? (and other stuff about AI efficiency)

king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-08-19, 18:22

Some time ago, someone was trying to get the AI to get level 10 soldiers by micromanaging.

For those not familiar with the process, it goes like that (I'd like to be able to put this under a collapsible spoiler to make the wall of text easier to navigate; some indentation would be good too):

  • 1) make training camp and arena, but set them to contain 0 soldiers.
  • 2) wait for them to be filled up with all the wares needed to promote a soldier to the highest grade.
  • 3) let one soldier go into the arena, so it trains to evasion 2.
  • 4) once that soldier's training is complete, make it go to the training camp. Since you can't choose which soldier go on the camp, you have to repeatedly kick soldiers out until one with the evade 2 promotion goes.
  • 5) your training camp will now fully upgrade that soldier already trained in evasion, since it has all the necessary resources.
  • go back to 2

Level 10 soldiers are very expensive, but since they will go heal after winning a fight, they can mow down legions of lesser soldiers with negligible losses. And a human using that strategy has a huge advantage. Currently, the AI takes 5-6 hours at least to get level 10 soldiers.

I was playing "large ocean" in hardcore mode (1v7 starting from the worst position), and I was mildly disappointed. Starting is difficult. You'll get attacked by 2 enemies before you can really make a good economy. Hard to survive while you work on that first level 10. But then...

Then it becomes a piece of cake. With a handful of level 10 soldiers, you plow through your starting opponents. Then you keep expanding, you meet new opponents, and you tear them apart too - and all while hardly losing any soldier. The later opponents, far from facing a human weakened by a prolonged struggle with their allies, face a human who has made a much better economy than they did, and crumble like a wet paperbag. Only the final foes in their islands will manage, by the time you get to reach them, to provide some good soldiers to challenge you, but only a handful of them; most of their resources will be squandered on half-promoted soldiers. So you face 10-20 fully promoted soldiers, and then it's back to tearing apart wet paper bags.

So, in the interest of providing a consistent challenge to skilled human players, I got some ideas there.

As far as I know, those previous attempts to teach the AI to micromanage failed because they could not get the AI to use a soldier with evasion in the training camp. All the soldiers with evasion would go to man the front line, and a poor rookie would go to the training camp and get all the weapon and armor promotions. Which is a huge waste, because a soldier fully promoted on attack and defence but lacking evasion is hugely expensive, but nowhere near as effective as a fully promoted one. It does easily, and with it the resurces to make a couple dozens lesser soldiers.

My idea is, could we teach the AI to do the micromanaging trick only as long as it has no enemies in sight? If there are no enemies around, the fully promoted soldiers would not go to the front line. Therefore they would be available to go in the training camp and get fully upgraded. Therefore, when the human finally get to meet them, they will be able to field some fully promoted soldier. And the human won't be able to steamroll over them without taking losses, and will be happy to have found a more significant challenge.

Another idea: some promotions are clearly more cost-effetive than others. Evade promotions are the best, because they take no metal. Then attack promotions, because they can triple the attack value of your soldier. Last are the defence promotions; they only increase the survivability of the soldier by about one third; a soldier with attack and evade but without defence still has a 30-35% chance against a fully trained soldier - and it costs much less. It may even be more cost-effective, in fact. The AI does not take that into account, so you can see soldiers trained in defence but not in attack, and often not even in evasion. I can't overstate how huge a waste of resources that is. A barbarian soldier fully upgraded in defence (I've seen the likes many times in the armies of the AI) costs like a half-dozen lesser soldiers, not counting the food needed for the training, and it is only mildlly more effective.

So, we could simply instruct the AI to focus on the important promotions first. How? By telling it to stop the higher training until the front line is manned with the best soldiers. Such an AI will initially remove all the food from the training camp because the arena has to work to get all the front soldiers to evade. Once all the soldiers in the buildings set with "prefer heroes" have evade promotions, the AI will get food and weapons to the training camp, but not armor/helms. Those will arrive only when all the soldiers in the aforementioned buildings are fully promoted in attack. Oh, and of course the training camp won't train any soldier lacking evasion; it will kick it out instead (we could allow attack 1 because it's cheap enough to go to a soldier without evade, and it makes a pretty goood difference). For the atlanteans it's going to be a bit trickier because the HP promotion is cost-effective, the shields are not; so the order is evade - HP - attack - shields. This would vastly increase the efficiency of resource allocations.

Last, since many humans don't know/want to micromanage, those settings could be activated by a specific AI level, which could be called the hard level (since so far we lack one).

By the way, the description of the AI levels could be improved. As far as I know there is no description anywhere of what the difficulty levels do. We could have a window like we have for the game mode, that appears if you hover the mouse cursor over the option. The description could be as simple as: very easy: the AI is severely limited in its production, and won't be able to upgrade its soldier at full - easy: the AI is moderately hindered in its production capacity, though that only becomes apparent on larger maps (remember that as of right now all the difficulty levels do is setting hard limits to how many buildings the AI can make) - normal: the AI has no special limitations - hard (if we implement it with my proposal) the AI has no limitations and will be able to perform some tricks with micromanagement.

Of course all this stuff is targeted at build 20.

P.S. The soldier levels page (https://wl.widelands.org/wiki/SoldierLevels/) still is not updated for the increased attack values we gave the barbarians during a rebalance some five months ago.

Edited: 2016-08-19, 18:29

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2016-08-20, 22:05

Well I would implement some of your ideas, but they seems too complicated for me to code. Could you for the beginning suggest 1 or 2 simple rules for trainingsites that would improve current situation?


Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 00:54
Posts: 351
Ranking
Tribe Member
Posted at: 2016-08-21, 06:02

To clarify, training buildings use two groups of resources. This post calls them:
(1) "Food": Meat/fish/bread which is used for every single upgrade
(2) "Equipment": Weapons, Armor, Helmets, Shields, and Strong Beer which are only used for one or two specific upgrades.

Give them something similar to the Rookie/Hero decision you have for standard military buildings -- except "hero" would mean "partially trained, but this building has the equipment to train them more".

Also, consider giving the Empire and Atlantean AI a higher priority for building evasion-boosting buildings, as (unlike all other training) their evasion only requires food and not equipment.

Finally, it's been a while since I fired up Widelands. Is the AI set to aim for a specific ratio of the two types of training buildings (training camp vs arena/colosseum, or dungeon vs labyrinth)? If not, you should consider doing so. After all, if they have a lopsided ratio, their warriors either lag behind in one, or the other sees little use because their warriors already maxed out their skills with it! Similarly, you don't want the equipment produces to be lopsided; if the barbarians have one warmill but three helm smithies, something is wrong. ;)

Edited: 2016-08-21, 06:10

Top Quote
king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-08-21, 09:05

DragonAtma wrote:

To clarify, training buildings use two groups of resources. This post calls them: (1) "Food": Meat/fish/bread which is used for every single upgrade (2) "Equipment": Weapons, Armor, Helmets, Shields, and Strong Beer which are only used for one or two specific upgrades.

Why would you consider strong beer to be equipment? it only costs grain and water, it is food. "equipment" is what costs metal.

But, let's see if I can codify some simple instructions for the proposals:

a) the AI micromanage fully promoted soldiers when no enemy is around

  • 1) WHILE "no enemy land in your line of sight"
  • 2) set all training site food priority as "high"; set all training site and arena capacity to 0
  • 3) IF arena contains at least 4 bread and 3 fish/meat THEN set its capacity to 1. Set it back to 0 when the soldier is trained and leaves the building.
  • 4) IF training site contains at least 10 bread and 6 fish/meat and 1 piece of each equipment THEN set its capacity to 12.
  • 5) When a soldier enters, IF it does not have the evade 2 promotion, THEN kick it out. ELSE (if it does have the evade 2 promotion) close all other slots of training site.

This should return a fully promoted soldier.

Modifications for atlanteans:

  • 3) IF labyrinth contains at least 6 bread and 6 fish/meat and 1 equipment of each type THEN set its capacity to 1. Set it back to 0 when the soldier is trained and leaves the building.
  • 4) IF dungeon contains at least 4 bread and 4 fish/meat and 1 piece of each equipment THEN set its capacity to 8.
  • 5) When a soldier enters, IF it does not have the evade 2 promotion and healt 1 promotion, THEN kick it out. ELSE (if it does have the evade 2 promotion) close all other slots of training site. *// this may cause soldiers without defence to get promoted, but defence is not a very iportant promotion anyway, we can live with it.

This set of instructions would not be executed if enemies are on sight.

b) the AI micromanages to get the more cost-effective promotions first when enemies are on sight

  • 1) WHILE "enemy land in your line of sight" (basically, this is an IF/THEN/ELSE condition with a1)
  • 2) set all training site food priority as "high"; set all training site and arena capacity to 0
  • 3) IF arena contains at least 4 bread and 3 fish/meat THEN set its capacity to 1. Set it back to 0 when the soldier is trained and leaves the building.
  • 4) IF training site contains at least 6 bread and 6 fish/meat and 1 piece of each weapon THEN set its capacity to 12.
  • 5) When a soldier enters, IF it does not have the evade 2 promotion, THEN kick it out. ELSE (if it does have the evade 2 promotion) close all other slots of training site.
  • 6) IF 12 soldiers have entered the building and havee been kicked out, keep the building closed for 5 minutes before repeating the cycle

This is more complicated for atlanteans:

  • 2b) WHILE "you have soldiers in your front line buildings without weapon promotions" THEN set labyrinth to contain no shields
  • 3) IF labyrinth contains at least 4 bread and 4 fish/meat THEN set its capacity to 1. Set it back to 0 when the soldier is trained and leaves the building.
  • 4) IF dungeon contains at least 4 bread and 4 fish/meat and 1 piece of each equipment THEN set its capacity to 8.
  • 5) When a soldier enters, IF it does not have the evade 2 promotion, THEN kick it out. ELSE (if it does have the evade 2 promotion) close all other slots of training site.
  • 6) IF 12 soldiers have entered the dungeon and have been kicked out, keep the dungeon closed for 5 minutes before repeating the cycle.
  • 7) WHILE "all your soldiers in front line buildings have weapon promotions" THEN set the labyrinth to contain shields
  • face-glasses.png IF labyrinth contains at least 4 bread and 4 fish/meat and 1 golden tabard and shield and advanced shield THEN set its capacity to 8.
  • 9) When a soldier enters the labyrinth, IF it does not have the evade 2 and weapon 4 promotions, THEN kick it out. ELSE (if it does have the evade 2 promotion) close all other slots.

Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 00:54
Posts: 351
Ranking
Tribe Member
Posted at: 2016-08-21, 10:08

It's true, strong beer is definitely not produced from iron -- but I wasn't categorizing them by what they're made of. Instead, I was categorizing them by how many upgrades required them: 1-2, or all/nearly all.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2016-08-21, 19:19

Well, the proposed change looks like a work for 50+ hours.

If it was like 2 hours, I would gladly do it, but it is too much for me...


Top Quote
king_of_nowhere
Avatar
Topic Opener
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2016-08-22, 09:07

DragonAtma wrote:

It's true, strong beer is definitely not produced from iron -- but I wasn't categorizing them by what they're made of. Instead, I was categorizing them by how many upgrades required them: 1-2, or all/nearly all.

From the point of view of cost-effectiveness, the important thing is how much it ddoes cost and what benefits it does provide.


Top Quote
gnarfk
Avatar
Joined: 2015-01-05, 15:18
Posts: 70
Ranking
Likes to be here
Location: France
Posted at: 2016-08-22, 09:23

Personally, i have another idea to solve this.

Instead of trying to teach the AI micromanaging, why don't we change the way the training sites work ? We could think of a "train the best soldiers first" button ? and something like in the military buildings "prefer heroes". In that way, micromanaging will not be needed to create fully upgraded soldiers.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2016-08-22, 20:24

gnarfk wrote:

Personally, i have another idea to solve this.

Instead of trying to teach the AI micromanaging, why don't we change the way the training sites work ? We could think of a "train the best soldiers first" button ? and something like in the military buildings "prefer heroes". In that way, micromanaging will not be needed to create fully upgraded soldiers.

+1


Top Quote
fk
Avatar
Joined: 2013-07-30, 21:58
Posts: 151
Ranking
At home in WL-forums
Posted at: 2016-08-23, 12:16

@Tibor

What you need is the possibility to suppress the training of rookies.


Top Quote