ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.58k stars 360 forks source link

Adventure map, wrong size path arrow for a step from sand on a road #7231

Open Branikolog opened 1 year ago

Branikolog commented 1 year ago

Preliminary checks

Platform

Windows

Describe the bug

When a hero steps on a road path arrow show low penalty.

fheroes2:

image

While in the OG this step is shown as penalized:

image

Save file

path arrow.zip

Additional info

No response

oleg-derevenetz commented 1 year ago

Hi @Branikolog OG displays it wrong. There is a road with movement cost 75 on this tile:

tile

so there is no penalty. Arrows show the penalty for moving OVER this tile and not TO this tile (for example, there is no arrow at all when you are moving to a neighboring tile, just the cross), and there is penalty 75 when you are moving OVER this tile because it's a road.

Branikolog commented 1 year ago

Hi, @oleg-derevenetz ! According to my screenshot we can see two "short" arrows. I suppose this should indicate, that we can make two steps without penalty. But this is not the case, as in this particular case step to the road and from the road consumes 200 movement points. Hero makes only 1 step over the road with 75 penalty. In the OG we can see only one "short" arrow here, which is more intuitive.

oleg-derevenetz commented 1 year ago

@Branikolog

According to my screenshot we can see two "short" arrows. I suppose this should indicate, that we can make two steps without penalty.

The first step is never marked by an arrow. Arrow indicates penalty while moving OVER the tile, and that large arrow below the castle entrance is wrong because we are moving over the road on this tile. So on the OG screenshot we are making two steps over the sand (the first step is over the tile with hero, so there is no arrow) and after the second one we are on the road, so the third step is performed with penalty 75, therefore there should be small arrow near the castle entrance and not the large one. There is always one arrow less than steps on the way:

path

On this screenshot there is a step without an arrow.

oleg-derevenetz commented 1 year ago

Let's simplify the situation a bit:

og

Do you think that all arrow sizes are fine here? I don't think so.

This screenshot from OG demonstrates that arrow length on the particular tile indicates penalty while moving OVER this tile, and not TO this tile:

terrain

Hero makes 3 steps over the sand here (by moving over his own tile + over 2 tiles with long arrows) with penalty 200 and when he steps on the grass, there is 100 penalty and therefore the arrow that corresponds to the first step over the grass terrain (the fourth step and the third arrow in order) is short.

P.S. BTW OG is somewhat confused when paving the path here:

https://github.com/ihhub/fheroes2/assets/32623900/3db01cbf-8433-4a40-932e-e8089dfe0d0c

Sometimes it thinks that there is a road below the castle (in this case the total cost would be 200+200+200+75=675), but sometimes it thinks that there is no road (total cost 200+200+300=700).

Branikolog commented 1 year ago

@oleg-derevenetz

This screenshot from OG demonstrates that arrow length on the particular tile indicates penalty while moving OVER this tile, and not TO this tile:

Correct me, if I'm wrong, in the case from the issue hero makes just 1 movement with penalty 75. All other steps require 200 movement points. But the path shows 2 short arrows indicating, that I can make two steps without penalty.

There is always one arrow less than steps on the way:

I really don't care much about the missing movement arrow. To have cross in the end we need to sacrifice first step visual representation or the last step visual representation. But in the middle of the path there should be consistency between penalized steps hero makes and the number or long/short arrows.

mov count

Right now I can see confusing two short arrows, but the real movement point losses tell me, that I made only 1 step over the road with 75 penalty.

Between, crossing the road hero doesn't make any unpenalized steps. But there's 1 short arrow saying that hero makes 1 step with 75 penalty, which is not the case actually.

image

OG: image

Sorry for bothering you with this. I remember you and @LeHerosInconnu spent much time working on path rules. I just want to to find out, how does it work, as it seems for me working incorrectly.

I actually meet this inconsistency trying to replicate another bug. At some moment I understood, that I don't understand how it actually works (regarding arrow size logic). :D

So here's the bug I finally caught. (The issue seems familiar to me, but I couldn't find any thread on github here.)

image

oleg-derevenetz commented 1 year ago

@Branikolog the consensus was that arrows are not about movement points spent by a hero, but about a tile's own penalty, i.e. the arrow length on a tile should match the tile penalty displayed by the "quick info" window on this tile. In this issue's case two steps were taken over road tiles with "native" penalty 75 (displayed by the quick info), thus we should have two short arrows.

oleg-derevenetz commented 1 year ago

@Branikolog

So here's the bug I finally caught. (The issue seems familiar to me, but I couldn't find any thread on github here.)

Well, it's not quite a "bug":

movement

In this case due to the "last move" rule the hero will spend the same amount of movement points both if he goes straight and if he goes zigzag (because he performs the "last move" over the road tile with "native" penalty 75 in straight direction, and he has 125 movement points left on the second road tile), so this trajectory looks weird, but it's nonetheless legitimate:

