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

Create a deterministic random generator #107

Closed
Dawoodoz opened this issue Dec 18, 2024 · 4 comments
Closed

Create a deterministic random generator #107

Dawoodoz opened this issue Dec 18, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@Dawoodoz
Copy link
Owner

Because random generators in C++ are defined by the compilers, compiling the same program with different C++ compilers can produce different results. Having a specified implementation of a random generator could improve that, so that it only changes if critical bugs are detected. It should have a large source of entropy and be balanced between speed and even distributions.

@Dawoodoz Dawoodoz added the enhancement New feature or request label Dec 18, 2024
@MiguelECL
Copy link

Would using a random generator engine defined in the std library with a fixed seed solve this issue?

@Dawoodoz
Copy link
Owner Author

Dawoodoz commented Jan 3, 2025

Would using a random generator engine defined in the std library with a fixed seed solve this issue?

In theory, yes. Choosing a specific algorithm that is mandated by the standard to exist would work. In practice however, not all C++ compilers will be fully compliant with the C++ standard, implementations can have different interpretations of the standard, and we don't know if those features will be deprecated for new random generators in future versions of C++. I remember how a random generator in pixel shader assembler got deprecated despite being a core functionality in GPU hardware. Just have to write the code in such a simple way that no compiler can refuse to compile it.

@MiguelECL
Copy link

Created a draft-pr concerning this issue, consisting of a C++ implementation of the xorshiftr+ PRNG. #127

@Dawoodoz
Copy link
Owner Author

Solved in #131

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

No branches or pull requests

2 participants