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

Pseudo-RNG does not seem to work #13

Open
JxD-DeciSion opened this issue Jul 20, 2023 · 0 comments
Open

Pseudo-RNG does not seem to work #13

JxD-DeciSion opened this issue Jul 20, 2023 · 0 comments

Comments

@JxD-DeciSion
Copy link

[Raylib] - [Pseudo-RNG does not seem to work]

Description
Since the .getRandomValue(min: , max:) method seems to be deprecated, I tried using Int32.random(in:)/Int.random(in:) as stated in the deprecation message. However, these methods do not seem to be affected by the .setRandomSeed() method. I even attempted to set the seed via srand() and srandom(), but this did not work either.

Steps to Reproduce

  1. Set the seed via .setRandomSeed() once (I did it in the beginning immediately after window initialization).
  2. Generate a random value using the method Int32.random(in:).
  3. Print the generated value to the console.
  4. Restart the application and repeat steps 1-3 using the exact same code/seed.

Current Behavior
The generated values are not identical, nor are their sequences anywhere near identical. When using .getRandomValue(min: , max:), everything works fine.

Relevant Screenshots/Logs
-

Environment
Operating System: Ubuntu 20.04.6 LTS
Project Version: master
Swift Version: 5.6.2
Target: x86_64-unknown-linux-gnu

Troubleshooting Steps Taken
I tried only setting the seed once at the very beginning. I used a hardcoded seed of '123'. I tried setting the seed via .setRandomSeed() as well as srand() and srandom(). For getting a pseudo-random value, I tried Int.random(in:), Int(random()), Int32.random(in:), as well as UInt32.random(in:). After getting a value from the PRNG, I restarted the application and did the exact same thing as before, expecting to get the exact same value. But the value I received was always different. I also tried replicating this in a playground environment, getting different values/sequences there as well.

Possible Solutions
Maybe the problem is with my usage, but I'm uncertain.

Additional Information
You can use .getRandomValue(min: , max:) as a workaround, regardless of its deprecation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant