Big AI flaw with dead leaders factions

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

Moderators: Forum Moderators, Developers

sacredceltic
Posts: 55
Joined: October 20th, 2013, 4:07 pm

Big AI flaw with dead leaders factions

Post by sacredceltic » February 1st, 2016, 4:57 pm

One big flaw I noticed with AI, in a multi-player context, is AI doesn't make a difference between troops from dead leaders factions and those from still alive leaders. This is very silly, because it doesn't focus on the remaining alive enemies, giving them space and time to focus and prey on them, and rather waste time cleaning the remnants of dead leaders factions, which doesn't make sense, apart from gaining a few experience points...

User avatar
Pentarctagon
Forum Administrator
Posts: 3981
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Big AI flaw with dead leaders factions

Post by Pentarctagon » February 2nd, 2016, 12:50 am

Though I would imagine it does make it easier to take over the defeated enemy's villages.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

gfgtdf
Developer
Posts: 1164
Joined: February 10th, 2013, 2:25 pm

Re: Big AI flaw with dead leaders factions

Post by gfgtdf » February 2nd, 2016, 1:43 am

I actually dont see why this is a flaw. I'd think that units form defeated sides threaten your unit just like unit from living sides.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

sacredceltic
Posts: 55
Joined: October 20th, 2013, 4:07 pm

Re: Big AI flaw with dead leaders factions

Post by sacredceltic » February 2nd, 2016, 1:43 pm

That's not true. Troops from defeated sides usually keep themselves in villages. They attack you only if you come next to them and they assess they're stronger. Otherwise, they leave you alone. Since the villages they occupy are as much a liability for your remaining actual ennemies with living leaders than for yourself, you should just ignore them and focus on defeating still living leaders. The condition of victory is the defeat of leaders, not of their remaining troops.

gfgtdf
Developer
Posts: 1164
Joined: February 10th, 2013, 2:25 pm

Re: Big AI flaw with dead leaders factions

Post by gfgtdf » February 2nd, 2016, 1:51 pm

Well if i were in a mp team game with a defated leader i'd defniteley not just not just put all may remaining units in villages, specially if these villages could also be used by my teampartner who has still a leader. On the mp server you can quite often observe isars games were one of the players has already its leader lost, and usually they try to get as much as possible out of their remaining units.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
tekelili
Posts: 1038
Joined: August 19th, 2009, 9:28 pm

Re: Big AI flaw with dead leaders factions

Post by tekelili » February 2nd, 2016, 2:17 pm

@sacredceltic: You are claiming to change an AI behavior wich pleases most of players and scenario designers. And you are claiming it form a very doubtfull point of view, because AI behavior is not exactly coded to "have sense" or "look clever", it has as main target provide fun gameplay. If you think some scenario would enjoy different AI behavior you could be right, but you should be carefull before promote ruin lot of scenarios wich designers were very aware about that AI behavior.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II

sacredceltic
Posts: 55
Joined: October 20th, 2013, 4:07 pm

Re: Big AI flaw with dead leaders factions

Post by sacredceltic » February 2nd, 2016, 4:25 pm

@gtgtdf

I'm speaking of playing against AI, not of humans teaming with AI. Of course, allies, human or AI, should keep on fighting even when their leaders are dead, until there is still one ally with a living leader.

But if I have 4 DIFFERENT opponents and 2 have their leaders already dead, I don't waste time fighting their remaining troops. Rather, I focus on the remaining alive one and try to finish him off to win. But AI doesn't do that, which is very stupid, because the case has been ignored in setting the objectives.
AI should improve, and to improve, it has to set the right objectives, the ones that human beings themselves set for themselves.

@tekelili
You are claiming to change an AI behavior wich pleases most of players and scenario designers. And you are claiming it form a very doubtfull point of view, because AI behavior is not exactly coded to "have sense" or "look clever", it has as main target provide fun gameplay. If you think some scenario would enjoy different AI behavior you could be right, but you should be carefull before promote ruin lot of scenarios wich designers were very aware about that AI behavior.
Not changing existing scenarios is an argument to freeze all improvements forever. By these standards, Wesnoth should never progress.

Victory is the sole valid ultimate standard, whatever the game, and focusing on remaining troops of dead opponents (when they are not allied to still living ones) is just a ridiculous behaviour that doesn't help victory at all.

Are we not going to improve AI because it unbalances old scenarios that nobody wants to play anymore because, once finished, they're just boring ?

Playing against a stupid AI is boring and such conservatism is killing all games.

User avatar
Gyra_Solune
Posts: 263
Joined: July 29th, 2015, 5:23 am

Re: Big AI flaw with dead leaders factions

Post by Gyra_Solune » February 2nd, 2016, 6:03 pm

