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 heroes get stuck in portals #9638

Open
2 tasks done
dtcyganok opened this issue Mar 15, 2025 · 16 comments · May be fixed by #9661
Open
2 tasks done

AI heroes get stuck in portals #9638

dtcyganok opened this issue Mar 15, 2025 · 16 comments · May be fixed by #9661
Labels
bug Something doesn't work

Comments

@dtcyganok
Copy link

Preliminary checks

Platform

Linux

Describe the bug

Sometimes AI heroes get stuck in portals. They can teleport to other portals, but by some reason they decide not to move until the end of the game. I've encountered this strange behavior twice on the maps "Enroth" and "Sudden Siege".

Image

Save file

The stuck hero is in the bottom right corner of the map.

Enroth_0031.zip

Additional info

No response

@dtcyganok dtcyganok added the bug Something doesn't work label Mar 15, 2025
@oleg-derevenetz
Copy link
Collaborator

They can teleport to other portals

In reality, they cannot. Ability to teleport without movement (using the spacebar button) is an fheroes2 extension (in the original HoMM2 you cannot do that) and this extension is human-only, AI currently is not able to do this due to a number of reasons (mostly due to compatibility concerns and a few technical reasons). So this not a bug - if AI cannot move anywhere from the portal (due to too strong guard on a nearby tile, for instance), then it will not be able to teleport to other portals.

@dtcyganok
Copy link
Author

dtcyganok commented Mar 15, 2025

OK, probably there are compatibility concerns and technical reasons.

Still this behavior looks incorrect and unexpected at least. Actually it means that the human player has a huge advantage over AI players on maps with portals.

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Mar 15, 2025

Actually it means that the human player has a huge advantage over AI players on maps with portals.

This extension was introduced by the previous developer team (among many others) but was not removed (unlike many others), because many people like it. On the other hand, if AI will be able to move directly to some specific portal without spending movement points, this, for instance, will break maps that "protect" human players from AI using the random nature of teleports. So the current behavior is a sort of a tradeoff.

@dtcyganok
Copy link
Author

dtcyganok commented Mar 15, 2025

"protect" human players from AI using the random nature of teleports.

Interesting compromise. Though as a human player I use the random nature of teleports to jump to desirable location. So it might be more fair if AI players could do the same. My two pens)

By the way the AI of heroes 3 can do so if I remember it right.

@oleg-derevenetz
Copy link
Collaborator

By the way the AI of heroes 3 can do so if I remember it right.

HoMM3 has the "spacebar mechanics" from the very beginning, unlike HoMM2, which didn't have it, so there are original HoMM2 maps (I don't remember which ones) that use the HoMM2-specific teleport mechanics to make it difficult for heroes to move to certain places of the map (for instance, between the AI "zone" and the human player's "zone"). BTW, the same is related to Whirlpools.

@minuspinus
Copy link

By the way the AI of heroes 3 can do so if I remember it right.

HoMM3 has the "spacebar mechanics" from the very beginning, unlike HoMM2, which didn't have it, so there are original HoMM2 maps (I don't remember which ones) that use the HoMM2-specific teleport mechanics to make it difficult for heroes to move to certain places of the map (for instance, between the AI "zone" and the human player's "zone"). BTW, the same is related to Whirlpools.

It doesn't sound very convincing: there is some map (my grandfather told me, I haven't seen it myself) that will sometimes be harder for a person to play (but it's not certain).
Mechanics that are available to humans should be available to AI as well.

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Mar 16, 2025

It doesn't sound very convincing

I really don't care to "convince" random person who come here to try to push others around. That's not what I do. I write code and explain the tradeoffs I have to make to those who ask me polite questions. You need to end your consumer attitude, I'm not your subordinate.

@minuspinus
Copy link

It doesn't sound very convincing

I really don't care to "convince" random person who come here to try to push others around. That's not what I do. I write code and explain the tradeoffs I have to make to those who ask me polite questions. You need to end your consumer attitude, I'm not your subordinate.

Oleg, I apologize for causing such feelings.
I have been following the project very closely for the last year and have great respect for the work of the whole team.

I will try to rewrite my comment like this:
I am impressed with the high quality of the work done by the team (this applies to all aspects of the project: from work organization, strategy, decision making, to interaction with the community), and I expect that all team decisions are balanced and fair for the players (honest).

According to this document: destrictions
Image

Any modifications in existing balance of the game are strictly prohibited. Monster statistics, building statistics, monster behavior or logic of existing spells, moves and animations must be untouched. There could be few exceptions in skills, spells, monster abilities or animations but such ideas must have a solid reason for it. A proposed idea with such change must contain a proper explanation of existing behavior, the reason of changing it and the effect of this change on existing game balance.

I was expecting a more careful treatment of the basic mechanics of the game, and the fact that the mechanics are being compromised in favor of the human player upsets me.

I think it's wrong. And this mechanic (visiting teleporters and whirlpools) is not done well enough. And should not be used in this way.

@modo-lv
Copy link
Contributor

modo-lv commented Mar 19, 2025

Could the "spacebar behavior" be tweaked to not work on portals (maybe with a setting)? That way it wouldn't conflict with the design integrity of the original maps. (And if there's a setting, even better -- each player can decide the best tradeoff for themselves.)

