Example #1
0
 private double SimpleEstimate(GameState state, KnownHand myHand)
 {
     return(myHand.Sum(card =>
     {
         var relativePositionInDeck = 1.0 * _cardIndices[card] / (Deck.Count - 1);
         return Math.Pow(relativePositionInDeck, state.Players.Count);
     }));
 }
Example #2
0
        public void OwnHand_CardNotInHand_CantBePlayed()
        {
            var sut  = new KnownHand(new[] { new Card(Suit.Hearts, Rank.Nine) });
            var card = new Card(Suit.Hearts, Rank.Ten);

            var result = sut.CanPlay(card, TrickState.Initial);

            Assert.False(result);
        }
Example #3
0
        public void OwnHand_WhenHandEmpty_CantPlayCard()
        {
            var sut  = new KnownHand(Enumerable.Empty <Card>());
            var card = new Card(Suit.Hearts, Rank.Ten);

            var result = sut.CanPlay(card, TrickState.Initial);

            Assert.False(result);
        }
Example #4
0
        public void OwnHand_Initially_AnyCardCanBePlayed()
        {
            var sut = new KnownHand(new[] {
                new Card(Suit.Hearts, Rank.Nine),
                new Card(Suit.Diamonds, Rank.King),
                new Card(Suit.Club, Rank.Ten)
            });
            var card = new Card(Suit.Diamonds, Rank.King);

            var result = sut.CanPlay(card, TrickState.Initial);

            Assert.True(result);
        }
Example #5
0
        public void OwnHand_SuitToFollowNotPresent_CanPlayAnother()
        {
            var sut = new KnownHand(new[] {
                new Card(Suit.Club, Rank.Nine),
                new Card(Suit.Diamonds, Rank.King),
            });
            var card = new Card(Suit.Diamonds, Rank.King);
            var stateWithHeartsPlayed = TrickState.Initial
                                        .Next(AsMove(new Card(Suit.Hearts, Rank.Five)));

            var result = sut.CanPlay(card, stateWithHeartsPlayed);

            Assert.True(result);
        }