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

AI spell usage in "I take you with me" case #8382

Open
1 task done
crypt47 opened this issue Feb 9, 2024 · 15 comments
Open
1 task done

AI spell usage in "I take you with me" case #8382

crypt47 opened this issue Feb 9, 2024 · 15 comments
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement

Comments

@crypt47
Copy link

crypt47 commented Feb 9, 2024

Preliminary checks

Describe the problem requiring a solution

In current save file an enemy in the castle has pretty high Spell Power and a destructive spell Meteor shower (or something like that). I know this because on some other conditions the spell was used with devastating effect. But currently (if I don't use Fenix for attacking and start by attacking trolls with my archers) the enemy hero uses Berserk spell which I simply canceled by Dispel. The enemy is then locked withing it's castle walls and eliminated with almost zero loses.
Beltway_0051.sav.zip

Describe the possible solution

This is right, that Berserk is optimal for inverting damage. But it can be canceled too easily. The enemy should be more bitchy in presense of strong ranged attackers plus after castle walls. He should switch to "I take you with me" scenario. At least on some Difficalty levels, imho.

Additional info

No response

@crypt47 crypt47 added the improvement New feature, request or improvement label Feb 9, 2024
@crypt47 crypt47 changed the title AI spell usage AI spell usage in "I take you with me" case Feb 9, 2024
@oleg-derevenetz oleg-derevenetz added the AI Artificial intelligence behaviour label Feb 9, 2024
@oleg-derevenetz oleg-derevenetz added this to the Beyond OG scope milestone Feb 9, 2024
@ihhub
Copy link
Owner

ihhub commented Feb 27, 2024

Hi @oleg-derevenetz , I believe we need to adjust the priority for Berserk spells for situations when the opponent hasn't casted a spell and when the creature is not the next in a row to make an action. What do you think?

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Feb 27, 2024

Hi @ihhub AFAIK the AI trend to use the non-damage spells in such a way that they could be easily dispelled by an opponent is well known (this applies not only to Berserk, but to other control spells as well - e.g. Slow, Blind, etc). I'm afraid that trying to solve this problem head-on by simply changing priorities will lead to the fact that AI will almost always use damage spells instead, because it always casts its spell during its first turn. Ideally, we need to implement some kind of "waiting for the right moment" mechanism, but I don't have any good ideas yet on how to formalize this very concept of the "right moment". In the pro gamer's tournaments, the process of choosing a spell and the right moment to apply it is somewhat similar to poker :) Everyone is guessing what spells the opponent have, if you cast a control spell too early, then it can be dispelled, and if it's too late, then you are risking that the opponent will cast Slow/Mass Slow.

@crypt47
Copy link
Author

crypt47 commented Mar 4, 2024

... In the pro gamer's tournaments, the process of choosing a spell and the right moment to apply it is somewhat similar to poker :) Everyone is guessing what spells the opponent have, if you cast a control spell too early, then it can be dispelled, and if it's too late, then you are risking that the opponent will cast Slow/Mass Slow.

I'm really a novice regarding this topic and you're probably doing more cleaver things then I'm going to say, but it looks to me like the computer has to have some strategy too. General algorithm with ranking will not do here. The computer should be like player switching to patterns of strategies. For example it should accumulate rangers and high level of mage abilities to use some strategy #1. Or it may "see" that he is class barbarian with a lot of rangers against class sorcerer, and use different "right moment" according to his tactics #2. You surely know much more then me about statistics prediction and modern AI.) Some randomization in making decisions would make it more interesting. Ideally I guess we all want to play against skynet type AI with neural network.)

@Alucard648
Copy link

What about using Armageddon spell as last ditch effort to end the battle with all creatures on battlefield dead? Especially in scenarios where defeating specific hero is instant win condition for AI.

@oleg-derevenetz
Copy link
Collaborator

What about using Armageddon spell as last ditch effort to end the battle with all creatures on battlefield dead? Especially in scenarios where defeating specific hero is instant win condition for AI.

Currently, AI does not use any "strategic knowledge" during battle. It can cast Armageddon if it is obvious that it's losing the battle, but it can't, say, use tactics like "specially send a hero with a single fast unit to cast Armageddon and win the map".

@crypt47
Copy link
Author

crypt47 commented Mar 4, 2024

What about using Armageddon spell as last ditch effort to end the battle with all creatures on battlefield dead? Especially in scenarios where defeating specific hero is instant win condition for AI.

This is exactly the case in sample save file. I prevent this by keeping only the fast units to take the initiative and locking enemy's melee in castle walls. AI simply can't figure out he's loosing. Because I have a strategy and he just access only the current situation.

@crypt47
Copy link
Author

crypt47 commented Mar 7, 2024

Currently, AI does not use any "strategic knowledge"

I've also noticed that the weak enemy hero often comes across my strong hero. It's very easy to leave an empty castle, wait and kill enemy heroes one by one. They doesn't try to avoid the danger or accumulate forces. Is it somehow related to the absence of strategic view in general?

@oleg-derevenetz
Copy link
Collaborator

Currently, AI does not use any "strategic knowledge"

I've also noticed that the weak enemy hero often comes across my strong hero. It's very easy to leave an empty castle, wait and kill enemy heroes one by one. They doesn't try to avoid the danger or accumulate forces. Is it somehow related to the absence of strategic view in general?

I mean, it doesn't use any strategic knowledge during battle itself. On the adventure map, there are so-called regions, and AI should avoid visiting regions that have strong enemy heroes, but it has its own ifs and buts, e.g. AI still can perform the fog discovery in the "dangerous" regions.

@crypt47
Copy link
Author

crypt47 commented Mar 7, 2024

I mean, it doesn't use any strategic knowledge during battle itself. On the adventure map, there are so-called regions, and AI should avoid visiting regions that have strong enemy heroes, but it has its own ifs and buts, e.g. AI still can perform the fog discovery in the "dangerous" regions.

Yes, ok, but it looks like AI makes completely irrational movies, that can't be explained by the fog of war. It surely comes to the known territory but with a strong enemy. And I've also noticed that starting from some version AI doesn't pick resources anymore (on some maps?). Lot's of it stays on a ground. Should I file a report or is it a known thing?

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Mar 7, 2024

It surely comes to the known territory but with a strong enemy.

The mechanics of all these regions was implemented not by me, but as I can see it applies additional penalties for "dangerous" regions, i.e. there is still a possibility that object with penalty can still be preferred to other objects. Also, as far as I understand, there is a possibility that a powerful enemy hero may, say, be close to the border of the region, and a weak AI hero will run up to the same border, but on the other hand. In general, yes, it would be good to improve this somehow, maybe there will be those who want to do this. There is a TODO comment BTW that suggests not to use regions for this, but to use distances to the enemy heroes instead.

And I've also noticed that starting from some version AI doesn't pick resources anymore (on some maps?). Lot's of it stays on a ground. Should I file a report or is it a known thing?

Sure, if there is a specific save file that demonstrates this issue, it would be nice.

@crypt47
Copy link
Author

crypt47 commented Mar 7, 2024

Fine then. I'll go for the save files. Meanwhile here is Beltway 0037,
Beltway_0037.sav.zip
next move the enemy hero jumps towards Alchemy's Lab despite visible threat.

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Mar 7, 2024

next move the enemy hero jumps towards Alchemy's Lab despite visible threat.

In this case AI hero is moving to the Watch Tower for the fog discovery. But in general I agree that it needs to be improved. For example, it can be done so that AI heroes generally cannot pass within direct reach of enemy heroes who are stronger. Something like this is now done in the AI pathfinder, but in regard to the wandering stacks (and partially enemy heroes in the sense that paving the path right through stronger heroes is not allowed). Anyone who interested can implement this, or maybe I'll take a look later when I have time.

@crypt47
Copy link
Author

crypt47 commented Mar 7, 2024

Thanks for checking. Just to be clear, I've recaptured the Alchemy Lab just after it was recaptured by him. So there is no way the AI couldn't see me in the fog. And I also played a little HoMM3 where the enemy hero always tries to lurk away of stronger opponent. So it's was sometimes a real PITA to find where he managed to hide off the visible area.

@idshibanov
Copy link
Collaborator

idshibanov commented Mar 9, 2024

Forcing an enemy to dispel a spell still beneficial especially when the game has such high impact spells such as Blind and Slow that can be cast by anyone. A proper solution to this problem is to teach Battle AI look and plan few turns ahead rather than evaluating only the current one.

However there's still improvements we can make to get halfway there. Currently as army numbers grow damage spells really fall out of favour. We can increase spell damage heuristic to a nlog2n for example, this way it will be more impactful for late game as spell power scales. Adding a simple check if enemy has already cast a spell this turn or not can help as well.

@crypt47
Copy link
Author

crypt47 commented Mar 9, 2024

Forcing an enemy to dispel a spell still beneficial especially when the game has such high impact spells such as Blind and Slow that can be cast by anyone.

It all depends. I believe that balance is off with antimagic spell. It is rather low-level, can't be dispelled and makes caster toothless in that way he can't compensate for attack/defense disadvantages of it's class. If by dispel we mean Antimagic it's pretty powerful, but not in case of the army that is locked behind castle walls against archers for example.

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

5 participants