Although that would require an info message when the player tries to to spacebar a portal, otherwise it will seem like a bug.

@oleg-derevenetz
Copy link
Collaborator

(maybe with a setting)?

Anything but that :) Initially (after the previous development team), the game had many fancy, so-called "experimental options" that affect gameplay (for instance, ability to put two heroes to the castle HoMM3-style or ability to set guardians to capturable objects and so on). At one time, it was decided to abandon options of this kind, the desired behavior should either be unconditionally integrated into the gameplay (just like an ability to hire non-upgraded units when upgraded ones are available - this is also not the original mechanics from HoMM2, but the fheroes2 extension), or not used at all.

In general, I agree that the ability to "reuse" teleports without spending movement points should not be available both to AI and human players. I remember that there were even ideas to simply allow you to select a destination directly using the some kind of menu, something like it's done for the Town Portal spell - they say "why do we need these random jumps at all if hero doesn't spend spell points or movement points anyway?". But for me, the original idea of random portals in HoMM2 is that you can get lost in them by spending movement points. But, anyway, this extension was not removed in time (perhaps because it was not designed as an experimental option), and now, I suppose, there are many people who are just used to it.

@modo-lv
Copy link
Contributor

modo-lv commented Mar 19, 2025

I understand and agree that not every HoMM3 feature needs to be backported, especially ones that that fundamentally alter game mechanics (such as the examples you mentioned).

The spacebar thing feels less like a gameplay mechanic and more like just a UI/QoL improvement (in most cases). If a player lands on a creature dwelling but discovers they have insufficient gold, and then uses another hero (or a market) to get it, making the hero move away and back (wasting valuable movement points) just to open the hiring window again doesn't feel like part of strategic gameplay -- it feels like an awkward UX oversight.

Moving through portals, however, is very much a part of strategic gameplay, and as such it should be preserved from OG if possible. Unlike hiring again from the same dwelling without moving, a portal actually teleports the hero around the map, and it makes sense for such a potentially huge advantage to have a cost (losing unpredictable number of movement points due to randomness).

That's why I feel like "spacebar works, except for portals" could be a good compromise (even if it sounds inconsistent or arbitrary at first).

@minuspinus
Copy link

From Discord:

Been thinking lately about using monoliths and whirlpools.
I think the core mechanic is unacceptably free movement around the map!
so for the current implementation (by space) we need to add a penalty! For example, 150 mp for each spacebar.
Such an implementation would allow the AI to use it normally as well.
A pathfinding skill could reduce this penalty.
I think it's important to leave it randomized (random jumps) - that's what the creators intended) it's not a mistake.

@oleg-derevenetz
Copy link
Collaborator

so for the current implementation (by space) we need to add a penalty! For example, 150 mp for each spacebar.
Such an implementation would allow the AI to use it normally as well.
A pathfinding skill could reduce this penalty.

I believe that instead of inventing various sorts of "special mechanics", we just need to make the portals work exactly like in the original game, that's all.

@minuspinus
Copy link

so for the current implementation (by space) we need to add a penalty! For example, 150 mp for each spacebar.
Such an implementation would allow the AI to use it normally as well.
A pathfinding skill could reduce this penalty.

I believe that instead of inventing various sorts of "special mechanics", we just need to make the portals work exactly like in the original game, that's all.

That would be the best solution!

@dtcyganok
Copy link
Author

I believe that instead of inventing various sorts of "special mechanics", we just need to make the portals work exactly like in the original game, that's all.

Seems like the safest solution. Simple and effective.
Meanwhile I suppose some users won't bе satisfied because it's a bit dull and disappointing.

@LeHerosInconnu
Copy link

LeHerosInconnu commented Mar 20, 2025

Hello everyone,

Related issue, discussion and pull request: #7139, #5625, #9578.

Note: in the case presented in the original post, the AI hero will still be stuck with the way the original game works.
The only way to release the stone liths is to sacrifice the hero (attack the rocs, dismiss the hero), or possibly summon a boat, or teleport the hero to another place of the adventure map or inside a town.
Stone liths will also be released if the red player has remained without a city for more than seven days, and is then eliminated from the game.
The AI could also voluntarily decide to block the stone liths. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't work
Projects
None yet
5 participants