Hacker News new | comments | show | ask | jobs | submit login

Your code

    std::random_device entropySource;
    std::mt19937 randGenerator(entropySource());
does not properly seed a mt19937. To copy a comment I made just two weeks ago (this error is a direct result of <random>'s poor design),

It is unfortunate how people keep trying to use `std::mt19937` and, unsurprisingly given how hard it is to use, how they (almost)[0] inevitably fail. Do yourself a favour and use a randomness library that doesn't hate you[1], is simple to seed correctly[2], produces decent quality randomness[3], isn't horribly bloated[4] and has more features[5] to boot. It's 2017. Let the Mersenne Twister die.

[0]: https://codereview.stackexchange.com/q/114066/40768

[1]: http://www.pcg-random.org/

[2]: http://www.pcg-random.org/posts/cpps-random_device.html

[3]: http://www.pcg-random.org/paper.html

[4]: https://cs.stackexchange.com/q/50059/16408

[5]: http://www.pcg-random.org/using-pcg-cpp.html#extra-features




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: