Exemplo n.º 1
0
        public float GetProbability(SimPlayerTurnContext context, Card card, HashSet <Card> cardsNotInDeck, ICollection <Card> cards)
        {
            float value = 0;

            for (int play = 0; play < NumberOfPlayouts; ++play)
            {
                var currentContext = context.DeepClone();

                this.Cards = new List <Card>(cards);
                var currentDeck = new SimDeck(cardsNotInDeck, currentContext.TrumpCard);

                var firstAction  = (currentContext.FirstPlayedCard != null) ? SimPlayerAction.PlayCard(currentContext.FirstPlayedCard) : null;
                var secondAction = (card == null) ? SimPlayerAction.CloseGame() : SimPlayerAction.PlayCard(card);

                var playAction = (card == null) ? this.CloseGame() : this.PlayCard(card);

                var firstPlayer = new SimDummyPlayer();

                var opponentCardsNumber = (currentContext.FirstPlayedCard == null) ? this.Cards.Count + 1 : this.Cards.Count;

                for (int i = 0; i < opponentCardsNumber; i++)
                {
                    if (currentDeck.CardsLeft == 0)
                    {
                        break;
                    }

                    firstPlayer.AddCard(currentDeck.GetNextCard());
                }

                var stateManager = new SimStateManager();
                stateManager.SetState(currentContext.State);
                var round = new SimRound(firstPlayer, this, GameRulesProvider.Santase, currentDeck, stateManager);


                var result = round.PlaySimulation(
                    currentContext.FirstPlayerRoundPoints,
                    currentContext.SecondPlayerRoundPoints,
                    firstAction,
                    secondAction,
                    firstPlayer.Cards,
                    this.Cards);

                value += this.Expand(result);
            }

            value = value / NumberOfPlayouts;

            return(value);
        }
Exemplo n.º 2
0
        public float GetProbability(SimPlayerTurnContext context, Card card, HashSet<Card> cardsNotInDeck, ICollection<Card> cards)
        {
            float value = 0;
            for (int play = 0; play < NumberOfPlayouts; ++play)
            {
                var currentContext = context.DeepClone();

                this.Cards = new List<Card>(cards);
                var currentDeck = new SimDeck(cardsNotInDeck, currentContext.TrumpCard);

                var firstAction = (currentContext.FirstPlayedCard != null) ? SimPlayerAction.PlayCard(currentContext.FirstPlayedCard) : null;
                var secondAction = (card == null) ? SimPlayerAction.CloseGame() : SimPlayerAction.PlayCard(card);

                var playAction = (card == null) ? this.CloseGame() : this.PlayCard(card);

                var firstPlayer = new SimDummyPlayer();

                var opponentCardsNumber = (currentContext.FirstPlayedCard == null) ? this.Cards.Count + 1 : this.Cards.Count;

                for (int i = 0; i < opponentCardsNumber; i++)
                {
                    if (currentDeck.CardsLeft == 0)
                    {
                        break;
                    }

                    firstPlayer.AddCard(currentDeck.GetNextCard());
                }

                var stateManager = new SimStateManager();
                stateManager.SetState(currentContext.State);
                var round = new SimRound(firstPlayer, this, GameRulesProvider.Santase, currentDeck, stateManager);

                var result = round.PlaySimulation(
                                                    currentContext.FirstPlayerRoundPoints,
                                                    currentContext.SecondPlayerRoundPoints,
                                                    firstAction,
                                                    secondAction,
                                                    firstPlayer.Cards,
                                                    this.Cards);

                value += this.Expand(result);
            }

            value = value / NumberOfPlayouts;

            return value;
        }