Determining how many cards of a Poker hand to discard

770 Views Asked by At

I am programming a game of 5 Card Poker, and an AI to play it. I have written a function that calculates, for a given card in a hand, the probability of improving the hand if this card is discarded and swapped for another random card dealt from the deck. As of now, the probability is calculated on the assumption that all other 47 cards are still in the deck. This will be refined at a later stage.

I now need to write a function that determines which, and how many (0, 1, 2, or 3) cards to discard from a hand.

  1. If I have the probability for each of the 5 cards, what is the best way to determine what combination (of up to 3) of these cards will give the largest possibility in improving the hand?
  2. What would be a suitable way to determine, based on this accumulated probability, if the cards should actually be discarded or not?
1

There are 1 best solutions below

0
On

But the objective is not just to improve but to improve to the best hand.

A 2 has the same chance to improve as Ace

Improve to the best possible hand is also not correct as would always draw for a straight flush

As for what to discard. The cards that don't make the hand.

  • Keep any 5 card hand (straight, flush, boat)
  • Keep quads
  • Keep trips
  • Keep 2 pairs
  • Keep 1 pair JJ+
  • Keep any 4 flush or 4 straight
  • Keep any Ax suited
  • Keep any pair
  • Keep suited connector 5 or higher or 1 gap suited
  • Keep 2 biggest cards if bigger than 7
  • Keep un-suited connector 5 or higher or 1 gap suited
  • Keep top two cards

If you have to pay to continue then many hands should be folded