Hacker News new | ask | show | jobs
by zxcvbn4038 2149 days ago
There are well known algorithms for shuffling cards, you don't need to reinvent it. Most online casinos use this:

https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle https://www.rosettacode.org/wiki/Knuth_shuffle

1 comments

Hey thanks for the article.

What I mean though is that in real life people won’t shuffle the same way as the computer does so my online playtesting might be inaccurate.

They’ll just do crap shuffling and cards will still be together in sets from the previous game - what I need is a bad / human shuffling algorithm that shuffles like lazy normal people do!

Most naive algorithms for card shuffling that you find people using that aren't Fischer-Yates or Knuth shuffle (as mentioned above) are sometimes "more lazy" than normal people and will give you worse results than the average human shuffling especially when you factor in how bad the average computer PRNG is. (Computers don't have "perfect random", so your assumption above is probably more amusing to me than you intended it to be. Even a bad/lazy human is still likely more "perfectly" random than the average computer.)

(ETA: One perfect naive algorithm example is directly in the article here: the riffle one card at a time algorithm. Select any n riffles less than the mean 236 and it is a guaranteed lazy/bad shuffle. Even selecting above the mean doesn't guarantee a perfect shuffle, again because of the properties of a computer PRNG.)