4 ms·
> if you use a 32-bit random number generator, you only reach about 4 x 10^9 of the 8 x 10^67 different ways I suggest you reread your linked article. The fau
by jxy 5y ago
> if you use a 32-bit random number generator, you only reach about 4 x 10^9 of the 8 x 10^67 different ways
I suggest you reread your linked article. The fault is in using a 32-bit SEED.
Random shuffling algorithms are trivial and well known [0]. It really doesn't need some click-bait blog posts.
[0] https://en.wikipedia.org/wiki/Fisher–Yates_shuffle https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
- codeulike 5y agoWell they're not well known to me. But yes I can see in the FAQ https://playingcards.io/docs/faq https://playingcards.io/docs/faq that this site uses Fisher-Yates.
- TheMiddleMan 5y agoYes, you got it, Fischer-Yates shuffle via lodash. Here's their implementation: https://github.com/lodash/lodash/blob/master/shuffle.js https://github.com/lodash/lodash/blob/master/shuffle.js
- codeulike 5y agoTrying to work out how many bits the seed has, but it depends on the browsers implementation of Math.random() - in theory could be anything but apparently its usually Xorshift128+, which as far as I can tell has a 128 bit seed. So all good? Although I'm not sure where the 128 bits for the seed come from. https://hackernoon.com/how-does-javascripts-math-random-generate-random-numbers-ef0de6a20131 https://hackernoon.com/how-does-javascripts-math-random-gene...