Пример #1
0
        private double EvaluateDiscards(int cards)
        {
            Debug.Assert(BitwiseCardHelper.GetCardCount(cards) == 12);

            var values = new List <double>();

            var enumerator = new TwoCardsEnumerator(cards);

            while (enumerator.MoveNext())
            {
                int    cardsAfterDiscarding = cards & ~enumerator.Current;
                double value = EvaluateCards(cardsAfterDiscarding, enumerator.Current);
                values.Add(value);
            }

            return(values.Max());
        }
Пример #2
0
        /// <summary>
        /// Calculates a mathematical expectation of the active hand for a certain game type.
        /// Uses the expecti-max algorithm to compute the value among all possible widow cards and further discards.
        /// Updates the <see cref="Expectation"/> property.
        /// </summary>
        /// <returns></returns>
        internal void Evaluate()
        {
            int ownCards = BitwiseCardHelper.CardCollectionToBits(mGame.ActiveHand.Cards);
            int unknownCards = ~ownCards;

            Debug.Assert(BitwiseCardHelper.GetCardCount(unknownCards) == 22);

            var values = new List<double>();

            var enumerator = new TwoCardsEnumerator(unknownCards);
            while (enumerator.MoveNext())
            {
                int ownCardsWithWidow = ownCards | enumerator.Current;
                double value = EvaluateDiscards(ownCardsWithWidow);
                values.Add(value);
            }

            Expectation = values.Average();
        }
Пример #3
0
        /// <summary>
        /// Calculates a mathematical expectation of the active hand for a certain game type.
        /// Uses the expecti-max algorithm to compute the value among all possible widow cards and further discards.
        /// Updates the <see cref="Expectation"/> property.
        /// </summary>
        /// <returns></returns>
        internal void Evaluate()
        {
            int ownCards     = BitwiseCardHelper.CardCollectionToBits(mGame.ActiveHand.Cards);
            int unknownCards = ~ownCards;

            Debug.Assert(BitwiseCardHelper.GetCardCount(unknownCards) == 22);

            var values = new List <double>();

            var enumerator = new TwoCardsEnumerator(unknownCards);

            while (enumerator.MoveNext())
            {
                int    ownCardsWithWidow = ownCards | enumerator.Current;
                double value             = EvaluateDiscards(ownCardsWithWidow);
                values.Add(value);
            }

            Expectation = values.Average();
        }
Пример #4
0
        private double EvaluateDiscards(int cards)
        {
            Debug.Assert(BitwiseCardHelper.GetCardCount(cards) == 12);

            var values = new List<double>();

            var enumerator = new TwoCardsEnumerator(cards);
            while (enumerator.MoveNext())
            {
                int cardsAfterDiscarding = cards & ~enumerator.Current;
                double value = EvaluateCards(cardsAfterDiscarding, enumerator.Current);
                values.Add(value);
            }

            return values.Max();
        }