예제 #1
0
        public bool TestNotEvenPair(List <string> inp_holeCards,
                                    List <string> inp_commonCards,
                                    int exp_result,
                                    HandClass inp_hc)
        {
            var _hs = inp_hc.evaluateHands(inp_holeCards, inp_commonCards);

            return(_hs.Item1 == exp_result);
        }
예제 #2
0
        public bool TestHand(List <string> inp_holeCards,
                             List <string> inp_commonCards,
                             int exp_result,
                             HandClass inp_hc,
                             HandClass.HandStrength exp_hs)
        {
            var _hs = inp_hc.evaluateHands(inp_holeCards, inp_commonCards);

            bool isTrips = _hs.Item1 == (int)exp_hs;

            bool isNumber = _hs.Item2 == exp_result;

            if (isTrips & isNumber)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        public bool TestKickers(List <string> inp_holeCards,
                                List <string> inp_commonCards,
                                int kicker_val,
                                int kicker_ind,
                                HandClass inp_hc)
        {
            var _hs = inp_hc.evaluateHands(inp_holeCards, inp_commonCards);

            List <int> kickers = _hs.Item3;
            int        ki;

            try {
                ki = kickers[kicker_ind];
            }
            catch {
                return(false);
            }

            return(ki == kicker_val);
        }
예제 #4
0
파일: Game.cs 프로젝트: sutt/exercises
        public List <int> evalWinner(List <List <string> > playerHoleCards, List <string> commonCards)
        {
            /*returns: List of player(s) who are top hand in the game */

            HandClass  hc        = new HandClass();
            int        playerLen = playerHoleCards.Count;
            List <int> ret       = new List <int>()
            {
            };

            List <Tuple <int, int, List <int> > > eval_ret2 = new List <Tuple <int, int, List <int> > >();
            List <int> evalHand = new List <int>()
            {
            };
            List <int> evalRank = new List <int>()
            {
            };
            List <List <int> > evalKickers = new List <List <int> >()
            {
            };

            foreach (List <string> _holeCards in playerHoleCards)
            {
                eval_ret2.Add(hc.evaluateHands(_holeCards, commonCards));
                evalHand.Add(hc.evaluateHands(_holeCards, commonCards).Item1);
                evalRank.Add(hc.evaluateHands(_holeCards, commonCards).Item2);
                evalKickers.Add(hc.evaluateHands(_holeCards, commonCards).Item3);
            }

            int        maxHand  = evalHand.Max();
            List <int> topHands = Enumerable.Range(0, evalHand.Count)
                                  .Where(i => evalHand[i] == maxHand)
                                  .ToList();

            if (topHands.Count == 1)
            {
                return(topHands);
            }
            else
            {
                int        maxRank  = evalRank.Max();
                List <int> topRanks = Enumerable.Range(0, topHands.Count)
                                      .Where(i => (evalRank[i] == maxRank) &
                                             (evalHand[i] == maxHand))
                                      .ToList();
                if (topRanks.Count == 1)
                {
                    return(topRanks);
                }
                else
                {
                    List <List <int> > kickersLeft = new List <List <int> >();
                    for (int h = 0; h < topRanks.Count; h++)
                    {
                        kickersLeft.Add(evalKickers[topRanks[h]]);
                    }

                    List <int> maxKickers = maxKicker(kickersLeft);

                    List <int> topKickers = Enumerable.Range(0, evalHand.Count)
                                            .Where(i => (evalRank[i] == maxRank) &
                                                   (evalHand[i] == maxHand) &
                                                   (Enumerable.SequenceEqual(
                                                        evalKickers[i], maxKickers)))
                                            .ToList();

                    if (topKickers.Count == 1)
                    {
                        return(topKickers);
                    }
                    else
                    {
                        //Split Pot, not even kickers break the tie
                        return(topKickers);
                    }
                }
            }
        }