public static bool GotTheStrongestCombination(HandRankType combination) { return(combination == HandRankType.Flush || combination == HandRankType.FullHouse || combination == HandRankType.FourOfAKind || combination == HandRankType.StraightFlush); }
public static bool GotTheStrongestCombination(HandRankType combination) { return combination == HandRankType.Flush || combination == HandRankType.FullHouse || combination == HandRankType.FourOfAKind || combination == HandRankType.StraightFlush; }
public void CompareToShouldWorkCorrectly( ExpectedCompareResult expectedCompareResult, HandRankType firstHandRankType, ICollection <CardType> firstCardTypes, HandRankType secondHandRankType, ICollection <CardType> secondCardTypes) { var firstBestHand = new BestHand(firstHandRankType, firstCardTypes.Shuffle().ToList()); var secondBestHand = new BestHand(secondHandRankType, secondCardTypes.Shuffle().ToList()); var compareToResultFirstSecond = firstBestHand.CompareTo(secondBestHand); var compareToResultSecondFirst = secondBestHand.CompareTo(firstBestHand); switch (expectedCompareResult) { case ExpectedCompareResult.FirstShouldBeBetter: Assert.IsTrue(compareToResultFirstSecond > 0, "compareToResultFirstSecond > 0"); Assert.IsTrue(compareToResultSecondFirst < 0, "compareToResultSecondFirst < 0"); break; case ExpectedCompareResult.SecondShouldBeBetter: Assert.IsTrue(compareToResultFirstSecond < 0, "compareToResultFirstSecond < 0"); Assert.IsTrue(compareToResultSecondFirst > 0, "compareToResultSecondFirst > 0"); break; case ExpectedCompareResult.TheyShouldBeEqual: Assert.AreEqual(0, compareToResultFirstSecond); Assert.AreEqual(0, compareToResultSecondFirst); break; default: Assert.Fail("Invalid ExpectedCompareResult value"); break; } }
public void GetRankTypeShouldWorkCorrectly(ICollection <Card> playerCards, HandRankType expectedHandRankType, ICollection <CardType> expectedBestHandCards) { IHandEvaluator handEvaluator = new HandEvaluator(); var bestHand = handEvaluator.GetBestHand(playerCards.Shuffle().ToList()); Assert.Equal(expectedHandRankType, bestHand.RankType); CollectionsAssert.SameElements(expectedBestHandCards, bestHand.Cards); }
public static bool GotStrongHand(HandRankType combination) { return combination == HandRankType.ThreeOfAKind || combination == HandRankType.Straight || combination == HandRankType.Flush || combination == HandRankType.FullHouse || combination == HandRankType.FourOfAKind || combination == HandRankType.StraightFlush; }
public static bool GotStrongHand(HandRankType combination) { return(combination == HandRankType.ThreeOfAKind || combination == HandRankType.Straight || combination == HandRankType.Flush || combination == HandRankType.FullHouse || combination == HandRankType.FourOfAKind || combination == HandRankType.StraightFlush); }
internal BestHand(HandRankType rankType, ICollection <CardType> cards) { if (cards.Count != 5) { throw new ArgumentException("Cards collection should contains exactly 5 elements", nameof(cards)); } this.Cards = cards; this.RankType = rankType; }
public static bool GotAnyCombination(HandRankType combination) { return combination == HandRankType.Pair || combination == HandRankType.TwoPairs || combination == HandRankType.ThreeOfAKind || combination == HandRankType.Straight || combination == HandRankType.Flush || combination == HandRankType.FullHouse || combination == HandRankType.FourOfAKind || combination == HandRankType.StraightFlush; }
private static bool GotStrongHand(HandRankType combination) { return(combination == HandRankType.Flush || combination == HandRankType.FourOfAKind || combination == HandRankType.FullHouse || combination == HandRankType.Straight || combination == HandRankType.StraightFlush || combination == HandRankType.ThreeOfAKind || combination == HandRankType.TwoPairs || combination == HandRankType.Pair); }
public static bool GotAnyCombination(HandRankType combination) { return(combination == HandRankType.Pair || combination == HandRankType.TwoPairs || combination == HandRankType.ThreeOfAKind || combination == HandRankType.Straight || combination == HandRankType.Flush || combination == HandRankType.FullHouse || combination == HandRankType.FourOfAKind || combination == HandRankType.StraightFlush); }
// renamed while explosions on testing server to aviod exploition private void DoIt(ICollection <Card> currentHand, HandRankType target) { foreach (var card in Deck.AllCards) { if (currentHand.Contains(card) || this.outs.Contains(card)) { continue; } currentHand.Add(card); if (this.handEvaluator.GetBestHand(currentHand).RankType >= target) { this.outs.Add(card); } currentHand.Remove(card); } }
// renamed while explosions on testing server to aviod exploition private int CountOuts(ICollection <Card> currentHand, HandRankType target) { var outCount = 0; foreach (var card in Deck.AllCards) { if (currentHand.Contains(card)) { continue; } currentHand.Add(card); if (this.handEvaluator.GetBestHand(currentHand).RankType >= target) { outCount++; } currentHand.Remove(card); } return(outCount); }
// renamed while explosions on testing server to aviod exploition private int CountOuts(ICollection<Card> currentHand, HandRankType target) { var outCount = 0; foreach (var card in Deck.AllCards) { if (currentHand.Contains(card)) { continue; } currentHand.Add(card); if (this.handEvaluator.GetBestHand(currentHand).RankType >= target) { outCount++; } currentHand.Remove(card); } return outCount; }
public static PlayerAction PassivePlayerAction(GetTurnContext context, HandRankType combination, int raiseAmount, int pushAmount) { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 || context.MoneyToCall > context.SmallBlind * 14) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft >= context.SmallBlind * pushAmount) { return PlayerAction.Raise(context.SmallBlind * pushAmount); } else { return PlayerAction.Raise(context.MoneyLeft); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft >= context.SmallBlind * raiseAmount) { return PlayerAction.Raise(context.SmallBlind * raiseAmount); } else { return PlayerAction.Raise(context.MoneyLeft); } } else { if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.SmallBlind * 6); } else { return PlayerAction.CheckOrCall(); } } } else { if (context.CanCheck && context.MoneyLeft > 0) { return PlayerAction.Raise((context.SmallBlind * raiseAmount) - context.SmallBlind); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return PlayerAction.CheckOrCall(); } return CheckOrFoldCustomAction(context); } }
public static PlayerAction AgressivePlayerAction(GetTurnContext context, CardValueType preFlopCards, HandRankType combination, int potMultiplier, int raiseSbMultipliyer) { if (preFlopCards == CardValueType.Recommended) { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if ((context.MoneyToCall > context.CurrentPot / 2 || context.MoneyToCall > context.SmallBlind * 14) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft >= context.SmallBlind * raiseSbMultipliyer) { return PlayerAction.Raise(context.CurrentPot * potMultiplier); } else { return PlayerAction.Raise(context.MoneyLeft); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft >= context.SmallBlind * raiseSbMultipliyer) { return PlayerAction.Raise(context.CurrentPot * potMultiplier); } else { return PlayerAction.Raise(context.MoneyLeft); } } else { if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.SmallBlind * 6); } else { return PlayerAction.CheckOrCall(); } } } else { if (context.CanCheck && context.MoneyLeft > 0 && context.MyMoneyInTheRound == 0) { return PlayerAction.Raise((context.SmallBlind * raiseSbMultipliyer) - context.SmallBlind); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return PlayerAction.CheckOrCall(); } else { return CheckOrFoldCustomAction(context); } } } else if (preFlopCards == CardValueType.NotRecommended || preFlopCards == CardValueType.Risky) { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.SmallBlind * 10) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.CurrentPot * potMultiplier); } else { return CheckOrFoldCustomAction(context); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.CurrentPot * potMultiplier); } else { return CheckOrFoldCustomAction(context); } } else { if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.SmallBlind * 6); } else { return CheckOrFoldCustomAction(context); } } } else { if (context.CanCheck && context.MoneyLeft > 0 && context.MyMoneyInTheRound == 0) { return PlayerAction.CheckOrCall(); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return PlayerAction.CheckOrCall(); } else { return CheckOrFoldCustomAction(context); } } } else { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 || context.MoneyToCall > context.SmallBlind * 14) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.CurrentPot * potMultiplier); } else { return PlayerAction.Raise(context.MoneyLeft); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return PlayerAction.Raise(context.MoneyLeft); } else if (context.MoneyLeft >= context.SmallBlind * raiseSbMultipliyer) { return PlayerAction.Raise(context.CurrentPot * potMultiplier); } else { return PlayerAction.Raise(context.MoneyLeft); } } else { if (context.MoneyLeft > 0) { return PlayerAction.Raise(context.SmallBlind * 6); } else { return CheckOrFoldCustomAction(context); } } } else { if (context.CanCheck && context.MoneyLeft > 0 && context.MyMoneyInTheRound == 0) { return PlayerAction.CheckOrCall(); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return PlayerAction.CheckOrCall(); } else { return CheckOrFoldCustomAction(context); } } } }
public void GetRankTypeShouldWorkCorrectly(ICollection<Card> playerCards, HandRankType expectedHandRankType, ICollection<CardType> expectedBestHandCards) { IHandEvaluator handEvaluator = new HandEvaluator(); var bestHand = handEvaluator.GetBestHand(playerCards.Shuffle().ToList()); Assert.AreEqual(expectedHandRankType, bestHand.RankType); CollectionAssert.AreEquivalent(expectedBestHandCards, bestHand.Cards); }
private static bool GotStrongHand(HandRankType combination) { return combination == HandRankType.Flush || combination == HandRankType.FourOfAKind || combination == HandRankType.FullHouse || combination == HandRankType.Straight || combination == HandRankType.StraightFlush || combination == HandRankType.ThreeOfAKind || combination == HandRankType.TwoPairs || combination == HandRankType.Flush || combination == HandRankType.Pair; }
// renamed while explosions on testing server to aviod exploition private void DoIt(ICollection<Card> currentHand, HandRankType target) { foreach (var card in Deck.AllCards) { if (currentHand.Contains(card) || this.outs.Contains(card)) { continue; } currentHand.Add(card); if (this.handEvaluator.GetBestHand(currentHand).RankType >= target) { this.outs.Add(card); } currentHand.Remove(card); } }
public static PlayerAction PassivePlayerAction(GetTurnContext context, HandRankType combination, int raiseAmount, int pushAmount) { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 || context.MoneyToCall > context.SmallBlind * 14) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft >= context.SmallBlind * pushAmount) { return(PlayerAction.Raise(context.SmallBlind * pushAmount)); } else { return(PlayerAction.Raise(context.MoneyLeft)); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft >= context.SmallBlind * raiseAmount) { return(PlayerAction.Raise(context.SmallBlind * raiseAmount)); } else { return(PlayerAction.Raise(context.MoneyLeft)); } } else { if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.SmallBlind * 6)); } else { return(PlayerAction.CheckOrCall()); } } } else { if (context.CanCheck && context.MoneyLeft > 0) { return(PlayerAction.Raise((context.SmallBlind * raiseAmount) - context.SmallBlind)); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return(PlayerAction.CheckOrCall()); } return(CheckOrFoldCustomAction(context)); } }
public static PlayerAction AgressivePlayerAction(GetTurnContext context, CardValueType preFlopCards, HandRankType combination, int potMultiplier, int raiseSbMultipliyer) { if (preFlopCards == CardValueType.Recommended) { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if ((context.MoneyToCall > context.CurrentPot / 2 || context.MoneyToCall > context.SmallBlind * 14) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft >= context.SmallBlind * raiseSbMultipliyer) { return(PlayerAction.Raise(context.CurrentPot * potMultiplier)); } else { return(PlayerAction.Raise(context.MoneyLeft)); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft >= context.SmallBlind * raiseSbMultipliyer) { return(PlayerAction.Raise(context.CurrentPot * potMultiplier)); } else { return(PlayerAction.Raise(context.MoneyLeft)); } } else { if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.SmallBlind * 6)); } else { return(PlayerAction.CheckOrCall()); } } } else { if (context.CanCheck && context.MoneyLeft > 0 && context.MyMoneyInTheRound == 0) { return(PlayerAction.Raise((context.SmallBlind * raiseSbMultipliyer) - context.SmallBlind)); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return(PlayerAction.CheckOrCall()); } else { return(CheckOrFoldCustomAction(context)); } } } else if (preFlopCards == CardValueType.NotRecommended || preFlopCards == CardValueType.Risky) { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.SmallBlind * 10) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.CurrentPot * potMultiplier)); } else { return(CheckOrFoldCustomAction(context)); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.CurrentPot * potMultiplier)); } else { return(CheckOrFoldCustomAction(context)); } } else { if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.SmallBlind * 6)); } else { return(CheckOrFoldCustomAction(context)); } } } else { if (context.CanCheck && context.MoneyLeft > 0 && context.MyMoneyInTheRound == 0) { return(PlayerAction.CheckOrCall()); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return(PlayerAction.CheckOrCall()); } else { return(CheckOrFoldCustomAction(context)); } } } else { if (CustomHandStreightChecks.GotStrongHand(combination)) { if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotTheStrongestHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 || context.MoneyToCall > context.SmallBlind * 14) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.CurrentPot * potMultiplier)); } else { return(PlayerAction.Raise(context.MoneyLeft)); } } else if (context.MoneyLeft > 0 && CustomHandStreightChecks.GotVeryStrongHand(combination)) { if (!context.CanCheck && (context.MoneyToCall > context.CurrentPot / 2 * 3 || context.MoneyToCall > context.SmallBlind * 20) && context.MoneyLeft > 0) { return(PlayerAction.Raise(context.MoneyLeft)); } else if (context.MoneyLeft >= context.SmallBlind * raiseSbMultipliyer) { return(PlayerAction.Raise(context.CurrentPot * potMultiplier)); } else { return(PlayerAction.Raise(context.MoneyLeft)); } } else { if (context.MoneyLeft > 0) { return(PlayerAction.Raise(context.SmallBlind * 6)); } else { return(CheckOrFoldCustomAction(context)); } } } else { if (context.CanCheck && context.MoneyLeft > 0 && context.MyMoneyInTheRound == 0) { return(PlayerAction.CheckOrCall()); } else if (context.MoneyToCall <= context.SmallBlind * 2) { return(PlayerAction.CheckOrCall()); } else { return(CheckOrFoldCustomAction(context)); } } } }
public void CompareToShouldWorkCorrectly( ExpectedCompareResult expectedCompareResult, HandRankType firstHandRankType, ICollection<CardType> firstCardTypes, HandRankType secondHandRankType, ICollection<CardType> secondCardTypes) { var firstBestHand = new BestHand(firstHandRankType, firstCardTypes.Shuffle().ToList()); var secondBestHand = new BestHand(secondHandRankType, secondCardTypes.Shuffle().ToList()); var compareToResultFirstSecond = firstBestHand.CompareTo(secondBestHand); var compareToResultSecondFirst = secondBestHand.CompareTo(firstBestHand); switch (expectedCompareResult) { case ExpectedCompareResult.FirstShouldBeBetter: Assert.IsTrue(compareToResultFirstSecond > 0, "compareToResultFirstSecond > 0"); Assert.IsTrue(compareToResultSecondFirst < 0, "compareToResultSecondFirst < 0"); break; case ExpectedCompareResult.SecondShouldBeBetter: Assert.IsTrue(compareToResultFirstSecond < 0, "compareToResultFirstSecond < 0"); Assert.IsTrue(compareToResultSecondFirst > 0, "compareToResultSecondFirst > 0"); break; case ExpectedCompareResult.TheyShouldBeEqual: Assert.AreEqual(0, compareToResultFirstSecond); Assert.AreEqual(0, compareToResultSecondFirst); break; default: Assert.Fail("Invalid ExpectedCompareResult value"); break; } }
public override PlayerAction GetTurn(GetTurnContext context) { #region PreFlopLogic if (context.RoundType == GameRoundType.PreFlop) { //checks if we have the button if (context.MyMoneyInTheRound == context.SmallBlind) { hasTheButton = true; } //checks if 3bettedPot; If the pot is big it is! if (context.CurrentPot > (context.SmallBlind * 4)) { is3bettedPot = true; } var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard, hasTheButton); //http://www.holdemresources.net/h/poker-theory/hune/usage.html #region mFactor< 20 if (mFactor < 20) { double nashEquillibriumRatio = 0; if (hasTheButton) { nashEquillibriumRatio = HandStrengthValuation.GetPusherBlindsCount(this.FirstCard, this.SecondCard); } else { nashEquillibriumRatio = HandStrengthValuation.GetCallerBlindsCount(this.FirstCard, this.SecondCard); } //find if we have less money then the effective stack size bool push = context.MoneyLeft <= (nashEquillibriumRatio * (context.SmallBlind * 2)); if (push) { return(PlayerAction.Raise(context.CurrentMaxBet)); } else { if (context.CanCheck) { return(PlayerAction.CheckOrCall()); } else { return(PlayerAction.Fold()); } } } #endregion #region UnplayableHands if (playHand == CardValuationType.Unplayable) { if (context.CanCheck) { return(PlayerAction.CheckOrCall()); } else { return(PlayerAction.Fold()); } } #endregion // raises risky hands only if in position and if it is not a 3betted Pot if (playHand == CardValuationType.Risky && context.MyMoneyInTheRound == context.SmallBlind) { // var smallBlindsTimes = RandomProvider.Next(1, 8); return(PlayerAction.Raise(context.SmallBlind * 6)); } // folds if not in position else if (playHand == CardValuationType.Risky && !hasTheButton) { if (context.CanCheck) { return(PlayerAction.CheckOrCall()); } else { return(PlayerAction.Fold()); } } // if recommended and not in 3bettedPot and a big M RAISES if (playHand == CardValuationType.Recommended) { if (is3bettedPot && mFactor > 100) { return(PlayerAction.CheckOrCall()); } if (is3bettedPot && mFactor > 200) { return(PlayerAction.Fold()); } // var smallBlindsTimes = RandomProvider.Next(6, 10); return(PlayerAction.Raise(context.SmallBlind * 6)); } //needs refactoring if (playHand == CardValuationType.Premium || playHand == CardValuationType.TopPremium) { if (playHand == CardValuationType.TopPremium) { hasTopPremium = true; return(PlayerAction.Raise(context.SmallBlind * 10)); } if (playHand == CardValuationType.Premium) { return(PlayerAction.Raise(context.SmallBlind * 10)); } } // not sure if this doesn't brake everything if (context.CanCheck) { return(PlayerAction.CheckOrCall()); } // not sure if this doesn't brake everything else { return(PlayerAction.Fold()); } } #endregion #region Post-FlopLogic double currentPotRaise = context.CurrentPot * 0.55; int currentPotRaiseInt = (int)currentPotRaise; List <Card> allCards = new List <Card>(this.CommunityCards); allCards.Add(this.FirstCard); allCards.Add(this.SecondCard); HandRankType type = HandEvaluator.GetBestHand(allCards).RankType; var playerFirstHand = ParseHandToString.GenerateStringFromCard(this.FirstCard); var playerSecondHand = ParseHandToString.GenerateStringFromCard(this.SecondCard); string playerHand = playerFirstHand + " " + playerSecondHand; string openCards = string.Empty; foreach (var item in this.CommunityCards) { openCards += ParseHandToString.GenerateStringFromCard(item) + " "; } var chance = MonteCarloAnalysis.CalculateWinChance(playerHand, openCards.Trim()); int Check = 15; int Raise = 60; int AllIn = 85; if (context.MoneyToCall <= (context.SmallBlind * 2)) { return(PlayerAction.CheckOrCall()); } if (chance < Check) { return(PlayerAction.Fold()); } if (chance < Raise) { return(PlayerAction.CheckOrCall()); } else if (chance < AllIn) { if ((int)type >= (int)HandRankType.Pair) { return(PlayerAction.Raise(currentPotRaiseInt)); } else { return(PlayerAction.Raise(context.SmallBlind * 4)); } } else { return(PlayerAction.Raise(context.CurrentMaxBet)); } }
public HandsHolder(CardValuationType playHand, HandRankType bestHand, HandRankType bestHandOnTable) { this.PlayHand = playHand; this.BestHand = bestHand; this.BestHandOnTable = bestHandOnTable; }
public void GetRankTypeShouldWorkCorrectly(HandRankType expectedHandRankType, ICollection<Card> cards) { var handEvaluator = new HandEvaluator(); var actualHandRankType = handEvaluator.GetRankType(cards.Shuffle().ToList()); Assert.AreEqual(expectedHandRankType, actualHandRankType); }