Exemplo n.º 1
0
        private PlayerAction PreflopLogic(GetTurnContext context)
        {
            this.ownCardsStrength = PreflopHandStrengthValuation.GetRecommendation(this.FirstCard, this.SecondCard);

            if (context.SmallBlind == 1)
            {
                if (!this.isAlwaysAllIn && context.CurrentPot + context.MoneyLeft == 2000)
                {
                    this.allInCount++;
                    if (this.allInCount > MagicNumber)
                    {
                        this.isAlwaysAllIn = true;
                    }

                    if (this.ownCardsStrength < CardValuationType.Strong)
                    {
                        return(PlayerAction.Fold());
                    }
                }
            }

            // handling AlwaysAllIn Player
            if (this.isAlwaysAllIn && context.CurrentPot + context.MoneyLeft == 2000)
            {
                if (context.SmallBlind <= 3)
                {
                    if (this.ownCardsStrength > CardValuationType.Recommended)
                    {
                        return(PlayerAction.CheckOrCall());
                    }

                    return(PlayerAction.Fold());
                }

                if (this.ownCardsStrength >= CardValuationType.Recommended ||
                    this.FirstCard.Type >= CardType.King ||
                    this.SecondCard.Type >= CardType.King)
                {
                    return(PlayerAction.CheckOrCall());
                }

                return(PlayerAction.Fold());
            }

            if (context.MoneyLeft <= context.SmallBlind * 10 /*&& ownCardsStrength > CardValuationType.Unplayable*/)
            {
                return(PlayerAction.Raise(context.MoneyLeft));
            }

            if (context.PreviousRoundActions.Count == 2)
            {
                if (this.ownCardsStrength == CardValuationType.Unplayable)
                {
                    return(PlayerAction.Fold());
                }

                if (this.ownCardsStrength == CardValuationType.Monster)
                {
                    if (isCallingStation)
                    {
                        return(PlayerAction.Raise((context.CurrentPot * 7) - MagicNumber));
                    }

                    if (isVeryAggressive)
                    {
                        return(PlayerAction.Raise((context.CurrentPot * 2) + MagicNumber));
                    }

                    return(PlayerAction.Raise((context.CurrentPot * 10) - MagicNumber));
                }

                if (this.ownCardsStrength >= CardValuationType.Recommended)
                {
                    if (isCallingStation)
                    {
                        return(PlayerAction.Raise((10 * context.SmallBlind) - MagicNumber));
                    }

                    return(PlayerAction.Raise((6 * context.SmallBlind) - MagicNumber));
                }

                if (this.ownCardsStrength == CardValuationType.Risky)
                {
                    if (isCallingStation || this.isAlwaysRaise)
                    {
                        return(PlayerAction.CheckOrCall());
                    }

                    return(PlayerAction.Raise((5 * context.SmallBlind) - MagicNumber));
                }

                if (this.ownCardsStrength == CardValuationType.NotRecommended)
                {
                    if (isCallingStation)
                    {
                        return(PlayerAction.CheckOrCall());
                    }

                    return(PlayerAction.Raise((4 * context.SmallBlind) + MagicNumber));
                }
            }

            // Facing a raise
            if (isSmallBlind && context.PreviousRoundActions.Count > 2)
            {
                if (this.ownCardsStrength == CardValuationType.NotRecommended)
                {
                    return(PlayerAction.Fold());
                }

                if (this.ownCardsStrength == CardValuationType.Monster)
                {
                    return(PlayerAction.Raise(Math.Min(((2 * context.MoneyToCall) + MagicNumber) + context.CurrentPot, AllIn(context.MoneyLeft))));
                }

                if (context.MoneyLeft <= context.SmallBlind * 20)
                {
                    if (this.FirstCard.Type == CardType.Ace || this.SecondCard.Type == CardType.Ace ||
                        this.ownCardsStrength >= CardValuationType.Recommended)
                    {
                        return(PlayerAction.Raise(AllIn(context.MoneyLeft)));
                    }

                    return(PlayerAction.Fold());
                }

                if (this.ownCardsStrength >= CardValuationType.Recommended)
                {
                    if (context.MoneyToCall <= context.MoneyLeft / 8)
                    {
                        return(PlayerAction.CheckOrCall());
                    }

                    if (this.ownCardsStrength == CardValuationType.Strong && context.MoneyToCall <= context.MoneyLeft / 5)
                    {
                        return(PlayerAction.CheckOrCall());
                    }

                    return(PlayerAction.Fold());
                }

                if (isSmallBlind && context.MoneyToCall <= context.MoneyLeft * 0.2)
                {
                    return(PlayerAction.CheckOrCall());
                }

                return(PlayerAction.Fold());
            }

            // Big blind
            if (!isSmallBlind && context.PreviousRoundActions.Count >= 3)
            {
                if (this.lastAction == PlayerActionType.Raise)
                {
                    if (this.ownCardsStrength <= CardValuationType.NotRecommended)
                    {
                        if (this.isAlwaysRaise)
                        {
                            return(PlayerAction.CheckOrCall());
                        }

                        return(PlayerAction.Fold());
                    }
                }

                if (this.ownCardsStrength == CardValuationType.Risky)
                {
                    if (context.MoneyToCall > context.MoneyLeft * 0.2)
                    {
                        return(PlayerAction.Fold());
                    }

                    return(PlayerAction.CheckOrCall());
                }

                if (this.lastAction == PlayerActionType.CheckCall)
                {
                    if (this.ownCardsStrength == CardValuationType.Monster)
                    {
                        return(PlayerAction.Raise((context.CurrentPot * 5) - MagicNumber));
                    }

                    if (this.ownCardsStrength >= CardValuationType.Recommended)
                    {
                        return(PlayerAction.Raise((8 * context.SmallBlind) - MagicNumber));
                    }

                    if (this.ownCardsStrength == CardValuationType.Risky)
                    {
                        return(PlayerAction.Raise((2 * context.SmallBlind) + MagicNumber));
                    }

                    if (this.ownCardsStrength == CardValuationType.NotRecommended)
                    {
                        return(PlayerAction.CheckOrCall());
                    }
                }

                if (this.lastAction == PlayerActionType.Raise &&
                    this.ownCardsStrength > CardValuationType.NotRecommended)
                {
                    if (this.ownCardsStrength > CardValuationType.Recommended)
                    {
                        return(PlayerAction.Raise(Math.Min(context.CurrentPot + (2 * context.MoneyToCall), context.MoneyLeft)));
                    }

                    if (this.ownCardsStrength == CardValuationType.Recommended)
                    {
                        if (context.MoneyToCall < context.MoneyLeft && context.MoneyToCall < context.SmallBlind * 8)
                        {
                            return(PlayerAction.CheckOrCall());
                        }

                        return(PlayerAction.Fold());
                    }

                    if (this.ownCardsStrength == CardValuationType.Risky)
                    {
                        if (context.MoneyToCall > context.MoneyLeft * 0.1 && context.MoneyToCall > context.SmallBlind * 5)
                        {
                            return(PlayerAction.Fold());
                        }

                        return(PlayerAction.CheckOrCall());
                    }
                }
            }

            return(PlayerAction.CheckOrCall());
        }
