there is a poker-system in java, that uses Collections.shuffle()
on all available cards before the cards are dealt.
So a collection of 52 cards 2-9, J, Q, K, A in 4 types.
After that we Collections.shuffle()
.
The problem is, that it seems (until now we didn't have big statistic, it's possible that we only see a lot of statistic inferences), that the algorithm is VERY unclearly.
So, is Collections.shuffle()
okay for a poker algorithm?
Answers to comments: With "unclearly" I mean it's very very mysteriq at some time. Much User complain about "it's not the same as live / other pokerrooms". I played a much with this system and must say, I agree, I see 3 Royal Flashs in under 2000 played hands in this system and live/in other pokerrooms with over 100.000 played hands I see 2 until today.
If this is a serious poker application, where money can change hands, the short answer is NO. For something like this, you should really use a hardware source of true randomness.
The slightly longer answer is: if you can't get hardware for doing true randomness, Collections.shuffle(List, Random)
might be good enough if you supply a SecureRandom
. The tricky part with this solution is finding a good seed value.
UPDATE: Based on your clarification, I'd suggest you look into how you're seeding the PRNG (assuming you're already using a cryptographically secure implementation; if not, do that first). You should not be using a limited set of seeds. Other things to consider:
The Collection.shuffle
uses the O(n) implementation of the Fisher-Yates shuffling algorithm.
And the random indexes are chosen with the normal PRNG of Java, so it will be approximately uniform: every shuffle of the deck will be as much probable as every other one.
This is quite ok for what you want to do, but when you want real randomization you should introduce some real random factors (like System.currentTimeMillis()
used to seed the random number generator) or something more realiable like a specialized hardware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With