8000 Combat screen, obstacles and their position on the battlefield should be recorded in the scenario save files · Issue #7146 · ihhub/fheroes2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Combat screen, obstacles and their position on the battlefield should be recorded in the scenario save files #7146

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

Open
2 tasks done
LeHerosInconnu opened this issue May 8, 2023 · 8 comments
Labels
bug Something doesn't work logic Things related to game logic
Milestone

Comments

@LeHerosInconnu
Copy link

Preliminary checks

Platform

Windows

Describe the bug

At the start of the scenario, all obstacles and their position on the battlefield should be determined for all squares where a fight can take place.
This should also be recorded in the scenario save files.

Here a screenshot from a saved scenario where the configuration of the obstacles is different.
Note: This scenario comes from another player on a different configuration than the one on which it was loaded.

In fheroes2:
Screenshot from the scenario video:

Obstacle type position 002

Screenshot from the saved scenario:

Obstacle type position 001

Save file

Related issue (with save file Scared Golems.zip): #7141.

Additional info

Scénario loaded in version 1.0.3 7084.

@oleg-derevenetz
Copy link
Collaborator
oleg-derevenetz commented May 8, 2023

At the start of the scenario, all obstacles and their position on the battlefield should be determined for all squares where a fight can take place.

How is this a bug? Currently it works this way: there is a random seed saved in the save file, and obstacle generation is based on this seed. But the implementation of random generator may be different depending on OS/compiler/etc, so there is a guarantee that you will get the same results (same obstacles on the battlefield in this case) on the same machine, but there is no guarantee that you'll get the same results on the different machine (although on another machine you will also get the same results on the same tile, but not necessarily the same as on the first machine). Why do you expect the same results in the first place? No one promises that.

@Branikolog
Copy link
Collaborator

Hi, @oleg-derevenetz
@LeHerosInconnu mentioned this, because it's the original behaviour, where all battlefields are the same no matter when you've started new walkthrough. (I'm not sure, it is not different on other machines though.)
I'm not against both behaviours, but testing save files from other people could be problematic. :)

@oleg-derevenetz
Copy link
Collaborator
oleg-derevenetz commented May 8, 2023

where all battlefields are the same no matter when you've started new walkthrough

Yes, in OG you'll get the same obstacles on the same tile in different playthroughs. But is that a good thing? Currently you'll get the same obstacles on the same tile during the same playthrough (on the same machine), but during the next playthrough it would be different. I believe it's good and not bad at all, because it adds variety to the game.

@Branikolog
Copy link
Collaborator

@oleg-derevenetz

where all battlefields are the same no matter when you've started new walkthrough

Yes, in OG you'll get the same obstacles on the same tile in different playthroughs. But is that a good thing? Currently you'll get the same obstacles on the same tile during the same playthrough (on the same machine), but during the next playthrough it would be different. I believe it's good and not bad at all, because it adds variety to the game.

Sure! That's great to replay the map with a completely different battlefields.
I personally have noticed several days ago the same thing myself: a file which I copied from my other machine had different obstacles. Cannot say it's bad... It's unusal. The only disadvantages I see here, is for testing purposes and in some rare cases, when two players compete replaying the same battle (using the same save file obviously) in the same conditions.

@oleg-derevenetz
Copy link
Collaborator

a file which I copied from my other machine had different obstacles

That's because random distributions (such as std::uniform_int_distribution from C++ standard library) may differ depending on OS or C++ compiler flavor/version. To get the same results on different machines, we should implement our own home-grown random generator, which will give the same results regardless of all these things, which is currently absolutely not a priority.

< 8000 /td>

@ihhub ihhub added the logic Things related to game logic label May 9, 2023
@ihhub ihhub added this to the 1.0.5 milestone May 9, 2023
@LeHerosInconnu
Copy link
Author

Hello @oleg-derevenetz and @Branikolog,

At the start of the scenario, all obstacles and their position on the battlefield should be determined for all squares where a fight can take place.

How is this a bug? Currently it works this way: there is a random seed saved in the save file, and obstacle generation is based on this seed. But the implementation of random generator may be different depending on OS/compiler/etc, so there is a guarantee that you will get the same results (same obstacles on the battlefield in this case) on the same machine, but there is no guarantee that you'll get the same results on the different machine (although on another machine you will also get the same results on the same tile, but not necessarily the same as on the first machine). Why do you expect the same results in the first place? No one promises that.

Is this type of functioning used elsewhere in fheroes2?

For example, for the progression of the primary and secondary skills of the hero, for the spells of the mage guilds and shrines, for the number of creatures of the wandering creatures, etc., etc., etc.?

In the original game, everything that has to be done randomly is done at the beginning of the scenario, then everything is fixed, randomness doesn't come into play anymore.

With Heroes 2, tournaments were organized with a save file from the beginning of the game as a starting point, so that all the participants had exactly and strictly the same game conditions.

So currently, if I understand correctly, the player can start a scenario on a desktop PC, make a save, load that save on his portable PC and have something different than if he had played the scenario only on his desktop PC.

So extrapolating, he wins on his desktop PC and he loses on his portable PC because he got different conditions from the same save file.

Taking another example, we can say that depending on whether we load the same file to generate the employees' pay on different computers, the salaries will not be the same.
Some employees will find this amusing, others will not really appreciate it.

Fheroes2 being a remake of Heroes 2, it is important that everything that is random is determined at the beginning of the scenario and is not subject to change afterwards.
The effects of loading the same savegame in fheroes2 must be strictly identical in the continuity of the game whatever the hardware and the software used to run the program.
Why should it be any different?

@oleg-derevenetz
Copy link
Collaborator
oleg-derevenetz commented May 9, 2023

In the original game, everything that has to be done randomly is done at the beginning of the scenario, then everything is fixed, randomness doesn't come into play anymore.

No, that's not how it works in the original game. Original game is using seeds as well, but they just use some "home-grown" pseudo-random generator implementation that generates the same sequence of pseudo-random numbers from the same initial seed everywhere, regardless of the specific OS, machine, etc. fheroes2 uses pseudo-random generator from C++ standard library, which may produce different sequences on different machines, because its implementation (or rather, the random distributions used by it) is not required to be platform-agnostic by any of existing C++ standards.

Is this type of functioning used elsewhere in fheroes2?

For example, for the progression of the primary and secondary skills of the hero, for the spells of the mage guilds and shrines, for the number of creatures of the wandering creatures, etc., etc., etc.?

Yes, that pseudo-random generator from std is used everywhere. It generates the same sequence of pseudo-random numbers from the same seed on the same machine, but there is absolutely no guarantee that it will generate the same sequence on a different machine (or, say, code generated by different compilers will produce the same sequence even on the same machine).

Taking another example, we can say that depending on whether we load the same file to generate the employees' pay on different computers, the salaries will not be the same.
Some employees will find this amusing, others will not really appreciate it.

These employees should not use the random generator then :)