Exemplo n.º 2
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            // antiCrash prefix - do not delete
            if (context.MoneyLeft <= 0)
            {
                return(PlayerAction.CheckOrCall());
            }

            if (context.RoundType == GameRoundType.PreFlop &&
                context.MoneyLeft < 500 &&
                context.SmallBlind >= 10)
            {
                if (PreflopHandStrengthValuation.GetRecommendation(this.FirstCard, this.SecondCard) >= CardValuationType.Recommended ||
                    this.FirstCard.Type == CardType.Ace ||
                    this.SecondCard.Type == CardType.Ace)
                {
                    return(PlayerAction.Raise(AllIn(context.MoneyLeft)));
                }
            }

            if (!smallBlindFlag && context.RoundType == GameRoundType.PreFlop)
            {
                smallBlindFlag = true;
                isSmallBlind   = context.MyMoneyInTheRound == context.SmallBlind;
            }

            this.lastAction = context.PreviousRoundActions.Any() ?
                              context.PreviousRoundActions.Last().Action.Type :
                              PlayerActionType.Fold;

            // collecting info for opponent
            if (context.PreviousRoundActions.Any() && context.SmallBlind <= 2 && context.RoundType != GameRoundType.PreFlop)
            {
                this.opponentActions.Add(context.PreviousRoundActions.Last().Action.Type);
            }

            if (this.opponentActions.Any() && !flag && context.SmallBlind == 5)
            {
                flag             = true;
                isCallingStation = this.FindCallingStation(this.opponentActions);

                isVeryAggressive = this.FindAggressiveStation(this.opponentActions);
            }

            // get current Rank
            if (context.RoundType != GameRoundType.PreFlop)
            {
                this.currentBestHand = this.GetCurrentBestHand();
            }

            // catching AlwaysRaisePlayer
            if (context.SmallBlind == 1 &&
                !this.isAlwaysRaise &&
                context.RoundType == GameRoundType.PreFlop &&
                (context.PreviousRoundActions.Count == 3 ||
                 context.PreviousRoundActions.Count == 4))
            {
                if (!this.isAlwaysRaise && context.MoneyToCall == 1)
                {
                    this.raiseCount++;
                    if (this.raiseCount > MagicNumber)
                    {
                        this.isAlwaysRaise = true;
                    }
                }
            }

            // fishing prefix - handles fish and always raise player
            if (this.isAlwaysRaise ||
                (context.MoneyToCall < MagicFishingNumber &&
                 context.RoundType != GameRoundType.PreFlop))
            {
                if (context.RoundType != GameRoundType.River)
                {
                    if (context.RoundType == GameRoundType.Turn)
                    {
                        if (this.FirstCard.Type == this.SecondCard.Type)
                        {
                            outs = this.CountOuts(this.hand, HandRankType.ThreeOfAKind);
                        }
                        else if (this.CurrentHandRank < HandRankType.Straight &&
                                 this.FirstCard.Type != this.SecondCard.Type)
                        {
                            outs = this.CountOuts(this.hand, HandRankType.Straight);
                        }
                    }

                    return(PlayerAction.CheckOrCall());
                }

                if (context.RoundType == GameRoundType.River && this.CurrentHandRank >= HandRankType.Straight && this.CommunityImproved())
                {
                    return(PlayerAction.Raise(AllIn(context.MoneyLeft)));
                }

                if (this.ownCardsStrength >= CardValuationType.Strong &&
                    outs < 5 &&
                    this.handEvaluator.GetBestHand(this.CommunityCards).RankType < HandRankType.Pair &&
                    this.CurrentHandRank >= HandRankType.TwoPairs)
                {
                    return(PlayerAction.Raise((context.CurrentPot * 3) + MagicNumber));
                }
            }

            // TODO: Some better way to access stages
            if (context.RoundType == GameRoundType.PreFlop)
            {
                return(this.PreflopLogic(context));
            }

            if (context.RoundType == GameRoundType.Flop)
            {
                return(this.FlopLogic(context));
            }

            if (context.RoundType == GameRoundType.Turn)
            {
                return(this.TurnLogic(context));
            }

            if (context.RoundType == GameRoundType.River)
            {
                return(this.RiverLogic(context));
            }

            return(PlayerAction.CheckOrCall());
        }