Well, it depends on the situation. If you have an enormous horde of level 2 enemies then even without a leader, you need to focus on tearing them down before actually going for the kill. And to be honest, it might be wise to do so even against smaller forces since that's basically free XP if you can surround and isolate the remaining enemies. However, if it's one or two trolls stuck on the other end of the map then I do not believe the AI is likely to even go for them.

Basically, I'm going to need a better description of what exactly the situation was for the AI, because in certain circumstances, yes, it can be more important to strike at what's left of an enemy army, even if it doesn't have a leader anymore, than it is to necessarily focus on the next leader.

sacredceltic
Posts: 55
Joined: October 20th, 2013, 4:07 pm

Re: Big AI flaw with dead leaders factions

Post by sacredceltic » February 2nd, 2016, 9:37 pm

I'm going to need a better description of what exactly the situation was for the AI, because in certain circumstances, yes, it can be more important to strike at what's left of an enemy army,
OK, then you misread me completely.
I explain again.

Say you fight 2 AI players, that are not allied. AI player 1 manages to kill AI player's 2 leader. What should AI player 1 do now in order to win against the remaining player (ie YOU) ?
a) waste its time fighting remaining troops from ALREADY DEFEATED player 2, while you mass your troops against him (that's what AI actually does, WHATEVER THE CIRCUMSTANCES!)
b) forget about ALREADY DEFEATED player 2 remaining troops (which just remain quietly in villages and can thus be ignored...) and focus on FIGHTING YOU, its SOLE REMAINING ENNEMY ?

User avatar
iceiceice
Developer
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Big AI flaw with dead leaders factions

Post by iceiceice » February 2nd, 2016, 10:10 pm

Thoughts:

1)
player 2 remaining troops (which just remain quietly in villages and can thus be ignored
They might not do this though, right? They might just try to attack for revenge, and kill many more of the AIs units than if he engaged them or zocced them properly.

2) I think you need to take a more realistic view of how the AI works.
  • The AI does not try to win.
    The AI does not know how to win. It is ignorant of the victory conditions.
  • Instead, there are a series of subroutines that control units, that are run in an arbitrary order.
  • The most important is the attack subroutine. The AI looks at all the move-attack combinations it could make this turn, and tries to pick out the most efficient one, and executes it. Efficiency is partly based on simulating the attack in question, and partly based on the gold costs of the units. Then it repeats this until it can't attack anymore.
  • There are a few other subroutines, including village grab, recruit, and some others.
  • The AI does not have any concept of "defend", it has only, recruit, grab villages, and attack basically. It cannot form a line. It has no real concept of zoc, for instance, it has no idea how to Zoc trap your scout that stole a village.
  • The AI generally does not "see forward" into the next turn at all. It does not contemplate how you might respond to its move, it doesn't consider whether you might be able to kill its leader the next turn. Instead there is a hack which can be used to force the AI leader to stay on the keep so the AI doesn't get it stupidly killed, which people find unfun.
  • The AI does not play differently depending on what time of day it is, other than seeing the efficiency numbers change in it estimate. It doesn't play differently at morning vs at afternoon, even though any decent human opponent would.
  • So far as I know the AI does not even distinguish between different sides. It sees only "enemy unit". I don't think it even sees or considers allied units at all.
This thread thus seems to me like many of the previous "AI is flawed" posts, in which people point out "the AI lacks common sense in the following situations".

Indeed, the AI is not at all like a human opponent, it's rather like a mangy dog that attacks you as viciously as possible whenever possible.

You need to set expectations appropriately, or start talking / thinking about how to engineer a better AI *framework*.

As I recall the one time that the AI will often elect not to attack is when your unit is 1 xp from levelling and has enough hp that it cannot possibly die, and so the AIs units will take retal damage and achieve nothing if they attack. Obviously, some developer thought that it was common sense not to attack in this situation, so in this case, the AI simply declines to attack -- and this "common sense" behavior also is considered a flaw by some and is exploitable by skilled players, and was also reported as a bug.

My point is that in general, pointing out "the AI lacks common sense in the following situation" is not really actionable by the developers. We can't just hack common sense into the AI, and if we try, we may just create more problems and make a bigger mess.

It's very hard to tell if a change that we make actually made the AI better, and frankly, a lot of the AI code is probably entirely broken anyways. As I recall, in 1.10 there was a function called "powerProjection" or something which the default AI might use to estimate how much "power" it could sent to a given hex in some rough sense, but the function was implemented incorrectly and actually it just returned an uninitialized value (random data), or something similarly bad. I recall that I patched this particular thing 2 or 3 years ago. My current belief is that a C++ programmer interested in improving the AI, would better spend their time by trying to find and fix bugs like that, than actually investigating AI behavior in any particular scenario.

