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

Provide the global random seed to NewGRFs #5487

Closed
DorpsGek opened this issue Feb 25, 2013 · 12 comments
Closed

Provide the global random seed to NewGRFs #5487

DorpsGek opened this issue Feb 25, 2013 · 12 comments
Labels
component: NewGRF This issue is related to NewGRFs flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

Eddi opened the ticket and wrote:

This patch introduces NewGRF global var 26, offering the world generation seed to NewGRFs, to potentially randomize parameters of the NewGRF.

What remains to be checked is that the value _settings_game.game_creation.generation_seed is already initialized during GRF activation and will not be changed afterwards.

Attachments

Reported version: Version?
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5487
@DorpsGek
Copy link
Member Author

frosch wrote:

I guess in theory this would belong to Action D Patch Vars.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12048

@DorpsGek
Copy link
Member Author

Eddi wrote:

judging from the comment:
* Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'.

i assume they use the same code.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12052

@DorpsGek
Copy link
Member Author

Eddi wrote:

I have an update here, that also adds a variable 27 which has different random bits for each GRF. in theory (tm) this should provide the same random bits on reload and on reapply GRFs, unless you change the number or order of GRFs.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12053

@DorpsGek
Copy link
Member Author

frosch wrote:

I think you should better store those in the save instead of making them depend on the GRF loading order. That should be more fail-safe wrt. changes to the way base graphics work or similar.

Also, what is then intention of this feature wrt. scenarios? Shall they have the same value everytime, or shall it be rerandomised on scenario start like vehicle reliabilities?

My earlier comment refers to using GetPatchVariable() instead of GetGlobalVariable(). The former is more suitable for stuff which does not change during a game.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12054

@DorpsGek
Copy link
Member Author

Eddi wrote:

this attempt features a completely different method, instead of providing variables, the action 14 is amended with a "random" type, where the parameter will be filled with random bits. needs additional magic to make sure the chosen random value is within the given limits of the parameter.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12057

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 3, 2013

Eddi wrote:

improved version now with support for min/max ranges

next task would be some test grfs for functionality tests. and when does/should rerandomisation happen? (upon starting the grf scan, upon adding the grf to the list, upon scenario/savegame creation?)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12074

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 3, 2013

frosch wrote:

I guess it should no rerandomise when starting a prepared scenario.

So I guess randomisation should happen when adding a GRF to a game, that is when starting a game, or when adding in mid-game. Though I am not sure how the editing of GRFs in-game compares to adding GRFS when starting a new game.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12075

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 4, 2013

frosch wrote:

How should the NewGRF parameter GUI handle this? Hide parameter completely?


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12490

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 4, 2013

Eddi wrote:

Yes, doesn't make a lot of sense to display it, i think.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment12492

@DorpsGek
Copy link
Member Author

Eddi wrote:

the currently best idea to handle randomization is to have the generator for the parameter values be initialized iwth (map_seed XOR grfid). this means there is no correlation between random bits for different NewGRFs, but the same NewGRF will retain values even when reordering NewGRFs or updating versions.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5487#comment13481

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) component: NewGRF This issue is related to NewGRFs enhancement labels Apr 7, 2018
@andythenorth
Copy link
Contributor

andythenorth commented Apr 12, 2018

andythenorth: Eddi|zuHause had a patch for this #5487
[8:53pm] andythenorth: still want it open?
[8:54pm] andythenorth: can it be a PR?
[8:54pm] Eddi|zuHause: i can't comment on how finished that was
[8:55pm] Eddi|zuHause: the comments sound like there were a bunch of open philosophy questions
[8:55pm] TrueBrain: I guess andythenorth is asking: do you want to make a PR out of it and see it through, or shall we close it?
[8:55pm] andythenorth: what TrueBrain said
[8:55pm] andythenorth: PR, or move on
[8:55pm] andythenorth: all of us
[8:56pm] Eddi|zuHause: i'd have to dig a little deeper to decide that

@andythenorth
Copy link
Contributor

Re-open if you think it's still valid ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: NewGRF This issue is related to NewGRFs flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

2 participants