///// CLASS LOGIC ///// public List <BestHand> analyzeBoard() { var madeHands = new List <BestHand>(); foreach (T h in this.range.hands) { var ha = new HandAnalyzer(h, this.board); madeHands.Add(ha.bestHand); } madeHands.Sort((x, y) => BestHand.compare(x, y)); return(madeHands); }
// used to compare public static int compare(BestHand b1, BestHand b2) { int case1 = Hand.compare(b1.primary, b2.primary); if (case1 != 0) { return(case1); } else { int case2 = Hand.compare(b1.secondary, b2.secondary); return(case2); } }
// used to ___??? public static WinState determineWinner(Board b, List <PreflopHand> hands) { var analyzers = new Dictionary <string, HandAnalyzer>(); foreach (PreflopHand h in hands) { analyzers.Add(String.Format("hand-{0}", hands.IndexOf(h)), new HandAnalyzer(h, b)); } var winningHands = new List <BestHand>(); // tracks all hands that are due a share of the Pot foreach (KeyValuePair <string, HandAnalyzer> a in analyzers) { BestHand competitor = analyzers[a.Key].bestHand; if (winningHands.Count == 0) { winningHands.Add(competitor); } else { int winner = BestHand.compare(competitor, winningHands[0]); if (winner == 0) { winningHands.Add(competitor); } else if (winner == 1) { winningHands = new List <BestHand>() { competitor }; } } } double equity = PickWinner.calculateEquitySplit(winningHands.Count); return(new WinState(equity, winningHands)); }
public HandAnalyzer(PreflopHand pf, Board b, bool toPrint = false, bool checkDraws = false) { // dependencies this.hand = pf; this.board = b; this.availableCards = pf.cards.Concat(b.getCards()).ToList(); this.deck = new Deck(new HashSet <Card>(this.availableCards)); // init class properties this.bestHand = null; this.quads = new HashSet <FourOfAKind>(); this.trips = new HashSet <ThreeOfAKind>(); this.pairs = new HashSet <Pair>(); this.flushes = new HashSet <Flush>(); this.straights = new HashSet <Straight>(); // populate class properties (e.g. poker hands) this.analyzePairedHands(); this.analyzeStraights(checkDraws); this.analyzeFlushes(checkDraws); // create best possible MadeHand from hand collections this.calculateBestHand(); }