Example #1
0
        public HandMask[][][] Calculate(HandRange[] ranges, Card[] boardCards, int numIterations, bool[] show)
        {
            Count = 0;
            ulong board = 0ul;
            ulong[] boardParts = new ulong[3];
            int[] numCardsSelected = new int[3];
            HandMask[][][] conditionMasks = new HandMask[numIterations][][];

            //-------------------------------------------------------------------------------------
            // Get all the possible hand ranges and their probabilities given the range data
            //-------------------------------------------------------------------------------------
            HandProbability[][] combos = CollateHandRangeCombinations(ranges);

            //-------------------------------------------------------------------------------------
            // Initialise the board mask from the model data
            //-------------------------------------------------------------------------------------
            int numCards = InitialiseBoardCards(boardCards, ref boardParts, ref numCardsSelected, ref board);

            //-------------------------------------------------------------------------------------
            // Iterate through a series of random sets of board cards
            //-------------------------------------------------------------------------------------
            for (int i = 0; i < numIterations; i++)
            {
                conditionMasks[i] = GetConditionResults(new ulong[0], ranges, combos, show, board, boardParts, numCardsSelected);
                Count++;
            }

            return conditionMasks;
        }
Example #2
0
 public static void CompileResults(HandMask[][][] masks, int numHands, List<RangeCalculatorResult> results)
 {
     for (int hand = 0; hand < numHands; hand++)
     {
         foreach (RangeCalculatorResult result in results)
         {
             int round = ((int)result.Round) - 1;
             HandMask mask = masks[hand][round][result.PlayerIndex];
             if (result.Condition.Matches(mask))
             {
                 result.Count++;
                 /*
                 if ((mask.Mask & MaskedEvaluator.HANDCONDITION_ISWINNER) > 0)
                     result.WinCount++;
                  */
             }
             result.Total++;
         }
     }
 }
Example #3
0
 public bool Matches(HandMask mask)
 {
     return _condition.Matches(mask);
 }
Example #4
0
 public bool Matches(HandMask mask)
 {
     ulong result = _mask & mask.Mask;
     return (result == _mask);
 }
Example #5
0
        public bool Matches(HandMask mask)
        {
            foreach (CompiledConditionWorker atom in _andConditions)
            {
                if (!atom.Matches(mask))
                    return false;
            }

            foreach (CompiledConditionWorker atom in _orConditions)
            {
                if (atom.Matches(mask))
                    return true;
            }

            return _orConditions.Length == 0;
        }
Example #6
0
        /// <summary>
        /// Get the set of results and conditions relating to the given board and set of hands
        /// </summary>
        /// <param name="round"></param>
        /// <param name="numCards"></param>
        /// <param name="hands"></param>
        /// <param name="board"></param>
        /// <param name="conditions"></param>
        /// <returns></returns>
        protected HandMask[] SetResults(int numCards, ulong[] hands, ulong board)
        {
            HandMask[] values = new HandMask[hands.Length];
            uint winningValue = 0;

            for (int i = 0; i < hands.Length; i++)
            {
                values[i] = MaskedEvaluator.Evaluate(board, hands[i], numCards + 2);
                if (values[i].Result > winningValue)
                    winningValue = values[i].Result;
            }

            for (int i = 0; i < hands.Length; i++)
                if (values[i].Result == winningValue)
                    values[i].IsWinner = true;
            return values;
        }
Example #7
0
        protected HandMask[][] GetConditionResults(ulong[] pockets, HandRange[] ranges, HandProbability[][] combos,
            bool[] show, ulong fullBoard, ulong[] boardPart, int[] numCardsSelected)
        {
            ulong[] hands = GetHands(pockets, ranges, combos, fullBoard);
            HandMask[][] handMasks = new HandMask[][] {
                new HandMask[hands.Length],
                new HandMask[hands.Length],
                new HandMask[hands.Length],
            };
            ulong dead = 0;

            foreach (ulong hand in hands)
                dead |= hand;

            ulong board = boardPart[0] | GetRandomCards(dead, 3 - numCardsSelected[0]);
            if (show[0])
                handMasks[0] = SetResults(3, hands, board);

            board |= boardPart[1] | GetRandomCards(dead | board, 1 - numCardsSelected[1]);
            if (show[1])
                handMasks[1] = SetResults(4, hands, board);

            board |= boardPart[2] | GetRandomCards(dead | board, 1 - numCardsSelected[2]);
            if (show[2])
                handMasks[2] = SetResults(5, hands, board);

            return handMasks;
        }