#1
|
|||
|
|||
Shuffle Algorithm
I guess this question is more for Sklansky or Malmuth but here it is. What is the best way to create an unbiased shuffle in software. I know of some ways that would work but I was curious as to what you guys used and how accurrate it actually is. I am working on some software for learning different gambling games. Just curious.
Jack |
#2
|
|||
|
|||
Re: Shuffle Algorithm
All you need is to select a uniform random number between 1 and 52! ~ 8.07x10^67 ~ 2^226. The result as as good as your random number generator is.
There are various sources for real random numbers such as HotBits or you can use the pseudo-RNG algorithm and very-large-integer package of your choice. Mersenne Twister seems to be the algorithm of choice these days. If you don't require cryptographically strong randomness, e.g. for quick and dirty simulation code, it will probably make very little difference what you use. I freely admit that in my own programs, I use the good old-fashioned FOR A = 1 TO 51 B = INT(RND*(53-A))+A SWAP CARD(A),CARD(B) NEXT method with the system's built-in RNG. Nothing too bad happens. [img]/images/graemlins/crazy.gif[/img] |
#3
|
|||
|
|||
Re: Shuffle Algorithm
The "swap card" method is the method I've used in some software I created where I wanted to just test the odds of getting certain hands. More of a hobby project than anything. Do you find that you can predict the order of the cards somehow, if this method is used? Say you were to swap 100k times.
|
|
|