andrewprock / pokerstove

poker evaluation and enumeration software
BSD 3-Clause "New" or "Revised" License
806 stars 350 forks source link

calculate readable winning hand format #69

Closed superappy closed 1 year ago

superappy commented 4 years ago

I am a noob at CPP programming yet I'm trying to integrate the library with Python. While the example program ps-eval explains evaluating the winning hand out of the input samples, is there any way to calculate winning cards out of the winning sample? For eg assuming: Board : AsKsQs2c5c Hand1 : JsTs Hand2: 3c7s Here Hand1 wins with a straight flush. So how do I evaluate to "Straight Flush AsKsQsJsTs" or something like that? Basically winning cards and winning label. Is that possible with the library?

MichaelUnknown commented 4 years ago

There is a PokerEvaluation Class, try to read up there for how individual results are represented.

 /**
   * the integer code is organized bitwise as:
   *  21 0987654 32109876 54321098 76543210
   *        TTTT MMMMmmmm BBAkkkkk kkkkkkkk
   *
   * T = type bits [0,12] (pair, trips, flush, etc...)
   * M = major rank
   * m = minor rank
   * A = ace swings low bit 0/1
   * k = kicker set
   ...

If you want just a single (holdem) result, you can use something like auto peval = pokerstove::PokerHandEvaluator::alloc("h"); auto eval = peval->evaluateHand(hand, board);