Ejemplo n.º 1
0
        public void run()
        {
            List <PreflopHand> hands = this.equities.Select(eq => eq.hand).ToList();

            foreach (int n in Enumerable.Range(0, this.iterations))
            {
                Deck  d = new Deck(new HashSet <Card>(this.deadCards));
                Board b = Board.generateBoard(d, this.board);

                WinState ws = PickWinner.determineWinner(b, hands);
                foreach (Equity eq in this.equities)
                {
                    bool matched = false;
                    foreach (BestHand bh in ws.winningHands)
                    {
                        if (bh.hasBestHand(eq.hand, b))
                        {
                            matched = true;
                        }
                        if (matched)
                        {
                            eq.updateEquity(ws.equity);
                        }
                        else
                        {
                            eq.updateEquity(0);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void handleEndgame(Board b, Pot pot)
        {
            List <Player>      players = table.getPlayersToAnalyze();
            List <PreflopHand> hands   = players.Select(p => p.Hand).ToList();

            WinState ws       = PickWinner.determineWinner(b, hands);
            double   potShare = pot.PotSize * ws.equity;

            foreach (Player p in players)
            {
                foreach (BestHand bh in ws.winningHands)
                {
                    if (bh.hasBestHand(p.Hand, b))
                    {
                        p.addToStack(potShare);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        // 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));
        }