# How does a Random Generator shuffle and distribute 52 cards?

Page 1 of 1

## 8 Replies - 1874 Views - Last Post: 23 June 2014 - 12:58 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=348943&amp;s=8b5555a89e27f55c03ad0f13750ad738&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 knowledge hunter

Reputation: 0
• Posts: 3
• Joined: 19-June 14

# How does a Random Generator shuffle and distribute 52 cards?

Posted 19 June 2014 - 11:24 AM

helllloooooooooo all! I am not a programmer or anyone who develops, designs or puts the final touches on a games or any other avenue that coding creates. I am very curious how a Random Number Generator (RNG) in the Game King video poker game Jacks or Better (JOB) works. I think that IGS is the software provider and owns Game King. I am hoping that I am at "THE SITE" that can explain in detail the answers to my questions that i have listed below or any other information that would help me to understand, what i am confused about the RNG.

I have read that the game JOB 9/6 is the simplest of the video poker games. I read that there is one RNG chip that shuffles 52 -5 cards which = 47 cards constantly until you press the hold button for the cards that you want to hold. Then once you press the deal button the RNG releases the number of cards to match the number of cards given up. I read that there are 2,598,960 combinations of hands that can be dealt for the JOB 9/6 game. I read that the RNG shuffles 24/7 even if no-one is playing.

1. What is true or false in the paragraph above?

2. How does the person playing receive the winning combinations such as the Royal Flush, the Straight Flush, the 4 of a kind, the Full House, the Flushes (royal or not) etc., if all the cards keep being mixed up constantly?

3. You can bet one denomination to 5 denominations per hand( 1 quarter to 5 quarters, 50 cents to \$2.50, \$1-\$5, \$2-\$10, \$5-\$25) etc.. You receive the most credits for a win by selecting the fifth choice of each denomination set. You can, in any of the sets change from 1 to 5 using the increase bet button or hit the max button after the UN-held cards have been replaced. You do not always have to just use the deal button. Some people always use the increase bet button or the max button after a hand is completed. They believe that they will receive a different set of cards (hoping it is a winning set) than they would have by just always using the re-deal button. I have witnessed many people win the big winners, by not playing strategically what cards they see, but by first hitting the deal button to see what comes up , then deciding to hold or not hold any cards, complete that particular hand by hitting the deal button and then hitting the increase to 5 or the max button each time after that to receive the next set of 5 cards, instead of using the deal button. MY question for this paragraph is ...What is the difference in what cards come up between re-dealing, using the increase button or using the max button? Is it going to deal differently because each selection I mentioned is at a different location of the cards being shuffled? I did notice that if only non winning combinations are showing up, and you do use the increase or max button after a completion, it seems like you begin receiving different sets of cards. Which if they are not the winning sets,you keep using the increase or max button after each completion to move to another new set, until the the cards that you are looking for start to show up. What is really happening with the cards?

4. In the Game King machine, there are choices of playing areas. Poker, Keno and Black jack. Under Poker there are 6 different video poker games to choose from. JOB, Double Bonus Poker, Double Double Bonus Poker, Joker's Wild, Deuces Wild and White Hot Aces. They all have different winning combinations from each other, but are they all using just 1 RNG chip with different programming for each game or does each game have its own RNG chip?

I think my next move should be to see if anyone will answer the above questions, or if someone can explain in simple details what a RNG can or cannot do in JOB video poker. I thank dreamincode for letting me ask these questions, and I pre-thank anyone who reviews this post for their time and their response if any.

playfully overwhelmed,
knowledge hunter

Is This A Good Question/Topic? 0

## Replies To: How does a Random Generator shuffle and distribute 52 cards?

### #2 modi123_1

• Suitor #2

Reputation: 11495
• Posts: 45,375
• Joined: 12-June 08

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 19 June 2014 - 11:32 AM

Before this gets too far - what's up? Are you trying to beat the random number algorithm?

### #3 knowledge hunter

Reputation: 0
• Posts: 3
• Joined: 19-June 14

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 20 June 2014 - 02:12 PM

I like to play video poker. If i were a live table poker player, I would know how many decks there were and how many cards of each suit there were. If i was a card counter(which i am not) one could have an advantage i would think. so I would like to know what i am playing against and be able to use it to be very good at the game.If someone plays chess, they read all they can to be the best. I cannot find anyone who can thoroughly describe how a RNG works for 52 cards.How winning combinations can come up if the deck is being shuffled constantly. And i would like answers to all of the other questions and situations that i wrote in my first post. i have no clue if i could beat the RN Algorithm, and I do not know much about algorithms, but I cannot attempt to beat it , if i cannot understand it!

I have a book by Robert J. Kriegel and Louis Patler named " if it ain't broke ... BREAK IT! Well i cannot improve the game or my playing it, if I am confused about it. And i think it was Thomas Edison that said "There is a better way! FIND IT!" .... Well i am investigating as much as i can about the RNG being used in JOB in the Game King video poker machines. Please help me if you will............ Thanks again for you interest ..... sportingly, knowledge hunter

### #4 jon.kiparsky

• Pancakes!

Reputation: 9443
• Posts: 16,366
• Joined: 19-March 11

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 20 June 2014 - 02:50 PM

I don't know implementation details for any video poker machines, but the correct way to shuffle cards, if you want to get actual randomness, is to use the Fisher-Yates shuffle. In this method, you have an array of cards which we'll call the source and an empty array which we'll call the destination. You perform the shuffle by simply selecting a random card in the source deck and placing it next in the destination deck. This is a linear-time algorithm which produces a random ordering, to the limits of your random-number generator.

