I came across a single deck online blackjack game that mentions it uses the Fisher–Yates shuffle after every round. Never heard of it before. Is it a good shuffle?
I came across a single deck online blackjack game that mentions it uses the Fisher–Yates shuffle after every round. Never heard of it before. Is it a good shuffle?
Email: [email protected]
The shuffle works like this Imagine you have a deck of 5 cards numbered 1, 2, 3, 4, 5 on a table.
Here's how you shuffle them:
- Start from the last card (#5)
- Pick any card at random from positions 1-5
- Swap it with card #5
- Move to second-to-last card (#4)
- Pick any card at random from positions 1-4
- Swap it with card #4
- Move to card #3
- Pick any card at random from positions 1-3
- Swap it with card #3
- Move to card #2
- Pick any card at random from positions 1-2
- Swap it with card #2
- Card #1 stays where it is (since there's nothing left to swap with)
The key idea is that you work backwards through the deck, and for each position, you randomly pick from all the cards that haven't been "locked in" yet.
Common mistakes that can make it less random:
1.Using a poor random number generator as Gronbog states.
2.Incorrect range calculation for the random index
3.The "naive shuffle" mistake of picking random positions in order. The problem with this approach is that it picks from ALL positions every time, instead of reducing the range of possible positions each time. This means some permutations are more likely to occur than others.
Bookmarks