Ejemplo n.º 1
0
        public void DiscardEstimator_AllCardsWithSameProbability_ReturnsAllCards()
        {
            var discardStrategyStub = CreateDiscardStrategy();
            var blueOneCard         = new Card(Color.Blue, Rank.One);
            var yellowTwoCard       = new Card(Color.Yellow, Rank.Two);
            var yellowThreeCard     = new Card(Color.Yellow, Rank.Three);

            discardStrategyStub.AddToHand(blueOneCard);
            discardStrategyStub.AddToHand(yellowTwoCard);
            discardStrategyStub.AddToHand(yellowThreeCard);

            var dict = new Dictionary <Card, double>
            {
                [blueOneCard]     = 0.3,
                [yellowTwoCard]   = 0.3,
                [yellowThreeCard] = 0.3
            };

            SetProbabilities(discardStrategyStub, dict);

            var boardContext  = new BoardContextStub();
            var playerContext = PlayerContextFabric.CreateStub(discardStrategyStub.Player, discardStrategyStub.Hand);

            // act
            var estimator = new DiscardEstimator(discardStrategyStub);
            var cards     = estimator.GetPossibleCards(boardContext, playerContext);

            // arrange
            Assert.AreEqual(3, cards.Count);
        }
Ejemplo n.º 2
0
        public void DiscardEstimator_BlueOneHasMaxProbability_ReturnsBlueOne()
        {
            var discardStrategyStub = CreateDiscardStrategy();

            var blueOneCard     = new Card(Color.Blue, Rank.One);
            var yellowTwoCard   = new Card(Color.Yellow, Rank.Two);
            var yellowThreeCard = new Card(Color.Yellow, Rank.Three);

            discardStrategyStub.AddToHand(blueOneCard);
            discardStrategyStub.AddToHand(yellowTwoCard);
            discardStrategyStub.AddToHand(yellowThreeCard);

            var dict = new Dictionary <Card, double>
            {
                [blueOneCard]     = 0.5,
                [yellowTwoCard]   = 0.3,
                [yellowThreeCard] = 0.25
            };

            SetProbabilities(discardStrategyStub, dict);

            var boardContext = new BoardContextStub();
            //new BoardContext(new FireworkPile(discardStrategyStub.GameProvider), new Card[0], new Card[0]);
            var playerContext = PlayerContextFabric.CreateStub(discardStrategyStub.Player, discardStrategyStub.Hand);

            // Act
            var estimator = new DiscardEstimator(discardStrategyStub);
            var cards     = estimator.GetPossibleCards(boardContext, playerContext);

            // Assert
            Assert.AreEqual(1, cards.Count);
            Assert.AreEqual(blueOneCard, cards[0]);
        }
Ejemplo n.º 3
0
        public void DiscardEstimator_KnowAboutBlueOneOnlyAndProbability10_ReturnsBlueOne()
        {
            var discardStrategyStub = CreateDiscardStrategy();

            var blueOneCard     = new Card(Color.Blue, Rank.One);
            var yellowTwoCard   = new Card(Color.Yellow, Rank.Two);
            var yellowThreeCard = new Card(Color.Yellow, Rank.Three);

            discardStrategyStub.AddToHand(blueOneCard);
            discardStrategyStub.AddToHand(yellowTwoCard);
            discardStrategyStub.AddToHand(yellowThreeCard);

            var dict = new Dictionary <Card, double>
            {
                [blueOneCard]     = 1.0,
                [yellowTwoCard]   = 0.25,
                [yellowThreeCard] = 0.25
            };

            SetProbabilities(discardStrategyStub, dict);

            var boardContext = new BoardContextStub();
            //new BoardContext(new FireworkPile(discardStrategyStub.GameProvider), new Card[0], new Card[0]);
            var playerContext = PlayerContextFabric.CreateStub(discardStrategyStub.Player, discardStrategyStub.Hand);

            playerContext.KnowAboutRankOrColorPredicate = cardInHand => cardInHand.Card == blueOneCard;

            // Act
            var estimator = new DiscardEstimator(discardStrategyStub);
            var cards     = estimator.GetPossibleCards(boardContext, playerContext);

            // Assert
            Assert.AreEqual(1, cards.Count);
            Assert.IsTrue(cards.Contains(blueOneCard));
        }
Ejemplo n.º 4
0
        public void DiscardEstimator_KnowSomethingAboutAllCardsAndTheSameProbabilities_ReturnsAllCards()
        {
            var discardStrategyStub = CreateDiscardStrategy();

            var blueOneCard     = new Card(Color.Blue, Rank.One);
            var yellowTwoCard   = new Card(Color.Yellow, Rank.Two);
            var yellowThreeCard = new Card(Color.Yellow, Rank.Three);

            discardStrategyStub.AddToHand(blueOneCard);
            discardStrategyStub.AddToHand(yellowTwoCard);
            discardStrategyStub.AddToHand(yellowThreeCard);

            var dict = new Dictionary <Card, double>
            {
                [blueOneCard]     = 0.33,
                [yellowTwoCard]   = 0.33,
                [yellowThreeCard] = 0.33
            };

            SetProbabilities(discardStrategyStub, dict);

            var boardContext  = new BoardContextStub();//new BoardContext(new FireworkPile(discardStrategyStub.GameProvider), new Card[0], new Card[0]);
            var playerContext = PlayerContextFabric.CreateStub(discardStrategyStub.Player, discardStrategyStub.Hand);

            playerContext.KnowAboutRankOrColorPredicate = cardInHand => true;


            var estimator = new DiscardEstimator(discardStrategyStub);
            var cards     = estimator.GetPossibleCards(boardContext, playerContext);

            Assert.AreEqual(3, cards.Count);
        }