https://github.com/ihhub/fheroes2/assets/32623900/3965648f-8cc6-4e4e-b8b7-1c34e2570836

P.S. Regarding the "last move" rule see this:

https://handbookhmm.ru/2-logistics

If the hero does not have enough movement points for a diagonal step on the current landscape, but enough for a straight step (including on the road, if the hero is on the road), then he can take a step in any direction at the price of a straight step.

Emphasis is mine. Although I admit that not everything is completely clear with the roads, because on the roads the penalty of a "straight step" depends on the direction of this step and on the presence of the road on the neighboring tile, but in the current implementation it is done like this.

P.P.S. Here is similar situation from OG ("similar" in terms of last move from the road tile):

https://github.com/ihhub/fheroes2/assets/32623900/24023775-afe2-4f4d-b536-329420f76473

This hero has undoubtedly less than 200 movement points left when he steps on the road (unfortunately, OG doesn't show the exact numbers), but he nevertheless is able to perform his last diagonal step to the sand (which "normally" costs 300MP), so it seems that road tile's penalty is always considered as 75 for the purpose of the "last move".

Branikolog commented 1 year ago

@oleg-derevenetz I'm quite familiar with such "last move" logic, as it was the same in H3. I'm also not against some varied paths, that game shows depending on... moon size... :) It really does not much matter for me, if hero would appear in the target place with the same movement points left (0 in the above case) in result. The thing bothers me (speaking about the bug above) is the fact that we see two arrows heading toward each other, which is confusing and looks like a bug. I think turning this arrow (the lowest one from screenshot) for 90 or even 180 degrees counterclock-wize wouldn't look as a bug in path generation.

the consensus was that arrows are not about movement points spent by a hero, but about a tile's own penalty, i.e. the arrow length on a tile should match the tile penalty displayed by the "quick info" window on this tile. In this issue's case two steps were taken over road tiles with "native" penalty 75 (displayed by the quick info), thus we should have two short arrows.

Mmm... That's how it works! Could be... Could be... I'm afraid, my opinion is rather subjective in this question, but I've always considered each arrow size from the movement points consumption point. But not the penalty of the cell itself. Showing short arrows in such situations could confuse players, making them think, they spend less movement points. Maybe new players will not find much difference between these two approaches and would get used to it. But I personally, as an old player, find this implementation as bugged and created this thread here. :) I'd like to hear the opinion, what other people think of this issue.

oleg-derevenetz commented 1 year ago

@Branikolog

The thing bothers me (speaking about the bug above) is the fact that we see two arrows heading toward each other, which is confusing and looks like a bug

Well, that's how the corresponding arrow from the OG resources looks like for this kind of movement.

but I've always considered each arrow size from the movement points consumption point.

Even so, the OG behavior is bugged anyway, because it's the first arrow should be short in this case, and not the second one :)

I'd like to hear the opinion, what other people think of this issue.

I recommend to discuss this with @LeHerosInconnu then. Players will always be confused, whether it be the case "this arrow is too short because I spent more movement points going off road" or "this arrow is too long because quick info shows just 75 penalty for this tile".

ihhub commented 1 year ago

I am marking this issue as low priority as it is indeed not very critical at the moment.

LeHerosInconnu commented 1 year ago

Hello @Branikolog and @oleg-derevenetz,

Yes, the path displayed misleads the player, because there's that pesky rule that the 75% reduced penalty of a road is only valid if the destination square is a road, otherwise it's the penalty of the terrain below the road that's taken into account (except for the last step where the road penalty is always taken into account).

I don't really understand the point of this rule, which upsets the simple logic that the penalty of the terrain (or road) as the origin of the move is taken into account. And I'd be in favor of simply eliminating this rule, the reason for which I can't see (if anyone has any ideas, I'd love an explanation).

I'm not against the arrows on the path to represent the consumption of movement points rather than the penalty of the square where the arrow is located, it's just a convention to be aware of. It's true that the current display is confusing with the specific "road to road" rule.

