Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > General Gambling > Probability
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2005, 12:39 AM
Japster Japster is offline
Junior Member
 
Join Date: May 2005
Posts: 1
Default 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
Reply With Quote
  #2  
Old 05-02-2005, 02:36 AM
Siegmund Siegmund is offline
Senior Member
 
Join Date: Feb 2005
Posts: 415
Default 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]
Reply With Quote
  #3  
Old 05-02-2005, 01:11 PM
LetYouDown LetYouDown is offline
Senior Member
 
Join Date: Mar 2005
Location: Sharing a smoke w/negativity
Posts: 524
Default 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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.