/// <summary>
        /// Initializes a new instance of the HandAveragePair class.
        /// </summary>
        /// <param name="hand">A hand</param>
        /// <param name="strength">A strength</param>
        internal HandStrengthWavePair(Hand hand, StrengthWave strength)
        {
            if (hand == null || strength == null)
            {
                throw new ArgumentException("Recieved a null parameter");
            }

            this.Hand     = hand;
            this.FuzzySet = strength;
        }
Example #2
0
        private static StrengthWave CalculateFlopOrTurnStrength(Hand hand, IReadOnlyList <Card> communityCardList)
        {
            List <CardSuit> flushSuits;
            List <CardSuit> nonFlushSuits;

            DetermineFlushAndNonFlushSuits(communityCardList, out flushSuits, out nonFlushSuits);

            List <Card> takenList = new List <Card>(communityCardList);

            takenList.Add(hand.Card2);
            takenList.Add(hand.Card1);

            List <StrengthWave> compilationList = new List <StrengthWave>();

            // If at least one suit with no flush possibility
            if (nonFlushSuits.Count >= 1)
            {
                // For each card value ("None" is 13)
                for (int valueInt = 0; valueInt < 13; ++valueInt)
                {
                    IReadOnlyList <Card> notTakenList =
                        DetermineNonFlushNonTakenCards(valueInt, flushSuits, takenList);

                    // If at least one not taken
                    if (notTakenList.Count > 0)
                    {
                        // Calculate strength once
                        StrengthWave strength = NextStreetHelper(hand, communityCardList, notTakenList[0]);

                        // Add result into running list for each not taken card
                        foreach (Card card in notTakenList)
                        {
                            compilationList.Add(strength);
                        }
                    }
                }
            }

            // For each represented suit that a flush is possible in
            foreach (CardSuit suit in flushSuits)
            {
                List <Card> notTakenList = new List <Card>();

                // For each card value ("None" is 13)
                for (int valueInt = 0; valueInt < 13; ++valueInt)
                {
                    CardValue value = (CardValue)valueInt;

                    // Get the card
                    Card candidateCard = Card.ToCardFromEnums(value, suit);

                    // If not taken
                    if (!Card.CardListContainsCard(takenList, candidateCard))
                    {
                        notTakenList.Add(candidateCard);
                    }
                }

                // Calculate and add strength once for each not taken card
                foreach (Card card in notTakenList)
                {
                    compilationList.Add(NextStreetHelper(hand, communityCardList, card));
                }
            }

            return(new StrengthWave(compilationList));
        }