You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A game that uses various forms of randomness for terrain generation and placing and naming cities and objects (randi, randf, randfn, OpenSimplexNoise, Array.shuffle(), etc).
Describe the problem or limitation you are having in your project
When bug testing, I want the ability to recreate the exact scenario that caused a particular issue. This means being able to initialise the random number generator (RNG) with the same starting conditions. I can set up my own object (RandomNumberGenerator.new()) and use that for most things, but the internal RNG is still used for things like Array.shuffle().
It is possible to do randomize() then set a variable using randi() then use seed(variable) to get a non-deterministic but known seed, however it's not a straightforward nor clean way of doing it.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Simply have something that exposes the current internal RNG's seed. e.g. the same as rng_variable.get_seed() for an RNG created using rng_variable = RandomNumberGenerator.new()
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
As above: simply a command that returns the current internal RNG's seed. e.g. get_seed() as a standalone command, instead of rng_variable.get_seed()
If this enhancement will not be used often, can it be worked around with a few lines of script?
randomize()
var new_seed = randi()
seed(new_seed)
print(new_seed)
Is there a reason why this should be core and not an add-on in the asset library?
Having looked at questions on the 'net, I am not the first to ask how to do this. It should be a really simple change to make this available, and the workaround is not intuitive and was quite hard to find. The documentation for RandomNumberGenerator suggests that we should be able to use get_seed() on any instance of the RNG, but we cannot use that on the internal one. This would make the internal RNG more consistent with the documented features of RNGs in general.
The text was updated successfully, but these errors were encountered:
but the internal RNG is still used for things like Array.shuffle().
This is a good point, at least we can clarify the documentation of this method. But I'm still not sure about the need to control the global RNG seed/state (randomize, seed, and potential method for getting/changing state). The global RNG is poorly controlled (as it can be changed from anywhere) and in my opinion should not be used for reproducible sequences.
Perhaps we should fix a few problematic methods: Array.shuffle(rng: RandomNumberGenerator = null) or Array.shuffle_rng(rng: RandomNumberGenerator).
Another syntax alternative: rng.shuffle(array). RandomNumberGenerator already has methods for generating numbers, so I believe that's where the shuffle method belongs (not on an array).
Describe the project you are working on
A game that uses various forms of randomness for terrain generation and placing and naming cities and objects (
randi
,randf
,randfn
,OpenSimplexNoise
,Array.shuffle()
, etc).Describe the problem or limitation you are having in your project
When bug testing, I want the ability to recreate the exact scenario that caused a particular issue. This means being able to initialise the random number generator (RNG) with the same starting conditions. I can set up my own object (
RandomNumberGenerator.new()
) and use that for most things, but the internal RNG is still used for things likeArray.shuffle()
.It is possible to do
randomize()
then set a variable usingrandi()
then useseed(variable)
to get a non-deterministic but known seed, however it's not a straightforward nor clean way of doing it.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Simply have something that exposes the current internal RNG's seed. e.g. the same as
rng_variable.get_seed()
for an RNG created usingrng_variable = RandomNumberGenerator.new()
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
As above: simply a command that returns the current internal RNG's seed. e.g.
get_seed()
as a standalone command, instead ofrng_variable.get_seed()
If this enhancement will not be used often, can it be worked around with a few lines of script?
Is there a reason why this should be core and not an add-on in the asset library?
Having looked at questions on the 'net, I am not the first to ask how to do this. It should be a really simple change to make this available, and the workaround is not intuitive and was quite hard to find. The documentation for RandomNumberGenerator suggests that we should be able to use
get_seed()
on any instance of the RNG, but we cannot use that on the internal one. This would make the internal RNG more consistent with the documented features of RNGs in general.The text was updated successfully, but these errors were encountered: