public void OutsideThreeDrawSFlushNoLowDrawWithTwoPair()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Two, Suit.Hearts),
                new Card(Rank.Three, Suit.Hearts),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Two, Suit.Spades),
                new Card(Rank.Three, Suit.Diamonds),
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(.09, outs.StraightFlush.Percentage);
            Assert.AreEqual(true, outs.StraightFlush.RunnerRunner);
            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
示例#2
0
        public void NothingToPairOuts()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Four, Suit.Hearts),
                new Card(Rank.Five, Suit.Hearts),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Seven, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var current = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs    = PokerOutsCalculator.CalculateTurnOuts(hand, current);

            watch.Stop();

            Assert.AreEqual(15, outs.Pair.Outs);
            Assert.AreEqual(false, outs.Pair.RunnerRunner);

            Assert.AreEqual(8, outs.Straight.Outs);

            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public void InsideRFlushDraw()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ten, Suit.Hearts),
                new Card(Rank.Jack, Suit.Hearts),
                new Card(Rank.Queen, Suit.Hearts),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Seven, Suit.Hearts),
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(1, outs.RoyalFlush.Outs);
            Assert.AreEqual(false, outs.RoyalFlush.RunnerRunner);
            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public void OutsideThreeDrawOneLowDraw()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Two, Suit.Hearts),
                new Card(Rank.Three, Suit.Clubs),
                new Card(Rank.Four, Suit.Clubs),
                new Card(Rank.Jack, Suit.Hearts),
                new Card(Rank.Ten, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(2.96, outs.Straight.Percentage);
            Assert.AreEqual(true, outs.Straight.RunnerRunner);
            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public void OutsideThreeDrawNoHighDrawWithTwoPair()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.King, Suit.Hearts),
                new Card(Rank.Queen, Suit.Clubs),
                new Card(Rank.King, Suit.Hearts),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Queen, Suit.Clubs)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(1.48, outs.Straight.Percentage);
            Assert.AreEqual(true, outs.Straight.RunnerRunner);

            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public void SFlushMissingTwoTwice()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Three, Suit.Hearts),
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Seven, Suit.Hearts),
                new Card(Rank.Ten, Suit.Hearts),
                new Card(Rank.Jack, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(.28, outs.StraightFlush.Percentage);
            Assert.AreEqual(true, outs.StraightFlush.RunnerRunner);

            Assert.Greater(250, watch.ElapsedMilliseconds);
        }
示例#7
0
        public void RoyalFlushMissingOneNoHighDraw()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Jack, Suit.Hearts),
                new Card(Rank.Four, Suit.Hearts),
                new Card(Rank.Five, Suit.Hearts),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.King, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(.09, outs.RoyalFlush.Percentage);
            Assert.AreEqual(true, outs.RoyalFlush.RunnerRunner);
            Assert.Greater(50, watch.ElapsedMilliseconds);
        }
        public void TwoPairToFullHouseOuts()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Ace, Suit.Clubs),
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Ten, Suit.Spades)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var current = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs    = PokerOutsCalculator.CalculateTurnOuts(hand, current);

            watch.Stop();

            Assert.AreEqual(4, outs.FullHouse.Outs);
            Assert.AreEqual(false, outs.FullHouse.RunnerRunner);

            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public void RemoveOnePairSuited()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ace, Suit.Clubs),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Seven, Suit.Clubs),
                new Card(Rank.Jack, Suit.Hearts),
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();
            watch.Start();
            var newCards = hand.RemovePairs();

            watch.Stop();


            Assert.AreEqual(4, newCards.Count);
            Assert.AreEqual(5, hand.Cards.Count);
            Assert.Greater(30, watch.ElapsedMilliseconds);
            Assert.AreEqual(true, newCards[0].Rank == Rank.Six && newCards[1].Rank == Rank.Seven && newCards[2].Rank == Rank.Jack && newCards[3].Rank == Rank.Ace && newCards[3].Suit == Suit.Hearts);
        }
示例#10
0
        public void OutsideThreeDrawRFlushNoLowDraw()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Ten, Suit.Hearts),
                new Card(Rank.Four, Suit.Hearts),
                new Card(Rank.Jack, Suit.Hearts),
                new Card(Rank.Queen, Suit.Hearts),
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(.09, outs.RoyalFlush.Percentage);
            Assert.AreEqual(true, outs.RoyalFlush.RunnerRunner);
            Assert.Greater(30, watch.ElapsedMilliseconds);
        }
        public void MissingOneWithPair()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Five, Suit.Clubs),
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Eight, Suit.Clubs),
                new Card(Rank.Six, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(2.96, outs.Straight.Percentage);
            Assert.AreEqual(true, outs.Straight.RunnerRunner);

            Assert.Greater(250, watch.ElapsedMilliseconds);
        }
        public void OutsideThreeAndMissingTwoFindsSimpleOut()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Three, Suit.Clubs),
                new Card(Rank.Four, Suit.Hearts),
                new Card(Rank.Five, Suit.Hearts),
                new Card(Rank.Seven, Suit.Clubs),
                new Card(Rank.Nine, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(4, outs.Straight.Outs);
            Assert.AreEqual(false, outs.Straight.RunnerRunner);
            Assert.Greater(250, watch.ElapsedMilliseconds);
        }
示例#13
0
        public void TwoInsideSFlushDraws()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Two, Suit.Hearts),
                new Card(Rank.Four, Suit.Hearts),
                new Card(Rank.Five, Suit.Hearts),
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Eight, Suit.Hearts),
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var score = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs  = PokerOutsCalculator.CalculateTurnOuts(hand, score);

            watch.Stop();

            Assert.AreEqual(2, outs.StraightFlush.Outs);
            Assert.AreEqual(false, outs.StraightFlush.RunnerRunner);
            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public void RemoveThreeAndPair()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Ace, Suit.Clubs),
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Seven, Suit.Clubs),
                new Card(Rank.Seven, Suit.Hearts),
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();
            watch.Start();
            var newCards = hand.RemovePairs();

            watch.Stop();


            Assert.AreEqual(2, newCards.Count);
            Assert.AreEqual(5, hand.Cards.Count);
            Assert.Greater(10, watch.ElapsedMilliseconds);
            Assert.AreEqual(true, newCards[0].Rank == Rank.Seven && newCards[1].Rank == Rank.Ace);
        }
示例#15
0
        public void PairToFourOfAKindOuts()
        {
            Stopwatch   watch = new Stopwatch();
            List <Card> cards = new List <Card>
            {
                new Card(Rank.Ace, Suit.Hearts),
                new Card(Rank.Four, Suit.Hearts),
                new Card(Rank.Six, Suit.Hearts),
                new Card(Rank.Six, Suit.Clubs),
                new Card(Rank.Seven, Suit.Hearts)
            };

            FiveCardHand hand = new FiveCardHand(cards);

            hand.Sort();

            watch.Start();
            var current = PokerEvaluator.CalculateFlopScore(hand.Cards);
            var outs    = PokerOutsCalculator.CalculateTurnOuts(hand, current);

            watch.Stop();

            Assert.AreEqual(.09, outs.FourOfAKind.Percentage);
            Assert.AreEqual(true, outs.FourOfAKind.RunnerRunner);

            Assert.Greater(200, watch.ElapsedMilliseconds);
        }
        public static PokerOuts CalculateTurnOuts(FiveCardHand cards, Pokerscore currentScore)
        {
            cards.Sort();
            PokerOuts.Clear();

            switch (currentScore)
            {
            case Pokerscore.RoyalFlush:
                return(PokerOuts);

            case Pokerscore.StraightFlush:
                PokerOuts.RoyalFlush = RoyalFlushCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.FourOfAKind:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.FullHouse:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.Flush:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.ThreeOfAKind:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                PokerOuts.Flush         = FlushCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.Straight:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                PokerOuts.Flush         = FlushCalculator.CalculateTurn(cards);
                PokerOuts.ThreeOfAKind  = ThreeOfAKindCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.TwoPair:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                PokerOuts.Flush         = FlushCalculator.CalculateTurn(cards);
                PokerOuts.ThreeOfAKind  = ThreeOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.Straight      = StraightCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.Pair:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                PokerOuts.Flush         = FlushCalculator.CalculateTurn(cards);
                PokerOuts.ThreeOfAKind  = ThreeOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.Straight      = StraightCalculator.CalculateTurn(cards);
                PokerOuts.TwoPair       = TwoPairCalculator.CalculateTurn(cards);
                return(PokerOuts);

            case Pokerscore.None:
                PokerOuts.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                PokerOuts.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                PokerOuts.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                PokerOuts.Flush         = FlushCalculator.CalculateTurn(cards);
                PokerOuts.ThreeOfAKind  = ThreeOfAKindCalculator.CalculateTurn(cards);
                PokerOuts.Straight      = StraightCalculator.CalculateTurn(cards);
                PokerOuts.TwoPair       = TwoPairCalculator.CalculateTurn(cards);
                PokerOuts.Pair          = PairCalculator.CalculateTurn(cards);
                return(PokerOuts);

            default:
                return(null);
            }
        }
