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 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 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 OneInsideSFlushDrawWithTwoPair() { Stopwatch watch = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Four, Suit.Spades), new Card(Rank.Four, Suit.Hearts), new Card(Rank.Five, Suit.Hearts), new Card(Rank.Six, Suit.Hearts), new Card(Rank.Eight, Suit.Hearts), new Card(Rank.Six, Suit.Diamonds), }; SixCardHand hand = new SixCardHand(cards); hand.Sort(); watch.Start(); var score = PokerEvaluator.CalculateFlopScore(hand.Cards); var outs = PokerOutsCalculator.CalculateRiverOuts(hand, score); watch.Stop(); Assert.AreEqual(1, outs.StraightFlush.Outs); Assert.Greater(200, watch.ElapsedMilliseconds); }
public void OneInsideSFlushHighAce() { Stopwatch watch = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Hearts), new Card(Rank.Queen, Suit.Hearts), new Card(Rank.Five, Suit.Hearts), new Card(Rank.Jack, Suit.Hearts), new Card(Rank.Five, Suit.Hearts), new Card(Rank.Ten, Suit.Hearts), }; SixCardHand hand = new SixCardHand(cards); hand.Sort(); watch.Start(); var score = PokerEvaluator.CalculateFlopScore(hand.Cards); var outs = PokerOutsCalculator.CalculateRiverOuts(hand, score); watch.Stop(); Assert.AreEqual(1, outs.StraightFlush.Outs); Assert.Greater(200, 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 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 ThreeOfAKindToFour() { Stopwatch watch = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Hearts), new Card(Rank.Six, Suit.Diamonds), new Card(Rank.Five, Suit.Hearts), new Card(Rank.Six, Suit.Clubs), new Card(Rank.Six, Suit.Spades), new Card(Rank.Queen, Suit.Clubs), }; SixCardHand hand = new SixCardHand(cards); hand.Sort(); watch.Start(); var current = PokerEvaluator.CalculateTurnScore(hand.Cards); var outs = PokerOutsCalculator.CalculateRiverOuts(hand, current); watch.Stop(); Assert.AreEqual(1, outs.FourOfAKind.Outs); Assert.AreEqual(false, outs.FourOfAKind.RunnerRunner); Assert.Greater(200, watch.ElapsedMilliseconds); }
public void OneInsideStraightDrawWithHighAceWithTwoPair() { Stopwatch watch = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Queen, Suit.Diamonds), new Card(Rank.King, Suit.Hearts), new Card(Rank.Ten, Suit.Clubs), new Card(Rank.Queen, Suit.Spades), new Card(Rank.King, Suit.Hearts), new Card(Rank.Ace, Suit.Diamonds), }; SixCardHand hand = new SixCardHand(cards); hand.Sort(); watch.Start(); var score = PokerEvaluator.CalculateFlopScore(hand.Cards); var outs = PokerOutsCalculator.CalculateRiverOuts(hand, score); watch.Stop(); Assert.AreEqual(4, outs.Straight.Outs); 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 OneOutsideRFlushWithTwoPair() { 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.King, Suit.Hearts), new Card(Rank.Jack, Suit.Clubs), new Card(Rank.Queen, Suit.Diamonds), }; SixCardHand hand = new SixCardHand(cards); hand.Sort(); watch.Start(); var score = PokerEvaluator.CalculateFlopScore(hand.Cards); var outs = PokerOutsCalculator.CalculateRiverOuts(hand, score); watch.Stop(); Assert.AreEqual(1, outs.RoyalFlush.Outs); Assert.Greater(250, watch.ElapsedMilliseconds); }
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 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); }
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 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 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 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); }
private void HandleRiver() { try { GameState = PokerGameState.River; ClearOutsEvent?.Invoke(); PokerScore = PokerEvaluator.CalculateRiverScore(CurrentRound.AllCards.Values.ToList().GetRange(0, 7)); PokerOutsCalculator.CalculateFinalWinChance(CurrentRound.AllCards.Values.ToList()); UpdateCurrentScoreEvent?.Invoke(PokerScore); UpdateBestPossibleEvent?.Invoke(Pokerscore.None); UpdateBestChanceEvent?.Invoke(_noOuts); UpdateOutsToBestEvent?.Invoke(_noOuts); } catch (Exception e) { Log.Error(e.Message); Log.Error(e.StackTrace); } }
private void HandleTurn() { try { GameState = PokerGameState.Turn; ClearOutsEvent?.Invoke(); PokerScore = PokerEvaluator.CalculateTurnScore(CurrentRound.AllCards.Values.ToList().GetRange(0, 6)); Outs = PokerOutsCalculator.CalculateRiverOuts( new SixCardHand(CurrentRound.AllCards.Values.ToList().GetRange(0, 6)), PokerScore); UpdateOutsEvent?.Invoke(Outs); UpdateCurrentScoreEvent?.Invoke(PokerScore); UpdateBestPossibleEvent?.Invoke(Outs.BestScore()); UpdateBestChanceEvent?.Invoke(Outs.BestPossible()); UpdateOutsToBestEvent?.Invoke(Outs.BestPossible()); } catch (Exception e) { Log.Error(e.Message); Log.Error(e.StackTrace); } }
public void TurnEvaluationTestStraightFlush() { var stop = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Diamonds), new Card(Rank.Two, Suit.Diamonds), new Card(Rank.Three, Suit.Diamonds), new Card(Rank.Four, Suit.Diamonds), new Card(Rank.Five, Suit.Diamonds), new Card(Rank.Ace, Suit.Hearts), }; stop.Start(); var score = PokerEvaluator.CalculateTurnScore(cards); stop.Stop(); Assert.AreEqual(score, Pokerscore.StraightFlush); Assert.Greater(35, stop.ElapsedMilliseconds); }
public void TurnEvaluationTestFlush() { var stop = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Diamonds), new Card(Rank.Jack, Suit.Diamonds), new Card(Rank.Three, Suit.Diamonds), new Card(Rank.Four, Suit.Diamonds), new Card(Rank.Four, Suit.Clubs), new Card(Rank.King, Suit.Diamonds), }; stop.Start(); var score = PokerEvaluator.CalculateTurnScore(cards); stop.Stop(); Assert.AreEqual(Pokerscore.Flush, score); Assert.Greater(40, stop.ElapsedMilliseconds); }
public void TestRiverStraightFlush() { var stop = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Diamonds), new Card(Rank.Two, Suit.Diamonds), new Card(Rank.Three, Suit.Diamonds), new Card(Rank.Four, Suit.Diamonds), new Card(Rank.Five, Suit.Diamonds), new Card(Rank.Queen, Suit.Diamonds), new Card(Rank.Ace, Suit.Hearts), }; stop.Start(); var score = PokerEvaluator.CalculateRiverScore(cards); stop.Stop(); Assert.AreEqual(Pokerscore.StraightFlush, score); Assert.Greater(60, stop.ElapsedMilliseconds); }
public void TestRiverThreeOfAKind() { var stop = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Diamonds), new Card(Rank.Jack, Suit.Hearts), new Card(Rank.Six, Suit.Diamonds), new Card(Rank.Four, Suit.Diamonds), new Card(Rank.King, Suit.Diamonds), new Card(Rank.Ace, Suit.Hearts), new Card(Rank.Ace, Suit.Hearts), }; stop.Start(); var score = PokerEvaluator.CalculateRiverScore(cards); stop.Stop(); Assert.AreEqual(Pokerscore.ThreeOfAKind, score); Assert.Greater(60, stop.ElapsedMilliseconds); }
public void TestRiverFullHouse() { var stop = new Stopwatch(); List <Card> cards = new List <Card> { new Card(Rank.Ace, Suit.Diamonds), new Card(Rank.Ace, Suit.Hearts), new Card(Rank.Ten, Suit.Diamonds), new Card(Rank.Ten, Suit.Spades), new Card(Rank.King, Suit.Diamonds), new Card(Rank.Queen, Suit.Diamonds), new Card(Rank.Ace, Suit.Hearts), }; stop.Start(); var score = PokerEvaluator.CalculateRiverScore(cards); stop.Stop(); Assert.AreEqual(Pokerscore.FullHouse, score); Assert.Greater(60, stop.ElapsedMilliseconds); }