Shuffling a poker deck in JavaScript with window.crypto.getRandomValues

前端 未结 3 1245
死守一世寂寞
死守一世寂寞 2021-02-05 08:32

A poker deck has 52 cards and thus 52! or roughly 2^226 possible permutations.

Now I want to shuffle such a deck of cards perfectly, with truly

3条回答
  •  孤独总比滥情好
    2021-02-05 09:17

    I personally think you could move outside the box a little bit. If you're that worried about randomness, you could look into an API key from random.org ( https://api.random.org/json-rpc/1/ ) or parse it out of a link like this: https://www.random.org/integer-sets/?sets=1&num=52&min=1&max=52&seqnos=on&commas=on&order=index&format=html&rnd=new .

    Sure, your datasets could be intercepted, but if you get a few hundred thousand sets of them then shuffle those sets you would be fine.

提交回复
热议问题