Sorceress, no road on the path: (click to expand) In original game: ![Hero path length 001](https://github.com/ihhub/fheroes2/assets/43583994/bb7eddca-2701-4bd8-9e10-91602b955bf4) ![Hero path length 002](https://github.com/ihhub/fheroes2/assets/43583994/85918a6f-40db-4f27-9853-2cd5ca2cc9f9) In fheroes2: ![Hero path length 005](https://github.com/ihhub/fheroes2/assets/43583994/87060221-0778-4958-8a7f-e8e729496af3) ![Hero path length 006](https://github.com/ihhub/fheroes2/assets/43583994/267c0ac9-1fa0-4f85-9263-b6b63ee19a27)
Barbarian, with Pathfinding expert: (click to expand) In original game: ![Hero path length 003](https://github.com/ihhub/fheroes2/assets/43583994/222b2545-9257-4ac1-ae8e-476cc575d764) ![Hero path length 004](https://github.com/ihhub/fheroes2/assets/43583994/b28ce0bb-bee3-4486-bf74-233e1d7e4c29) In fheroes2: ![Hero path length 007](https://github.com/ihhub/fheroes2/assets/43583994/77e3a968-f6cf-48cd-ae87-e5fa73b92aa2) ![Hero path length 008](https://github.com/ihhub/fheroes2/assets/43583994/6daa37b1-a7ac-4ad8-9cc8-dcc5c5947c3d)
Sorceress, road on the path: (click to expand) In original game: ![Hero path length 009](https://github.com/ihhub/fheroes2/assets/43583994/2562b125-2c36-4332-bae6-58560c467f9d) ![Hero path length 010](https://github.com/ihhub/fheroes2/assets/43583994/d163d1c3-65b6-41c4-9c80-82912d5859a5) In fheroes2: ![Hero path length 011](https://github.com/ihhub/fheroes2/assets/43583994/41197b01-8f49-41b5-9228-407ea16a04d4) ![Hero path length 012](https://github.com/ihhub/fheroes2/assets/43583994/6c4f6248-18da-403b-ae5a-4ff827138f3b)
Barbarian, with Pathfinding expert, movement points consumption: (click to expand) In fheroes2: https://github.com/ihhub/fheroes2/assets/43583994/cabe10c7-1e2c-49da-ace5-72e56289db85

I haven't been able to reproduce this path.

image

Also, the bottom arrow doesn't seem to be pointing in the right direction as seen from the hero's movement. The bottom of the arrow should be straight and the arrowhead should be pointing to the left. Keep an eye on it. ;)

Also, the move that costs the hero the fewest movement points is taken into account first in the original game, whereas in fheroes2 this is not the case. This inevitably results in paths that are not always the same.

Barbarian path 01: (click to expand) In original game: ![Hero path 01 01](https://github.com/ihhub/fheroes2/assets/43583994/22618ab8-e1cf-4f92-b093-f046b2bf6e0a) In fheroes2: ![Hero path 01 03](https://github.com/ihhub/fheroes2/assets/43583994/5cdc682d-b4b0-44c9-9e7e-54e98ec3a55e)
Barbarian path 02: (click to expand) In original game: ![Hero path 01 02](https://github.com/ihhub/fheroes2/assets/43583994/85bc5012-a688-4529-afeb-6f26bbd5191f) In fheroes2: ![Hero path 01 04](https://github.com/ihhub/fheroes2/assets/43583994/b9cfe81a-0ca5-482c-9f66-0bb0829564d6)
Barbarian path 03: (click to expand) In original game: ![Hero path 01 05](https://github.com/ihhub/fheroes2/assets/43583994/910b3279-b121-4b6d-81b2-98c0779cbc9f) In fheroes2: ![Hero path 01 06](https://github.com/ihhub/fheroes2/assets/43583994/bcc0ce64-e41a-48b3-be3f-2ee120288923)

Here are the save files: Hero path length 01.zip

oleg-derevenetz commented 1 year ago

Also, the bottom arrow doesn't seem to be pointing in the right direction as seen from the hero's movement. The bottom of the arrow should be straight and the arrowhead should be pointing to the left.

In fact, in this case hero is turning back at an angle of 135 degrees (he gets to the tile at the bottom of the road by going straight down from the upper road tile, and then goes to the upper left tile diagonally). This is actually close to a U-turn, but not quite. There are not so many arrow variants for this type of movement, namely these:

017 - currently used 024 - used for a case when hero turns from the bottom left direction to the top left direction, i.e. it's indicates a less sharp (90 degree) turn.

Also, the move that costs the hero the fewest movement points is taken into account first in the original game, whereas in fheroes2 this is not the case.

BTW in this particular case it's in fact the case in fheroes2, but not in the original game :) There are two options in this case after the first step:

  1. Step to the left from the road and consume 200MP on the sand;
  2. Step to the bottom tile using the road (and consume 75MP) and then make the last step to the upper left diagonally (and consume all remaining movement points).

HOMM2 chooses the first option and fheroes2 chooses the second option, but "the move that costs the hero the fewest movement points" is the second one, and not the first one. Another proof that "steps that take the fewest amount of movement points are preferred" logic does not reflect the reality - at least, not entirely.

LeHerosInconnu commented 1 year ago

Hello @Branikolog and @oleg-derevenetz,

In this case due to the "last move" rule the hero will spend the same amount of movement points both if he goes straight and if he goes zigzag (because he performs the "last move" over the road tile with "native" penalty 75 in straight direction, and he has 125 movement points left on the second road tile), so this trajectory looks weird, but it's nonetheless legitimate:

https://github.com/ihhub/fheroes2/assets/32623900/3965648f-8cc6-4e4e-b8b7-1c34e2570836

In this case, since the number of movement points consumed is the same, why not make the hero take the shortest route visually? This would avoid having that "comic" move of the hero zig-zagging across the adventure map and seeming not to know what he wants.

Also, the bottom arrow doesn't seem to be pointing in the right direction as seen from the hero's movement. The bottom of the arrow should be straight and the arrowhead should be pointing to the left.

In fact, in this case hero is turning back at an angle of 135 degrees (he gets to the tile at the bottom of the road by going straight down from the upper road tile, and then goes to the upper left tile diagonally). This is actually close to a U-turn, but not quite. There are not so many arrow variants for this type of movement, namely these:

017 - currently used 024 - used for a case when hero turns from the bottom left direction to the top left direction, i.e. it's indicates a less sharp (90 degree) turn.

The arrow of the hero's path should indicate the direction in which the hero exits the origin square. This even if the hero performs an action to reorient himself within the origin square.

In fheroes2:

Hero path arrow coupé 001 Hero path arrow coupé 002 Hero path arrow coupé 003

Also, the move that costs the hero the fewest movement points is taken into account first in the original game, whereas in fheroes2 this is not the case.

BTW in this particular case it's in fact the case in fheroes2, but not in the original game :) There are two options in this case after the first step:

  1. Step to the left from the road and consume 200MP on the sand;
  2. Step to the bottom tile using the road (and consume 75MP) and then make the last step to the upper left diagonally (and consume all remaining movement points).

HOMM2 chooses the first option and fheroes2 chooses the second option, but "the move that costs the hero the fewest movement points" is the second one, and not the first one. Another proof that "steps that take the fewest amount of movement points are preferred" logic does not reflect the reality - at least, not entirely.

This is certainly one of the few cases where this happens (others as examples?), and in this case it results in a zig-zag path for the hero that is more reminiscent of an "anomaly" than anything else. And taking this anomaly as an example is not necessarily a good reference. :) Anyway, this was more in relation to the three examples of the Barbarian's paths from below, two of which are different from the three shown, than in relation to the hero's zig zag path reported by @Branikolog. And which sometimes reduces the hero's movement on the adventure map because of this difference:

Another example.

It's day 7. The player has the opportunity to pick up a pile of ore, which will enable him to build the Green Tower, with 4 green dragons available for recruiting the following week. An important advantage for the rest of the scenario. Will he succeed?

Let's try with Heroes 2 first:

https://github.com/ihhub/fheroes2/assets/43583994/7c303bb0-c276-48c3-b2e6-4a4eb6cb3e34

It's a success!!!

Next, let's try fheroes2:

https://github.com/ihhub/fheroes2/assets/43583994/ec141f41-d13d-4c6a-8ae5-3dfc8f18ec57

Total failure!!!

The 50 extra hero movement points spent by the diagonal movement at the start of the hero's path to attack the peasant are permanently lost for the rest of the hero's movement, and will never be recovered.

This doesn't happen in the original game, because the game first favors horizontal and vertical movements for heroes, which consume fewer movement points.

Here is the scenario test and the save files: Dragon or not Dragon 01.zip

Originally posted by @LeHerosInconnu in https://github.com/ihhub/fheroes2/discussions/6106#discussioncomment-6031390

oleg-derevenetz commented 1 year ago

In this case, since the number of movement points consumed is the same, why not make the hero take the shortest route visually?

Yes, I believe we can implement the logic "if there are multiple paths with the same cost, choose the one that takes less steps" some day.

The arrow of the hero's path should indicate the direction in which the hero exits the origin square.

There are arrow variants that also take into account the direction from which hero comes to the tile (with various bends). Maybe some of them are less "well chosen" than others.

Branikolog commented 1 year ago

HI, @LeHerosInconnu

I haven't been able to reproduce this path.

Hero should have as little movement points, as possible for this situation. Actually, this arrow issue happens due to the rule of last step being available in a case there's enough points only for straight moves.

Yes, I believe we can implement the logic "if there are multiple paths with the same cost, choose the one that takes less steps" some day.

I believe this would solve the problem with two arrows heading towards each other.

LeHerosInconnu commented 1 year ago

Hello @Branikolog,

HI, @LeHerosInconnu

I haven't been able to reproduce this path.

Hero should have as little movement points, as possible for this situation. Actually, this arrow issue happens due to the rule of last step being available in a case there's enough points only for straight moves.

Yes, I've managed to reproduce it, thank you. The hero must have 400 movement points left.

In fheroes2:

Hero path 400 move 01