@LeHerosInconnu
Copy link
Author

Hello @oleg-derevenetz,

In the original game, everything that has to be done randomly is done at the beginning of the scenario, then everything is fixed, randomness doesn't come into play anymore.

No, that's not how it works in the original game. Original game is using seeds as well, but they just use some "home-grown" pseudo-random generator implementation that generates the same sequence of pseudo-random numbers from the same initial seed everywhere, regardless of the specific OS, machine, etc. fheroes2 uses pseudo-random generator from C++ standard library, which may produce different sequences on different machines, because its implementation (or rather, the random distributions used by it) is not required to be platform-agnostic by any of existing C++ standards.

...that generates the same sequence of pseudo-random numbers from the same initial seed everywhere...

That was my point.
Once generated, the numbers can always be generated in the same way, so it is no longer about randomness from that moment on as the numbers become reproducible.

Is this type of functioning used elsewhere in fheroes2?
For example, for the progression of the primary and secondary skills of the hero, for the spells of the mage guilds and shrines, for the number of creatures of the wandering creatures, etc., etc., etc.?

Yes, that pseudo-random generator from std is used everywhere. It generates the same sequence of pseudo-random numbers from the same seed on the same machine, but there is absolutely no guarantee that it will generate the same sequence on a different machine (or, say, code generated by different compilers will produce the same sequence even on the same machine).

Oops...

Taking another example, we can say that depending on whether we load the same file to generate the employees' pay on different computers, the salaries will not be the same.
Some employees will find this amusing, others will not really appreciate it.

These employees should not use the random generator then :)

This was to emphasize the fact that the user expects the same result from the same save file no matter where it is used.
I hope no one uses randomness to calculate salaries. :)

@ihhub ihhub modified the milestones: 1.0.5, 1.0.6 Jun 14, 2023
@ihhub ihhub modified the milestones: 1.0.6, 1.0.7 Jul 15, 2023
@ihhub ihhub modified the milestones: 1.0.7, 1.0.8 Aug 14, 2023
@ihhub ihhub modified the milestones: 1.0.8, 1.0.9 Sep 11, 2023
@ihhub ihhub modified the milestones: 1.0.9, 1.1.0 Oct 11, 2023
@ihhub ihhub modified the milestones: 1.1.0, 1.1.1 May 22, 2024
@ihhub ihhub modified the milestones: 1.1.1, 1.1.2 Jul 13, 2024
@ihhub ihhub modified the milestones: 1.1.2, 1.1.3 Sep 15, 2024
@ihhub ihhub removed this from the 1.1.3 milestone Oct 23, 2024
@ihhub ihhub added this to the 1.1.4 milestone Oct 23, 2024
@ihhub ihhub modified the milestones: 1.1.4, 1.1.5 Nov 27, 2024
@ihhub ihhub modified the milestones: 1.1.5, 1.1.6 Dec 30, 2024
@ihhub ihhub modified the milestones: 1.1.6, 1.1.7 Feb 16, 2025
@ihhub ihhub modified the milestones: 1.1.7, 1.1.8 Mar 23, 2025
@ihhub ihhub modified the milestones: 1.1.8, 1.1.9 May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't work logic Things related to game logic
Projects
None yet
Development

No branches or pull requests

4 participants
0