示例#17
0
        public static OutsCollection CalculateTurnOuts(FiveCardHand cards, Pokerscore currentScore)
        {
            cards.Sort();
            OutsCollection.Clear();

            switch (currentScore)
            {
            case Pokerscore.RoyalFlush:
                return(OutsCollection);

            case Pokerscore.StraightFlush:
                OutsCollection.RoyalFlush = RoyalFlushCalculator.CalculateTurn(cards);
                return(OutsCollection);

            case Pokerscore.FourOfAKind:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                return(OutsCollection);

            case Pokerscore.FullHouse:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.FourOfAKind   = FourOfAKindCalculator.TurnOutsDictionary[currentScore];
                return(OutsCollection);

            case Pokerscore.Flush:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                OutsCollection.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                return(OutsCollection);

            case Pokerscore.Straight:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.FourOfAKind   = FourOfAKindCalculator.CalculateTurn(cards);
                OutsCollection.FullHouse     = FullHouseCalculator.CalculateTurn(cards);
                OutsCollection.Flush         = FlushCalculator.CalculateTurn(cards);
                return(OutsCollection);

            case Pokerscore.ThreeOfAKind:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.FourOfAKind   = FourOfAKindCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.FullHouse     = FullHouseCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.Flush         = FlushCalculator.CalculateTurn(cards);
                OutsCollection.Straight      = StraightCalculator.CalculateTurn(cards);
                return(OutsCollection);

            case Pokerscore.TwoPair:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.FourOfAKind   = FourOfAKindCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.FullHouse     = FullHouseCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.Flush         = FlushCalculator.CalculateTurn(cards);
                OutsCollection.Straight      = StraightCalculator.CalculateTurn(cards);
                return(OutsCollection);

            case Pokerscore.Pair:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.FourOfAKind   = FourOfAKindCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.FullHouse     = FullHouseCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.Flush         = FlushCalculator.CalculateTurn(cards);
                OutsCollection.ThreeOfAKind  = ThreeOfAKindCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.Straight      = StraightCalculator.CalculateTurn(cards);
                OutsCollection.TwoPair       = TwoPairCalculator.TurnOutsDictionary[currentScore];
                return(OutsCollection);

            case Pokerscore.None:
                OutsCollection.RoyalFlush    = RoyalFlushCalculator.CalculateTurn(cards);
                OutsCollection.StraightFlush = StraightFlushCalculator.CalculateTurn(cards);
                OutsCollection.Flush         = FlushCalculator.CalculateTurn(cards);
                OutsCollection.ThreeOfAKind  = ThreeOfAKindCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.Straight      = StraightCalculator.CalculateTurn(cards);
                OutsCollection.TwoPair       = TwoPairCalculator.TurnOutsDictionary[currentScore];
                OutsCollection.Pair          = PairCalculator.CalculateTurn(cards);
                return(OutsCollection);

            default:
                return(null);
            }
        }