HoldemHand.Hand.DetailedOddsWithMultiplePlayers C# (CSharp) Method

DetailedOddsWithMultiplePlayers() public static method

Cacluates the approxamate odds that each player and opponent mask type has to win. This method uses Monte Carlo Analysis to determine a results. The quality of the result will depend on the amount of time allowed for the simulation.
public static DetailedOddsWithMultiplePlayers ( string pocket, string board, ulong dead, int playerCount, double &playerodds, double &oppodds, double duration ) : void
pocket string Players Hand
board string Current Board
dead ulong Dead Cards
playerCount int the number of players in the mask.
playerodds double The returned odds array for the player
oppodds double The returned odds array for the opponents
duration double The time allowed to run the simulation
return void
        public static void DetailedOddsWithMultiplePlayers(string pocket, string board, ulong dead, int playerCount, out double[] playerodds, out double[] oppodds, double duration)
        {
            #if DEBUG
            if (!Hand.ValidateHand(board)) throw new ArgumentException();
            if (playerCount < 1 || playerCount > 9) throw new ArgumentException();
            if (Hand.BitCount(Hand.ParseHand(board)) > 5) throw new ArgumentException();
            if (duration < 0.0) throw new ArgumentException();
            #endif
            Random rand = new Random();
            ulong boardmask = Hand.ParseHand(board);
            ulong[] pocketlist = PocketHands.Query(pocket, boardmask | dead);
            double[] podds = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            double[] oodds = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
            ulong[] opponent = new ulong[playerCount];
            uint[] oppHandVal = new uint[playerCount];
            double start = Hand.CurrentTime;
            int count = 0;
            ulong deadmask, finalboard, pocketmask;
            uint best;

            while ((Hand.CurrentTime - start) < duration)
            {
                pocketmask = Hand.RandomHand(rand, pocketlist, boardmask, 2);

                // The order cards are dealt doesn't effect the resulting
                // odds in a simulation like this. So for coding convienence
                // we will draw the board cards before the opponents cards.
                finalboard = Hand.RandomHand(rand, boardmask, pocketmask | dead, 5);
                deadmask = pocketmask | dead | finalboard;

                for (int i = 0; i < playerCount; i++)
                {
                    deadmask |= opponent[i] = Hand.RandomHand(rand, 0UL, deadmask, 2);
                    oppHandVal[i] = Hand.Evaluate(opponent[i] | finalboard, 7);
                }

                uint handval = Hand.Evaluate(pocketmask | finalboard, 7);

                Array.Sort<uint>(oppHandVal);
                best = oppHandVal[playerCount - 1];

                if (handval > best)
                {
                    podds[Hand.HandType(handval)] += 1.0;
                }
                else if (handval == best)
                {
                    podds[Hand.HandType(handval)] += 0.5;
                    oodds[Hand.HandType(best)] += 0.5;
                }
                else
                {
                    oodds[Hand.HandType(best)] += 1.0;
                }
                count++;
            }

            if (count > 0)
            {
                for (int i = 0; i < podds.Length; i++)
                {
                    podds[i] /= count;
                    oodds[i] /= count;
                }
            }

            // The returned results
            playerodds = podds;
            oppodds = oodds;
        }

Same methods

Hand::DetailedOddsWithMultiplePlayers ( string pocket, string board, ulong dead, int playerCount, double &playerodds, double &oppodds, int trials ) : void
Hand::DetailedOddsWithMultiplePlayers ( ulong pocket, ulong board, ulong dead, int playerCount, double &playerodds, double &oppodds, double duration ) : void
Hand::DetailedOddsWithMultiplePlayers ( ulong pocket, ulong board, ulong dead, int playerCount, double &playerodds, double &oppodds, int trials ) : void