Exemple #1
0
        internal HandState(Hand source)
        {
            Cards = BitwiseCardHelper.CardCollectionToBits(source.Cards);

            if (source.PlayedCard.HasValue)
            {
                Move = new Move(BitwiseCardHelper.CardToBits(source.PlayedCard.Value));
            }

            Tricks = source.Tricks;
        }
Exemple #2
0
        internal PlayingState(PlayingContext context)
        {
            mContext = context;

            Game game = context.Game;

            for (int i = 0; i < HandCount; i++)
            {
                mHands[i] = new HandState(game.GetHand(i));
            }

            mActiveIndex = game.ActiveHand.Index;
            mDiscards    = BitwiseCardHelper.CardCollectionToBits(game.PlayingContext.Discards);
            mLeadingSuit = context.InitialSuit;
        }
Exemple #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();
        }