Latest Posts

Topic: Improving the AI

hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-24, 18:43

Tibor wrote:

OK, this was never seriously reviewed by another person, so just carry on.

I only wanted to say that it was not an intention to "always attack"

I never assumed that. However to keep the 4 eye principle I'd need your review when finished. And I am glad for the assistance you already offered me on so much occasions.


Top Quote
JanO
Avatar
Joined: 2015-08-02, 10:56
Posts: 177
Ranking
At home in WL-forums
Posted at: 2020-04-24, 19:40

Is this a good opportunity to brainstorm a bit together, how such evaluations might give meaningful results? face-wink.png


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-24, 22:51

JanO wrote:

Is this a good opportunity to brainstorm a bit together, how such evaluations might give meaningful results? face-wink.png

I don't understand what you mean however I am curious to your explanation.
Anyhow found a real big bug as calculate_strength is not working correctly. Hunting down the root cause.
(this means the weakness of AI attacking isn't accountable to genetic algorithm) as this bug prevented it from ever being used in the past.)


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-24, 23:26

ok found it basic evade an basic defense were not subtracted fromm 100 for normalization.
proper attacker selction missing.
However pushed a branch for review.


Top Quote
blind3rdeye
Avatar
Joined: 2020-03-26, 07:47
Posts: 74
Ranking
Likes to be here
Posted at: 2020-04-25, 02:22

That's good news about identifying a calculate_strength bug. I imagine fixing that will have a noticeable benefit - and be a lot easier than making structural changes!

By the way, I just started a game with an AI ally, and I notice that they tried to build a training camp and a battle arena at the same time; but they don't yet have a gold supply. So both buildings have been sitting close to completion for a long time, keeping two builders tied up, spending a lot of resources; and not getting the benefit of either building. (If they'd just picked one of those, they'd be able to finish it and use it; but trying to build both at once really stuffed things up.)

Maybe that kind of resource management issue is an edge case that not worth worrying about; but I'm thinking maybe the AI could consider whether or not they have a source for a required resource before deciding to spend more than they have. (ie. they don't have a gold source, so they shouldn't try to build something that uses more gold that they already have!) - ... Or perhaps such checks already exist, and this is just a cause of starting the second building before the gold had been allocated to the first building.


Top Quote
JanO
Avatar
Joined: 2015-08-02, 10:56
Posts: 177
Ranking
At home in WL-forums
Posted at: 2020-04-25, 08:40

I mean, do you plan to code new algorithms that decide if and where AI attacks? Then we should maybe collect some points what AI could evaluate for this decision.

Examples:

  • Prefer attacking small milsites, close distance and no other nearby defenses
  • Don't attack stronger enemies, if they have more heroes
  • Prefer an attack (or multiple attacks) that are capable of destroying special buildings like warehouses or trainingsites, even if this causes losses
  • Consider building big milsites before an attack to have more attackers (for destruction of special buildings)
  • Maybe different modi operandi like:

    • massive attacks to kill specific heroes with rookies, if the opponent has only a low amount of those
    • massive attacks on many milsites simultaneously to conquer land (maybe calculate a value of the region to conquer, like not depleted mountains, very fertile areas in maps with only few fertile land...)
    • if the opponent's soldiers have maximum the [same level of promotions -1] as the own ones, attack with only one soldier so the enemy can be weakened without own losses
  • Don't attack with wounded soldiers (unless enemy's soldiers are hurt even worse)

  • Hunt down wounded heroes
  • ...
Edited: 2020-04-25, 08:40

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-25, 11:54

JanO wrote:

I mean, do you plan to code new algorithms that decide if and where AI attacks? Then we should maybe collect some points what AI could evaluate for this decision.

Examples:

  • Prefer attacking small milsites, close distance and no other nearby defenses
  • Don't attack stronger enemies, if they have more heroes
  • Prefer an attack (or multiple attacks) that are capable of destroying special buildings like warehouses or trainingsites, even if this causes losses
  • Consider building big milsites before an attack to have more attackers (for destruction of special buildings)
  • Maybe different modi operandi like:

    • massive attacks to kill specific heroes with rookies, if the opponent has only a low amount of those
    • massive attacks on many milsites simultaneously to conquer land (maybe calculate a value of the region to conquer, like not depleted mountains, very fertile areas in maps with only few fertile land...)
    • if the opponent's soldiers have maximum the [same level of promotions -1] as the own ones, attack with only one soldier so the enemy can be weakened without own losses
  • Don't attack with wounded soldiers (unless enemy's soldiers are hurt even worse)

  • Hunt down wounded heroes
  • ...

Ok understood. Answer is:
Some of them have already been there, but aren't working. So my first goal is to make the genetic algorithm already there working. The bug found yesterday prevented this.
But I need to still implement proper Attack soldier selection.
First I will implement to only attack with soldiers that have at least x% of their max_health where x will be subject to genetic algorithm and should range from 75 to 100.
Other suggestions welcome. Epecially whether it makes sense to attack with only strong soldiers or keep them for defense. Additionally how many soldiers should be sent per attack, and waht would be a general value to determine all these deciions.

Please keep in mind this needs to work acceptable in every situation and can't be tailored to any specific situation.


Top Quote
JanO
Avatar
Joined: 2015-08-02, 10:56
Posts: 177
Ranking
At home in WL-forums
Posted at: 2020-04-25, 13:14

Yes, you are right.
It looks like you are going to code quite some parts here from scratch, so maybe we could consider to implement some additional parameters as placeholders, that can later be used for difficulty-settings.
Does AI have information on the troops inside defending buildings?

When you implement the %min_health, I suggest to make (at least) two thresholds. One (upper) for new attacks, one lower for hunting down wounded soldiers. The number of attackers should be dependent on the modus of the attack (as I mentioned) and on the number (and strength?) of expected defenders.


Top Quote
teppo

Joined: 2012-01-30, 08:42
Posts: 423
Ranking
Tribe Member
Posted at: 2020-04-25, 14:28

Having an AI that plays well in all circumstances is difficult. AI that can handle one map is a lot easier.

Therefore, would it be a good idea, if it was possible to include AI DNA into a map.

If it was possible to run the training loop by itself then training such DNA for selected maps would be within reach.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-04-25, 15:52

teppo wrote:

Therefore, would it be a good idea, if it was possible to include AI DNA into a map.

The problem here can be that interpretation of wai files by C++ can change (also in this branch) so after long time you could have very differing C++ and wai files

If it was possible to run the training loop by itself then training such DNA for selected maps would be within reach.

Do you mean like let your computer to train for 24 hours or so? The process of handling the wai files is still too fragile for this.


Top Quote