The truth is that no one has looked at the C++ code that backs up the AI in many years, and probably it should all be audited for bugs and rewritten for simplicity. At this point, it makes more sense IMO to just start over and make a better AI framework, rather than suggest various changes and patches to improve the existing AI, because as mentioned by tekelili, hacking in stuff like this now is a good chance to break the many UMC scenarios that may rely on obscure AI behaviors, and honestly we're not that likely to actually realize a big improvement to make it worth it.

I'm not sure what would be the best way to write this or present this, but it does seem that every few months or so we get reports like these about some bad AI behavior that a player observed in a game, or we get bug reports on the bug tracker about things like this. Maybe we need some kind of sticky thread / FPI item / Wiki page with a guide or layman's overview of the AI and how to give the most useful kind of feedback about the AI? :hmm:

User avatar
tekelili
Posts: 1038
Joined: August 19th, 2009, 9:28 pm

Re: Big AI flaw with dead leaders factions

Post by tekelili » February 2nd, 2016, 10:27 pm

sacredceltic wrote:Are we not going to improve AI because it unbalances old scenarios that nobody wants to play anymore because, once finished, they're just boring ?

Playing against a stupid AI is boring and such conservatism is killing all games.
Well... I was thinking in extremly fun and well designed scenarios that are still in constant development and are played in multiplayer server every day, like my signature one ;)
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II

sacredceltic
Posts: 55
Joined: October 20th, 2013, 4:07 pm

Re: Big AI flaw with dead leaders factions

Post by sacredceltic » February 3rd, 2016, 8:55 am

They might just try to attack for revenge
AI doesn't know what a "revenge" is. I think you don't know AI. AI is just stupid. It just tries to achieve fixed goals. The problem is, some goals are not properly set. "revenge" has never been a goal for AI (unless you're talking about specific scenarios that I don't know about. I'm speaking of general standard AI behaviour.)

When a standard AI faction leader dies, its remaining troops try to take refuge in villages, and just wait there to prey on weaker creatures passing by. That's the STANDARD AI behaviour.
So wasting time fighting these remaining troops which don't pose any problem against your global strategy (which is to beat other LIVING LEADERS) is stupid. However, that's what AI remaining players do.

sacredceltic
Posts: 55
Joined: October 20th, 2013, 4:07 pm

Re: Big AI flaw with dead leaders factions

Post by sacredceltic » February 3rd, 2016, 9:05 am

We can't just hack common sense into the AI,
Maybe not you, but surely somebody else can. It's just a matter of setting goals properly, ie, setting the priority on attacking still living leaders faction's troops (again, I'm not speaking of situations where a dead leader's faction is still allied with a living one, because, of course, in this case, it's the whole alliance that must be taken into account and considered as a unique ennemy)

The argument you use saying "we can't have a more intelligent AI" is just like "we don't want to improve Wesnoth because it's going to unbalance our old boring scenarios that we spent half our life elaborating", it's the recipee for Wesnoth to become an old frozen game incapable of evolving.
It's crystal clear to me that the evolution of Wesnoth, and its gaming appeal goes through a cleverer AI.
Setting this default priority of fighting living leaders/alliances rather than dead ones is plain simple.

I had never read so many "No I want to continue playing against a stupid AI" in my life. Stunning!

User avatar
Pentarctagon
Forum Administrator
Posts: 3981
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Big AI flaw with dead leaders factions

Post by Pentarctagon » February 3rd, 2016, 9:16 am

sacredceltic wrote:Setting this default priority of fighting living leaders/alliances rather than dead ones is plain simple.
It's not prioritizing fighting a defeated side, it's prioritizing claiming villages.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

Whiskeyjack
Posts: 423
Joined: February 7th, 2015, 1:27 am
Location: Germany

Re: Big AI flaw with dead leaders factions

Post by Whiskeyjack » February 3rd, 2016, 10:09 am

Wow sacredceltic,

chill some and cool your head off. You clearly ignored most of iceiceice´s post and the "developer" tag on his profile. Not knowing a whole lot about the current coding possibilities with AI I´m way more inclined to believe his (seemingly) professional assessment than your rambling.

For example take those two points of his into consideration:
iceiceice wrote: The AI does not try to win.
The AI does not know how to win. It is ignorant of the victory conditions.
iceiceice wrote:So far as I know the AI does not even distinguish between different sides. It sees only "enemy unit". I don't think it even sees or considers allied units at all.
As long as those statements are true all your suggestion of "easy" solutions are garbage.

And I can´t shake the feeling that it is you who is focused on one single type of scenarios, namely one player vs. different AIs in special cases where one AI will defeat another.

The only useful (but not in any way new or innovative) statement you made is that one important point of improving Wesnoth would be to improve the AI. iceiceice explained in a very sensible fashion, why tunneling on small side cases like yours might actually make matters worse and even if it works would not be worth the effort. If you want a better AI that badly, get your C++ pants on and delve into the code...
Under blood-red skies an old man sits in the ruins of Carthage contemplating prophecy.

Post Reply