3

I am trying to build a poker bot in java. I have written the hand evaluation class and I am about to start feeding a neural network but I face a problem. I need the winning odds of every hand for every step: preflop, flop, turn, river.

My problem is that, there are 52 cards and the combinations of 5 cards are 2,598,960. So I need to store 2,598,960 odds for each possible hand. The number is huge and these are only the odds I need for the river.

So I have two options:

  1. Find the odds for every possible hand and every possible deck and every time I start my application load them and kill my memory.
  2. Calculate the odds on the fly and lack processing power.

Is there a 3rd better option to deal with this problem?

dirac
  • 309
  • 1
  • 9
  • 2
    Where do you need to run your program? 2 million numbers (and even much more) do not seem to be a problem in any modern computer. – joanlofe Dec 23 '15 at 12:02
  • It's not just 2 million numbers. It's 2.6m * possiblle hands. Possible hand compilations are almost 1000, so it's 2.6 billions odds only for the river. – dirac Dec 23 '15 at 12:19

2 Answers2

0

3rd option is use the disk... but my first choice would be to calculate odds as you need them.

Why do you need to calculate all combinations of 5 cards, a lot of these hands are worth the same, as there are 4 suits there is repetition between hands.

Personally I would rank your hand based on how many hands beat your hand and how many hands your hand beats. From this you can compute your probability of winning the table by multiplying by number of active hands.

David Petran
  • 3
  • 1
  • 4
  • use the disk? What's that? – dirac Dec 24 '15 at 00:41
  • The hard disk, some persistent storage outside of your application. For example a database of hands to odds that you could query on the fly. Its going to be big though like at least gigabytes. – David Petran Dec 24 '15 at 08:01
  • I think this is the worst option. – dirac Dec 25 '15 at 16:05
  • @dirac storage off the odds at all is the worst option, regardless of where you choose to store them. Another problem is that if your bot is going to make decisions based on the player playing any two cards" (thus based on the full set of possible cards held by the player), your bot is going to be a loser... if the player is decent at all, they are not playing "atc", they are playing a somewhat defined range of cards (fuzzy definable based on the action leading up to the river) which will remove many possibilities from the full set of hands you base your odds on. – mah Jan 15 '16 at 15:47
0

What about ignoring the colors? From 52 possible values, you drop to 13. You only have 6175 options remaining. Of course, colors are important for a flush - but here, it is pretty much binary - are all the colors the same or not? So we are at 12350 (including some impossible combinations, in fact it is 7462 as in the others, a number is contained more than once, so the color must differ).

If the order is important (e.g. starting hand, flip, flop, river or how is it called), it will be a lot more, but it is still less than your two millions. Try simplifying your problems and you'll realize they can be solved.

Vlasec
  • 5,500
  • 3
  • 27
  • 30
  • You can't ignore colors – dirac Jan 18 '16 at 16:58
  • I don't ignore it completely. I covered the flushes, did I miss anything else? – Vlasec Jan 19 '16 at 08:33
  • Uh, I didn't realize - you are speaking about Texas Hold'em Poker, right? Then I guess it is a bit more complicated, with seven cards in total. But still, try to simplify. – Vlasec Jan 19 '16 at 09:05