Randomizer

1. Senior Member
Join Date
Dec 1969
Posts
170

## Randomizer

Hi Guys,<BR><BR>Can you confirm this code will occasionally return 3 characters of the same code?<BR><BR>(I am making a small poker machine application for learning)<BR><BR>&#060;snip&#062;<BR>Do While i &#060; "4"<BR> <BR>Randomize<BR>randomnum=Int(Rnd*6) + 1 <BR>Select Case randomnum<BR>Case 1<BR>Response.Write "10"<BR>Case 2<BR>Response.Write "J"<BR>Case 3<BR>Response.Write "Q"<BR>Case 4<BR>Response.Write "K"<BR>Case 5<BR>Response.Write "A"<BR>Case 6<BR>Response.Write "S"<BR>End Select<BR>i = i + 1<BR>Loop<BR>&#060;/snip&#062;<BR><BR>Thanks :o)<BR>Renee<BR><BR>

2. balletchick Guest

## RE: Randomizer

It is possible that you will get three repeating values, though unlikely. <BR><BR>And the (rnd * 6) should be (rnd * 5)... as it now stands it would be possible to return a random &#039 7&#039.<BR><BR>If you want to simulate poker hands though, you really need to emulate the entire 52-card deck. First, assign a value to each possible card (e.g. 1=Ace Diamonds, 2=Ace Spades, 3=Ace Hearts, 4=Ace Clubs, 5=2 Diamonds, 6=2 Spades, etc.)<BR><BR>Then, after assigning these values, put them into an array in random order (like shuffling a deck of cards!).<BR><BR>Then, pick random numbers (in this case, 3 random numbers) that are NOT the same as each other, and pull the appropriate card from the shuffled array (the deck). <BR><BR>That would give you a better approximation of the distribution of cards in the &#039real world&#039. (YES stickler-dudes... I DID say approximation, not exact) <BR><BR>:)<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•