Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battle: computer attacks me first and lose the battle #8206

Closed
1 task done
fheroes2bugs opened this issue Dec 29, 2023 · 17 comments
Closed
1 task done

Battle: computer attacks me first and lose the battle #8206

fheroes2bugs opened this issue Dec 29, 2023 · 17 comments
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement

Comments

@fheroes2bugs
Copy link

Preliminary checks

Describe the problem requiring a solution

My hero and computer hero have nearly equal army. But for unknown reason computer decides to attack me and ... he loses the battle.
Here is red hero attacking my hero:

red.suicide.mp4

Describe the possible solution

Computer should calculate his power more accurate, he must not attack enemy if he has equal power.

Additional info

Version 1.0.11
Save:
suicide.zip

@fheroes2bugs fheroes2bugs added the improvement New feature, request or improvement label Dec 29, 2023
@oleg-derevenetz
Copy link
Collaborator

Computer should calculate his power more accurate, he must not attack enemy if he has equal power.

From an AI perspective, the power is not the same here because of the spells. Although the set of spells is comparable for both heroes, your hero has just one spell point, so he in fact is not able to cast battle spells, while AI hero has 55 spell points. AI in this case relied on spells and I must say he was close to victory. It is impossible to calculate everything with 100% accuracy.

@oleg-derevenetz oleg-derevenetz added the AI Artificial intelligence behaviour label Dec 29, 2023
@oleg-derevenetz oleg-derevenetz added this to the Beyond OG scope milestone Dec 29, 2023
@fheroes2bugs
Copy link
Author

Computer should calculate his power more accurate, he must not attack enemy if he has equal power.

From an AI perspective, the power is not the same here because of the spells. Although the set of spells is comparable for both heroes, your hero has just one spell point, so he in fact is not able to cast battle spells, while AI hero has 55 spell points. AI in this case relied on spells and I must say he was close to victory. It is impossible to calculate everything with 100% accuracy.

Before attacking other heroes computer can do some "phantom fight" keep it in memory, and if result is not suitable (computer loses hero) then not to attack.

@ihhub
Copy link
Owner

ihhub commented Dec 29, 2023

Computer should calculate his power more accurate, he must not attack enemy if he has equal power.

From an AI perspective, the power is not the same here because of the spells. Although the set of spells is comparable for both heroes, your hero has just one spell point, so he in fact is not able to cast battle spells, while AI hero has 55 spell points. AI in this case relied on spells and I must say he was close to victory. It is impossible to calculate everything with 100% accuracy.

Before attacking other heroes computer can do some "phantom fight" keep it in memory, and if result is not suitable (computer loses hero) then not to attack.

That's called cheating.

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Dec 29, 2023

That's called cheating.

And also it's costly and useless against a human player because the AI vs AI battle is conducted far from the manner in which a human player plays. If AI-controlled hero has defeated another AI-controlled hero, it does not mean at all that it will defeat the same hero, but controlled by a human.

@fheroes2bugs
Copy link
Author

fheroes2bugs commented Dec 29, 2023

And also it's costly and useless against a human player because the AI vs AI battle is conducted far from in the same manner in which a human player plays. If AI-controlled hero has defeated another AI-controlled hero, it does not mean at all that it will defeat the same hero, but controlled by a human.

I'd say the opposite. At the moment, at the battle, computer (hero/neutral creatures) is very strong, I always get better result if I perform fast battle. There are some rare cases like #8182 or #7952 but they are very rare and you should be very experienced to remember it.
So if computer wins computer, then he will win human too. If human is not using some smart spells like blind or berserk etc or using some known weakness like issues 8182 and 7952...

Aslo, if computer can see how much mana I have - isn't he cheating?
Can't we perform cheating with "phantom fight" only for impossible diffuculty? I play the expert difficulty map with and impossible game difficulty and enemy just suicides me. There are not much ways to get AI more stronger and I see it is exactly suitable way.

@oleg-derevenetz
Copy link
Collaborator

So if computer wins computer, then he will win human too

According to my experience, AI plays far from my typical results. I'm always wondering when @Branikolog say that AI is "too smart" and should be nerfed for auto battles. AI can be easily distracted from approaching and blocking the archers, it cannot use some spells at all (like Teleport) or cannot use another spells that can win the battle by themselves (like Berserk) in a "good enough" manner, etc. Experienced human player just acts differently. Also, as I already said, performing the full battle is a very costly operation.

@Branikolog
Copy link
Collaborator

According to my experience, AI plays far from my typical results. I'm always wondering when @Branikolog say that AI is "too smart" and should be nerfed for auto battles. AI can be easily distracted from approaching and blocking the archers, it cannot use some spells at all (like Teleport) or cannot use another spells that can win the battle by themselves (like Berserk) in a "good enough" manner, etc. Experienced human player just acts differently. Also, as I already said, performing the full battle is a very costly operation.

According to my observations (streamers or even my own experience), instant battle AI proposes a really good battle outcome quite often, which players don't even expect to be achieved themselves and they gladly accept it. This is valid for me and quite skilled streamers (I consider us as above average players). If we speak about not so skilled player - he will use instant battle results in 80% of cases. Half a year ago I watched a speedrun of SW campaign, where the speedrunner managed to finish the whole campaign in about 1+ hour, where he played barely 10 manual battles. the rest was won by the instant battle AI. :)

@zenseii
Copy link
Collaborator

zenseii commented Dec 29, 2023

I'd like to add that the reason you can speed run or play with only instant battle results is because the AI's adventure map logic isn't on par with an average human player yet. If you play better on the adventure map, then you can safely accept the few extra losses from doing a battle in auto mode, compared to manually battling them out and getting fewer losses.

