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

rollRange under certain circumstances very likely to return the same result #750

Open
felher opened this issue Jul 13, 2024 · 0 comments
Open

Comments

@felher
Copy link

felher commented Jul 13, 2024

The default java.util.Random handles calls to nextInt(x) where x is a power of two specially.

In Indigo, this leads to the fact that when you do dice.rollRange(1, 4) at the start of every FrameTick, you are overwhelmingly likely to get the same number as before.

Possible workaround: call rollRange(1, 4) (or with any other number) and discard the first return value. Successive calls seem to yield more random values.

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