# How is shuffling of cards done in online rummy game?

Any card player knows the term card shuffling and has used it many times without really thinking about it too much. So, what exactly is this term and how is it done online? Are there many methods of shuffling?

What is Shuffling?

With 52 cards in a deck, shuffling is done to introduce chance into any card game, including rummy. Shuffling randomizes the order of cards and ensures that chance is introduced into card games like rummy. Shuffling is done first after which the deck is cut to ensure that the outcome is not manipulated to favor one party over another.

Online card games use algorithms to shuffle cards.  A special program called the Random Number Generator, previously used to power slot machines, has been adapted to shuffle cards. Players participating in online card games wouldn’t know the difference.

Random Number Generation and how it works

Computers generate two types of random numbers

– Truly random numbers are hard to predict and implementation by specific OS is different.

– Pseudo random numbers: As the name suggests, numbers generated by this method are not truly random and are done by using a mathematical formula or table. The results are random in a statistical manner. The behavior is predictable, and the next number could be predicted after a period of observation. Because of the above, PRNG is seldom used.

While it may seem easy to write an algorithm to shuffle cards, it is not very easy. The most used algorithm to shuffle cards is Fisher-Yates. Basically, the algorithm works by putting all elements in a bucket. Once a number is picked, it will randomly pick the next one and carry on till there are none.  It works in an unbiased manner to produce multiple permutations and everyone is a likely outcome. There are several ways to shuffle a deck and the best way to randomize it requires only 7 shuffles.

There are several reasons that the Fisher-Yates method is the best.

1.It is totally unbiased.

2.It uses a constant (0) or 1 space, because the swaps performed in the palace.

3.It uses linear (o)N time, because it shuffles every item in the set once.

Keep in mind that shuffling is harder than it looks. There are several algorithms in use for shuffling and many are inefficient. They also don’t work properly unless more than 2 decks of cards are used, and shuffling is done many times. Random Number Generation is very complicated, and several programs are still being developed to make randomization truly random.

Shuffling algorithms used by gaming websites may vary and at some point, patterns will repeat themselves. This is very evident when one deck of cards is in use by players. This is one aspect which is being addressed by app development companies and better results can be expected in the future.