Is Collections.shuffle suitable for the poker algorithm?

java has a poker system that uses Collections.shuffle() for all available cards before the cards are dealt.

So, a collection of 52 cards 2-9, J, Q, K, A in 4 types.

After that we are Collections.shuffle() .

The problem is that it seems (so far we have not had a lot of statistics, it is possible that we only see a lot of statistical conclusions) that the algorithm is VERY unclear.

So is Collections.shuffle() suitable for the poker algorithm?


Responses to comments: From “unclear” I mean this is a very very mysterious moment at some time. Many users complain that "it's not the same as live / other poker rooms." I played a lot with this system and I must say, I agree, I see that 3 Royal Flashs under the age of 2000 played in this system and played in other poker rooms with more than 100,000 hands played. I see 2 until today.

+4
source share
7 answers

If this is a serious poker application where money can change hands, the short answer will be NO. For something like this, you really need to use a hardware source of true randomness.

The answer is somewhat longer: if you cannot get the hardware to perform true randomness, Collections.shuffle(List, Random) can be good enough if you put a SecureRandom . The hard part of this decision is finding a good seed value.

UPDATE. Based on your explanation, I would advise you to learn how you sow PRNG (if you are already using a cryptographically secure implementation, and if not, do it first). You should not use a limited set of seeds. Other things to consider:

  • you should create a single PRNG instance for each game.
  • you only need to shuffle the deck between your hands; from your question, it’s not 100% clear that you also don’t shuffle the deck between the flop, turn, river, etc.
+9
source

Collection.shuffle uses the O (n) implementation of the Fisher-Yates shuffle algorithm.

And random indexes are selected with normal Java PRNG, so it will be about the same: each shuffling of the deck will be as likely as any other.

This is quite normal for what you want to do, but when you need real randomization, you need to introduce some real random factors (for example, System.currentTimeMillis() used to seed the random number generator) or something more realistic, like a specialized one equipment.

+6
source

Well, I generally hate people saying this to me, but yes and no. This is about as good as pickrandomcardbetween (1, 52) and using the rand () function when it comes to randomness.

No part is that for everything that deals with random or random values, you need the proper equipment, a regular computer cannot even remotely generate a truly random result of any kind.

Edit: If your pokersystem is for fun games, this is one thing, but when the money is involved, people will hang you up to create random results this way.

+4
source

I suggest reading this article:

How we learned to cheat online poker

The authors examined one software package and found several flaws. One serious problem was the seed. If you start with a 32-bit semester (and do not generate a new independent seed during shuffling), you can only generate 2 ^ 32 different random sequences. There are 2 ^ 226 possible shuffles of a deck of 52 cards, which means that only a small fraction of the possible deck orders will be produced.

The player knows 5 card positions (7 in Omaha) on the flop. If the player knows the shuffle algorithm, he can guess which seeds of the candidate were based on the cards that he sees. This gives him a great advantage in determining the probabilities of having hidden cards.

+4
source

If this is serious money-driven poker software, then the answer is no. (For this you will need some source of true randomness.) However, for simple circumstances, this is about as good a solution as any other algorithm.

If you need more information about the shuffle algorithm itself, see Java Collections.shuffle does what? .

+2
source

The problem is that the numbers generated by random are statistically random. This means that the shuffle does not behave like a deck of cards, because it is more random than the shuffle of real life. To have something more realistic, you need to simulate how you shuffle cards in real life, for example, how many times you cut and so on. I saw a site with a chart comparing the results of real cubes and the results obtained by a computer, which showed how the results differ. Computer results were more evenly distributed, but I can not find the google link.

0
source

I can say that this is not how large poker sites do it. A preliminary shuffling of the deck makes the card sequence available in memory on the game server somewhere, i.e. It can be read if you have access to the server (for example, operators). Instead, cards are randomly selected from the deck when they are needed (using a safe random case over hardware RNG). This sometimes overshadows your mind when you get the “wrong” community cards, because if you just waited longer for milliseconds to call, they were different :)

0
source

Source: https://habr.com/ru/post/1308046/


All Articles