The main, or most influential, shortcomings of the battle AI, as far as I've experienced, are these:

  1. If threatened it will use spells on its first creature's turn instead of waiting until you've cast a spell to see if there's a better spell to cast, like casting Bless on a creature that will act after several others have gone - But, this is EXACTLY the way I see most human Heroes 2 players play too. I've lost count of how many times I've watched a human player cast Blind during the battle's first turn, only to be completely surprised by the AI dispelling it immediately the turn after.
  2. It will stand still and accept your barrage of lightning bolts thinking that the only way you can hurt it is with your few troops that it considers much weaker than its troops - Most human players will realize that they need to change their tactic in this case. This has been addressed.
  3. It doesn't make decisions thinking some battle rounds ahead - Most human players think at most one battle round ahead. Teaching the AI this is quite complex logic.
  4. Not avoiding to expose itself to multi-hex attacks and spells. - Most human players take this into account to some extent.

All in all though, for most players, these aren't bad decisions that will ultimately lead to the AI losing the game.

Instead, the adventure map shortcomings are much greater, and they are the main reason the AI can easily be beat, because if you play effectively on the adventure map then your army will be much greater than the AI's, to the extent that these suboptimal battle decisions are irrelevant. Most players struggle when the AI has a greater army.

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Dec 29, 2023

It will stand still and accept your barrage of lightning bolts thinking that the only way you can hurt it is with your few troops that it considers much weaker than its troops

Well, actually, AI takes into account your attack spells as "shooters value" in addition to the value of your actual stacks of shooters, and this will influence its behavior, AI will go offensive if you have advantage in the shooters value even if you don't have any actual shooters, like in the last video from this comment:

#8047 (comment)

However, there are always buts and ifs and corner cases, so...

@zenseii
Copy link
Collaborator

zenseii commented Dec 29, 2023

@oleg-derevenetz.

Well, actually, AI takes into account your attack spells as "shooters value"

Thanks for pointing that out! The AI has been evolving quicker than I'm able to keep track. This means that there are even fewer holes in the battle AI's tactics.

Nevertheless, I've also experienced being attacked by an AI player where the instant result showed them losing. Upon replaying that match and turning on AUTO, it showed that the AI lost because my troops got good morale and probably some good damage rolls.

This is nothing that needs to be fixed. I'm afraid the AI will become too defensive if we try to account for such possibilities when it is deciding whether to attack. These cases happen for human players too, but they have the luxury to reload and retry.

@zenseii
Copy link
Collaborator

zenseii commented Dec 29, 2023

Actually, looking at that battle again, I can see that one of the AI flaws I had forgot to mention - exposing itself to multi-hex attacks, had a significant impact on the outcome. I suppose the AI correctly estimated that it would win the battle, but during the battle it didn't avoid the double-hex attack from your phoenixes.

In other words, improving that logic of the AI is a better target than letting the AI cheat.

@fheroes2bugs
Copy link
Author

I'm afraid the AI will become too defensive if we try to account for such possibilities when it is deciding whether to attack

You have main hero... will you attack enemy hero, that has the near equal army?
Well, if it is map 1 on 1 or on map when only 2 players left... it can be done. But on map with 6 players when you attack strong enemy, your main forces will be destroyed and other 4 players will destroy you and computer you have attacked. There is no chance to win if you lose your whole army, and other 4 players didn't perform such an hasty move, isn't it?..

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Dec 29, 2023

This is nothing that needs to be fixed.

If this is going to improve over time, it's unlikely by pre-playing battles. This is not only mega-expensive, but also impossible to cache. When comparing the calculated power of armies, you can firmly rely on the fact that the power of armies with which you have not interacted does not change on your turn, and you should only recalculate the power of your army and make a comparison with a pre-cached value of an enemy (or neutral) army. In the case of pre-played battles, you will have to conduct them again with any change in the power of your army, leveling up the hero, learning new spells, and so on, the results of early battles can no longer be relied upon. In short, this is hardly an option.

@kitovyj
Copy link

kitovyj commented Dec 30, 2023

Please don't let AI cheat. It kills all the fun. That is what they did in Heroes V, AI never loses a battle there, they don't even perform a real battle against neutrals, just deducing the army size according to the estimated losses. That looks weird and feels boring.

@fheroes2bugs
Copy link
Author

fheroes2bugs commented Jan 2, 2024

Please don't let AI cheat. It kills all the fun. That is what they did in Heroes V, AI never loses a battle there, they don't even perform a real battle against neutrals, just deducing the army size according to the estimated losses. That looks weird and feels boring.

What about make strong AI only for impossible diffuculty? Easy/normal/hard/expert could have fun with stupid AI that loses the battle and do other "fun" moves.

@kitovyj
Copy link

kitovyj commented Jan 2, 2024

Please don't let AI cheat. It kills all the fun. That is what they did in Heroes V, AI never loses a battle there, they don't even perform a real battle against neutrals, just deducing the army size according to the estimated losses. That looks weird and feels boring.

What about make strong AI only for impossible diffuculty? Easy/normal/hard/expert could have fun with stupid AI that loses the battle and do other "fun" moves.

Sure, then let's just give AI 100k gold and 10 dragons at the beginning. Or maybe 10x monster health and +3 permanent luck? It's not that difficult to make the game hard to win. Making AI an interesting opponent is a different thing.

@ihhub
Copy link
Owner

ihhub commented Apr 13, 2024

This issue could have been fixed with the latest changes in AI defence logic and double hex creature behavior. I assume that Sprites would attack Phoenix rather than defending Grand Elves.

I am closing this issue as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement
Projects
None yet
Development

No branches or pull requests

6 participants