Example #1
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 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);
        }
Example #3
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 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 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);
        }
        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 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);
        }
Example #8
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 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);
        }
        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);
        }
        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 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 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);
        }
Example #14
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);
        }
Example #15
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);
        }
Example #16
0
        public static PokerScoreOuts CalculateTurn(FiveCardHand cards)
        {
            if (cards.HasPair())
            {
                return(TurnOutsDictionary[Pokerscore.Pair]);
            }

            return(new PokerScoreOuts {
                Outs = 0, Percentage = 1.39, RunnerRunner = true
            });
        }
        public static PokerScoreOuts CalculateTurn(FiveCardHand cards)
        {
            if (cards.HasThreeOfAKind())
            {
                return(TurnOutsDictionary[Pokerscore.ThreeOfAKind]);
            }
            if (cards.HasTwoPair())
            {
                return(TurnOutsDictionary[Pokerscore.TwoPair]);
            }

            return(PokerHelper.CreateTurnOuts(0, false));
        }
Example #18
0
        public static int CalculateTurn(FiveCardHand cards)
        {
            if (cards.CountFlush() == 4)
            {
                return(9);
            }
            if (cards.CountFlush() == 3)
            {
                return(10);
            }

            return(0);
        }
Example #19
0
        public static PokerScoreOuts CalculateTurn(FiveCardHand cards)
        {
            if (cards.CountFlush() == 4)
            {
                return(PokerHelper.CreateTurnOuts(9, false));
            }
            if (cards.CountFlush() == 3)
            {
                return new PokerScoreOuts {
                           Outs = 0, Percentage = 4.163, RunnerRunner = true
                }
            }
            ;

            return(PokerHelper.CreateTurnOuts(0, false));
        }
Example #20
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);
            }
        }
        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);
            }
        }
 public static int CalculateTurn(FiveCardHand cards)
 {
     return(0);
 }
 public static PokerScoreOuts CalculateTurn(FiveCardHand cards)
 {
     return(new PokerScoreOuts {
         Outs = 0, Percentage = 0, RunnerRunner = true
     });
 }
Example #24
0
        public static PokerScoreOuts CalculateTurn(FiveCardHand cards)
        {
            ISet <int> open       = new HashSet <int>(),
                       missingOne = new HashSet <int>(),
                       missingTwo = new HashSet <int>(),
                       inside     = new HashSet <int>(),
                       outside    = new HashSet <int>();

            var withoutPair = cards.RemovePairs();
            var handList    = new List <int> {
                cards.Cards[0].ToInt(), cards.Cards[1].ToInt(), cards.Cards[2].ToInt(), cards.Cards[3].ToInt(), cards.Cards[4].ToInt()
            };

            if (withoutPair.Count <= 2)
            {
                return(PokerHelper.CreateTurnOuts(0, true));
            }
            if (withoutPair.Count == 3)
            {
                if (withoutPair[2].Rank == Rank.Ace && withoutPair[0].Rank <= Rank.Four)
                {
                    withoutPair = new List <Card> {
                        withoutPair[2], withoutPair[0], withoutPair[1]
                    }
                }
                ;
                open       = PokerHelper.CountThreeOpenEnded(handList, withoutPair);
                missingOne = PokerHelper.CountThreeMissingOne(handList, withoutPair);
                missingTwo = PokerHelper.CountThreeMissingTwo(handList, withoutPair);

                return(PokerHelper.RunnerRunnerOuts(open, missingOne, missingTwo));
            }
            if (withoutPair.Count == 4)
            {
                outside = PokerHelper.CountOutsideStraightDraws(handList, withoutPair);
                if (outside.Count > 0)
                {
                    return(PokerHelper.CreateTurnOuts(outside.Count * 4, false));
                }

                inside = PokerHelper.CountInsideStraightDraws(handList, withoutPair);
                if (inside.Count > 0)
                {
                    return(PokerHelper.CreateTurnOuts(inside.Count * 4, false));
                }

                if (withoutPair[3].Rank == Rank.Ace)
                {
                    var comb = new List <Card> {
                        withoutPair[3], withoutPair[0], withoutPair[1]
                    };
                    open.UnionWith(PokerHelper.CountThreeOpenEnded(handList, comb));
                    missingOne.UnionWith(PokerHelper.CountThreeMissingOne(handList, comb));
                    missingTwo.UnionWith(PokerHelper.CountThreeMissingTwo(handList, comb));
                }

                foreach (var comb in PokerEnumerator.GetThreeCardsFromFour(withoutPair))
                {
                    open.UnionWith(PokerHelper.CountThreeOpenEnded(handList, comb));
                    missingOne.UnionWith(PokerHelper.CountThreeMissingOne(handList, comb));
                    missingTwo.UnionWith(PokerHelper.CountThreeMissingTwo(handList, comb));
                }

                return(PokerHelper.RunnerRunnerOuts(open, missingOne, missingTwo));
            }
            if (withoutPair.Count == 5)
            {
                //Four card collections
                if (withoutPair[4].Rank == Rank.Ace && withoutPair[2].Rank <= Rank.Five)
                {
                    var comb = new List <Card> {
                        withoutPair[4], withoutPair[0], withoutPair[1], withoutPair[2]
                    };

                    outside.UnionWith(PokerHelper.CountOutsideStraightDraws(handList, comb));
                    if (outside.Count > 0)
                    {
                        return(PokerHelper.CreateTurnOuts(outside.Count * 4, false));
                    }

                    inside.UnionWith(PokerHelper.CountInsideStraightDraws(handList, comb));
                    if (inside.Count > 0)
                    {
                        return(PokerHelper.CreateTurnOuts(inside.Count * 4, false));
                    }
                }

                foreach (var comb in PokerEnumerator.GetFourCardsFromFive(withoutPair))
                {
                    outside.UnionWith(PokerHelper.CountOutsideStraightDraws(handList, comb));
                    inside.UnionWith(PokerHelper.CountInsideStraightDraws(handList, comb));
                }

                outside.UnionWith(inside);
                if (outside.Count > 0)
                {
                    return(PokerHelper.CreateRiverOuts(outside.Count * 4));
                }

                //Three card collections
                if (withoutPair[4].Rank == Rank.Ace)
                {
                    var comb = new List <Card> {
                        withoutPair[4], withoutPair[0], withoutPair[1]
                    };
                    open.UnionWith(PokerHelper.CountThreeOpenEnded(handList, comb));
                    missingOne.UnionWith(PokerHelper.CountThreeMissingOne(handList, comb));
                    missingTwo.UnionWith(PokerHelper.CountThreeMissingTwo(handList, comb));
                }

                foreach (var comb in PokerEnumerator.GetThreeCardsFromFive(withoutPair))
                {
                    open.UnionWith(PokerHelper.CountThreeOpenEnded(handList, comb));
                    missingOne.UnionWith(PokerHelper.CountThreeMissingOne(handList, comb));
                    missingTwo.UnionWith(PokerHelper.CountThreeMissingTwo(handList, comb));
                }

                return(PokerHelper.RunnerRunnerOuts(open, missingOne, missingTwo));
            }
            throw new ArgumentException("Without pair count should never be more than five");
        }
Example #25
0
 public static PokerScoreOuts CalculateTurn(FiveCardHand cards)
 {
     return(PokerHelper.CreateTurnOuts(15, false));
 }