Now, the video poker machine is interested in randomness, because it's possible to beat a pattern. By sitting down at the machine, you're accepting idiot's odds to begin with, so they don't need to cheat. Random, then, is very good for them. So it's reasonable to suppose that they're using a Fisher-Yates shuffle. On the other hand, there are other reasonable ways to suppose about this, so that's not very convincing.

In the long run, I think it doesn't matter much. Anyone who is sufficiently ignorant about math that they'll play video poker is not going to beat that machine. Just sit back and enjoy losing your money and don't worry your pretty little head about it.

### #5 jon.kiparsky

• Pancakes!

Reputation: 9443
• Posts: 16,366
• Joined: 19-March 11

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 20 June 2014 - 03:06 PM

Quote

They believe that they will receive a different set of cards (hoping it is a winning set) than they would have by just always using the re-deal button.

Why would a different set of cards be any better than the first ones? Assume that the deal is random both times - in that case you're just as likely to trade down as to trade up. This is idiotic.

Quote

What is the difference in what cards come up between re-dealing, using the increase button or using the max button? Is it going to deal differently because each selection I mentioned is at a different location of the cards being shuffled?

All of the possibilities that you mention would have to be programmed into the machine. Someone would have to decide to make it work that way. Why would they go to any extra effort to put in ways for you to win extra?
Of course, it's possible that there's a bug somewhere in the program: that there's a way to win above the expected rate of payout, which is unintentional. Let's suppose that such a thing exists, and furthermore that I know about it. And let's suppose that this brings the expected rate of payout into positive territory for me - that is, that it is such a bad error on their part that it makes it worth my while to play the game, since I'd win more than I'd lose. If that were the case, why in the world would I tell anyone about it? That would only guarantee that the bug would be fixed and my improved odds would go away.

If any of this were not true, then these machines would do the wrong trick: they would lose money. And the company that installed them and operated them would go bankrupt, and these machines would disappear. So you can assume that the fact that a given video poker machine exists means that it's doing what it's meant to do: it's transferring money from the pockets of the stupid to the pockets of people who are both smart enough and immoral enough to take advantage of the stupid. Being on either side of that game, in my book, makes you a profound loser.

### #6 knowledge hunter

Reputation: 0
• Posts: 3
• Joined: 19-June 14

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 23 June 2014 - 12:40 PM

Jon K ...... I was not asking for your opinion on playing the game, just information on how it works. The Google security engineer Tavis Ormandy reveals bugs in Microsoft and other companies operating systems and software. How he reveals it is subject to controversy, but the fact remains that he is and has exposed "bugs" and by doing so, has made others repair the error for the better. This forum is available to many to get and offer help to each other in a precise endorsing manner . I hope that in the future your post responses leave out your biased opinions and you begin to offer valuable positive guidance. You will gain more respect by encouraging people than by belittling them.

Will someone tell me what code is used to program a RNG card video game? Or can you let me know what book(s) i can seek to possibly find the answers to my questions by myself?

"The ultimate measure of a man is not where he stands in moments of comfort and convenience, but where he stands at times of challenge and controversy" - Martin Luther King

"When you feel yourself preparing to lock horns with someone, remember that it will be more profitable if you lock hands instead. A handshake leaves no bones bleaching in the sun." - Napoleon Hill

Praise and Thanks to you all,

knowledge hunter

### #7 modi123_1

• Suitor #2

Reputation: 11495
• Posts: 45,375
• Joined: 12-June 08

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 23 June 2014 - 12:45 PM

Quote

Will someone tell me what code is used to program a RNG card video game

I would imagine it is proprietary. If someone had the algo cracked on how random numbers are generated then the game becomes deterministic and the company/casino begins to lose money.

### #8 jon.kiparsky

• Pancakes!

Reputation: 9443
• Posts: 16,366
• Joined: 19-March 11

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 23 June 2014 - 12:49 PM

Volume 2 of The Art of Computer Programming covers random number generation. Also, chapter 5 of Menezes et al's Handbook of Applied Cryptography goes into some detail on pseudorandom number generators. Those are two good starting points, but of course there will be others.

modi123_1, on 23 June 2014 - 02:45 PM, said:

Quote

Will someone tell me what code is used to program a RNG card video game

I would imagine it is proprietary. If someone had the algo cracked on how random numbers are generated then the game becomes deterministic and the company/casino begins to lose money.

This is only true for very bad PRNGs. For the same reasons that you'd never trust a proprietary crypto algorithm, you should never trust a proprietary PRNG in situations where it matters - especially if it's an algorithm you came up with yourself. (See DEK's discussion of his early random generation algorithm in TAOCP2)

### #9 modi123_1

• Suitor #2

Reputation: 11495
• Posts: 45,375
• Joined: 12-June 08

## Re: How does a Random Generator shuffle and distribute 52 cards?

Posted 23 June 2014 - 12:58 PM

Yeah, but if I had a chip from slotmachine maker X and the seed.. well... it would give me a leg up. (Which is what I think this cat is going on about.. some sort of advantage/intel on slot machines, their chips, and programming to facilitate larger winnings).

Typically the chips are generating combinations until some user interacts, grabs a few of the next numbers, crams those into what ever winning combo formula to validate, and pays accordingly.