コード例 #1
0
ファイル: TodorPlayer.cs プロジェクト: ekov1/TelerikAcademy
        private PlayerAction SafeAllInState(GetTurnContext context)
        {
            // if they raised more than a certain proportion of my money and I don`t have strong hand fold
            if (context.PreviousRoundActions.Count > 0 && context.PreviousRoundActions.Last().Action.Type == PlayerActionType.Raise)
            {
                if (context.MoneyToCall >= context.MoneyLeft / 2 && this.HandStrength < .8)
                {
                    return(PlayerAction.Fold());
                }
            }

            if (this.HandStrength < .42 && !context.CanCheck)
            {
                return(PlayerAction.Fold());
            }

            var raise = context.MoneyLeft;

            if (this.HandStrength > .95 && raise > 0)
            {
                return(PlayerAction.Raise(raise / 2));
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #2
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            int opponentMoney = (this.startGameMoney * 2) - context.MyMoneyInTheRound - context.MoneyLeft;

            var getActionContext = new GetActionContext(
                context.PreviousRoundActions,
                this.currentGameStackStage,
                this.roundsActions,
                context.RoundType,
                this.FirstCard,
                this.SecondCard,
                this.CommunityCards,
                context.SmallBlind,
                context.MoneyLeft,
                opponentMoney,
                context.CurrentPot,
                context.CanCheck,
                this.Name);

            PlayerAction action = null;

            if (action == null)
            {
                action = BaseStrategy.GetPlayerAction(getActionContext);
            }

            if (action.Type == PlayerActionType.Raise && action.Money == context.MoneyLeft)
            {
                this.lastMyPushMoney = context.MoneyLeft - context.MyMoneyInTheRound;
            }

            return(action);
        }
コード例 #3
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            var chanceForAction = RandomProvider.Next(1, 101);

            if (chanceForAction == 1 && context.MoneyLeft > 0)
            {
                // All-in
                return(PlayerAction.Raise(context.MoneyLeft));
            }

            if (chanceForAction <= 15)
            {
                // Minimum raise
                return(PlayerAction.Raise(1));
            }

            // Play safe
            if (context.CanCheck)
            {
                return(PlayerAction.CheckOrCall());
            }

            if (chanceForAction <= 60)
            {
                // Call
                return(PlayerAction.CheckOrCall());
            }
            else
            {
                // Fold
                return(PlayerAction.Fold());
            }
        }
コード例 #4
0
ファイル: Jesus.cs プロジェクト: tddold/Team-TheChurch
        private PlayerAction GetActionByCardValuationType(CardValuationType playHand, GetTurnContext context)
        {
            if (playHand == CardValuationType.Unplayable)
            {
                return this.GetUnplayableAction(context);
            }

            if (playHand == CardValuationType.Risky)
            {
                return this.ChooseAction(context.MoneyLeft, 0.1f);
            }

            if (playHand == CardValuationType.Recommended)
            {
                return this.ChooseAction(context.MoneyLeft, 0.25f);
            }

            if (playHand == CardValuationType.VeryPowerful)
            {
                return this.ChooseAction(context.MoneyLeft, 0.5f);
            }

            if (playHand == CardValuationType.AllIn)
            {
                return this.ChooseAction(context.MoneyLeft, 1f);
            }

            return PlayerAction.CheckOrCall();
        }
コード例 #5
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            this.UpdateCommonRow(context.CurrentPot);
            ConsoleHelper.WriteOnConsole(this.row + 1, 2, context.MoneyLeft + "   ");

            // HEREEEEEEEEEEeeee
            //System.Threading.Thread.Sleep(1000);
            var action = base.GetTurn(context);

            ConsoleHelper.WriteOnConsole(this.row + 2, 2, new string(' ', this.width - 3));

            var lastAction = action.Type + (action.Type == PlayerActionType.Fold
                ? string.Empty
                : "(" + (action.Money + ((context.MoneyToCall < 0) ? 0 : context.MoneyToCall) + ")"));

            ConsoleHelper.WriteOnConsole(this.row + 3, 2, "Last action: " + lastAction + "            ");

            var moneyAfterAction = action.Type == PlayerActionType.Fold
                ? context.MoneyLeft
                : context.MoneyLeft - action.Money - context.MoneyToCall;

            ConsoleHelper.WriteOnConsole(this.row + 1, 2, moneyAfterAction + "   ");

            return(action);
        }
コード例 #6
0
ファイル: SmartPlayer.cs プロジェクト: ekov1/TelerikAcademy
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            if (context.RoundType == GameRoundType.PreFlop)
            {
                var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard);
                if (playHand == CardValuationType.Unplayable)
                {
                    if (context.CanCheck)
                    {
                        return(PlayerAction.CheckOrCall());
                    }
                    else
                    {
                        return(PlayerAction.Fold());
                    }
                }

                if (playHand == CardValuationType.Risky)
                {
                    var smallBlindsTimes = RandomProvider.Next(1, 8);
                    return(PlayerAction.Raise(context.SmallBlind * smallBlindsTimes));
                }

                if (playHand == CardValuationType.Recommended)
                {
                    var smallBlindsTimes = RandomProvider.Next(6, 14);
                    return(PlayerAction.Raise(context.SmallBlind * smallBlindsTimes));
                }

                return(PlayerAction.CheckOrCall());
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #7
0
        public override PlayerAction ProcessRequest(GetTurnContext context, double handValue, int raiseAmount)
        {
            if (handValue < 0.60)
            {
                if (context.MoneyToCall - context.MyMoneyInTheRound > raiseAmount * 2 && SmokinAcesPlayer.actions
                    .Any(x => !x.PlayerName.ToLower().Contains("dadummest")))
                {
                    return PlayerAction.Fold();
                }

                var raiseCount = SmokinAcesPlayer.actions.Count;
                if (raiseCount == 0 && context.RoundType > GameRoundType.Turn)
                {
                    return PlayerAction.Raise(raiseAmount);
                }

                return PlayerAction.CheckOrCall();
            }

            else if (this.Successor != null)
            {
                return this.Successor.ProcessRequest(context, handValue, raiseAmount);
            }

            return null;
        }
コード例 #8
0
        public static CardValueType PreFlopAggressive(GetTurnContext context, Card firstCard, Card secondCard)
        {
            var value = firstCard.Suit == secondCard.Suit
                          ? (firstCard.Type > secondCard.Type
                                 ? StartingHandRecommendationsAggressive[MaxCardTypeValue - (int)firstCard.Type, MaxCardTypeValue - (int)secondCard.Type]
                                 : StartingHandRecommendationsAggressive[MaxCardTypeValue - (int)secondCard.Type, MaxCardTypeValue - (int)firstCard.Type])
                          : (firstCard.Type > secondCard.Type
                                 ? StartingHandRecommendationsAggressive[MaxCardTypeValue - (int)secondCard.Type, MaxCardTypeValue - (int)firstCard.Type]
                                 : StartingHandRecommendationsAggressive[MaxCardTypeValue - (int)firstCard.Type, MaxCardTypeValue - (int)secondCard.Type]);

            switch (value)
            {
            case 0:
                return(CardValueType.Unplayable);

            case 1:
                return(CardValueType.Risky);

            case 2:
                return(CardValueType.Recommended);

            case 3:
                return(CardValueType.Recommended);

            default:
                return(CardValueType.Unplayable);
            }
        }
コード例 #9
0
 public override PlayerAction GetTurn(GetTurnContext context)
 {
     if (context.MoneyLeft <= 250)
     {
         // CLOSE to LOOSING The Game - PLay aggresivly to return back the stack
         var preFlopCards = CustomHandEvaluator.PreFlopAggressive(context, this.FirstCard, this.SecondCard);
         var firstCard = this.FirstCard;
         var secondCard = this.SecondCard;
         var communityCards = this.CommunityCards;
         return CustomStackActions.NormalStackMethod(context, preFlopCards, firstCard, secondCard, communityCards);
     }
     else if (context.MoneyLeft > 250 && context.MoneyLeft < 1750)
     {
         var preFlopCards = CustomHandEvaluator.PreFlop(context, this.FirstCard, this.SecondCard);
         var firstCard = this.FirstCard;
         var secondCard = this.SecondCard;
         var communityCards = this.CommunityCards;
         return CustomStackActions.NormalStackMethod(context, preFlopCards, firstCard, secondCard, communityCards);
     }
     else
     {
         // context.MoneyLeft > 1600 we are CHIPLEADERS - FIGHT With AGRESSION!
         var preFlopCards = CustomHandEvaluator.PreFlopAggressive(context, this.FirstCard, this.SecondCard);
         var firstCard = this.FirstCard;
         var secondCard = this.SecondCard;
         var communityCards = this.CommunityCards;
         return CustomStackActions.NormalStackMethod(context, preFlopCards, firstCard, secondCard, communityCards);
     }
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PassiveAggressiveFlopProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 /// <param name="communityCards">The community board cards (flop, turn, river)</param>
 internal PassiveAggressiveFlopProvider(GetTurnContext context, Card first, Card second, IReadOnlyCollection<Card> communityCards, bool isFirst)
     : base(context, first, second, isFirst)
 {
     this.handEvaluator = new PreFlopHandEvaluator();
     this.communityCards = communityCards;
     this.allCards = new List<Card> { first, second };
     this.allCards.AddRange(communityCards.ToList());
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActionProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 public ActionProvider(GetTurnContext context, Card first, Card second, bool isFirst)
 {
     this.Context    = context;
     this.firstCard  = first;
     this.secondCard = second;
     this.isFirst    = isFirst;
     this.raise      = this.Context.SmallBlind * 8;
     this.push       = (this.Context.CurrentPot / 4) * 3;
 }
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActionProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 public ActionProvider(GetTurnContext context, Card first, Card second, bool isFirst)
 {
     this.Context = context;
     this.firstCard = first;
     this.secondCard = second;
     this.isFirst = isFirst;
     this.raise = this.Context.SmallBlind * 8;
     this.push = (this.Context.CurrentPot / 4) * 3;
 }
コード例 #13
0
        private PlayerAction RiverLogic(GetTurnContext context)
        {
            if (isCallingStation && this.CurrentHandRank > HandRankType.Pair &&
                this.lastAction < PlayerActionType.Raise)
            {
                return(PlayerAction.Raise((context.CurrentPot * 2) - MagicNumber));
            }

            if (isVeryAggressive &&
                this.lastAction == PlayerActionType.Raise &&
                context.MoneyToCall <= ((context.CurrentPot / 2) + 1))
            {
                if (this.FirstCard.Type >= CardType.King || this.SecondCard.Type >= CardType.King)
                {
                    return(PlayerAction.CheckOrCall());
                }

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

            if (this.lastAction < PlayerActionType.Raise && !isCallingStation && !this.isAlwaysRaise)
            {
                return(PlayerAction.Raise((context.CurrentPot / 3) + MagicNumber));
            }

            // TODO: add handrank
            if (this.lastAction == PlayerActionType.Raise)
            {
                if (this.CurrentHandRank >= HandRankType.Straight && this.CommunityImproved())
                {
                    return(PlayerAction.Raise(context.CurrentPot + MagicNumber));
                }

                if (this.CurrentHandRank >= HandRankType.TwoPairs)
                {
                    return(PlayerAction.CheckOrCall());
                }

                if (!isCallingStation && context.MoneyToCall <= context.CurrentPot / 2 && this.CurrentHandRank >= HandRankType.Pair)
                {
                    return(PlayerAction.CheckOrCall());
                }

                return(PlayerAction.Fold());
            }

            if (this.CurrentHandRank >= HandRankType.TwoPairs && this.CommunityImproved())
            {
                return(PlayerAction.Raise(context.CurrentPot + MagicNumber));
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #14
0
        public ActionProvider GetActionProvider(GetTurnContext currentContext, Card first, Card second, IReadOnlyCollection <Card> community)
        {
            this.context = currentContext;

            if (this.context == null)
            {
                throw new NullReferenceException("Context must be set.");
            }

            if (this.context.RoundType == GameRoundType.PreFlop)
            {
                if (this.context.MyMoneyInTheRound == this.context.SmallBlind &&
                    this.context.MoneyToCall == this.context.SmallBlind &&
                    !this.context.CanCheck)
                {
                    this.isFirst = true;
                }
                else if (this.context.MyMoneyInTheRound == this.context.SmallBlind * 2 &&
                         this.context.PreviousRoundActions.Count == 3)
                {
                    this.isFirst = false;
                }

                if (this.context.MoneyLeft < 200)
                {
                    if (this.context.MoneyLeft / this.context.SmallBlind <= 15)
                    {
                        return(new SuperAggressivePreFlopActionProvider(this.context, first, second, this.isFirst));
                    }
                    else if (this.context.MoneyLeft / this.context.SmallBlind > 15 && this.context.MoneyLeft / this.context.SmallBlind <= 50)
                    {
                        return(new AggressivePreFlopActionProvider(this.context, first, second, this.isFirst));
                    }
                    else
                    {
                        // ontext.MoneyLeft / context.SmallBlind > 50
                        return(new PassiveAggressivePreFlopActionProvider(this.context, first, second, this.isFirst));
                    }
                }

                return(new AggressivePreFlopActionProvider(this.context, first, second, this.isFirst));
            }
            else if (this.context.RoundType == GameRoundType.Flop)
            {
                return(new PassiveAggressiveFlopProvider(this.context, first, second, community, this.isFirst));
            }
            else if (this.context.RoundType == GameRoundType.Turn)
            {
                return(new PassiveAggressiveFlopProvider(this.context, first, second, community, this.isFirst));
            }
            else
            {
                // RIVER (final state)
                return(new PassiveAggressiveFlopProvider(this.context, first, second, community, this.isFirst));
            }
        }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PassiveAggressiveFlopProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 /// <param name="communityCards">The community board cards (flop, turn, river)</param>
 internal PassiveAggressiveFlopProvider(GetTurnContext context, Card first, Card second, IReadOnlyCollection <Card> communityCards, bool isFirst)
     : base(context, first, second, isFirst)
 {
     this.handEvaluator  = new PreFlopHandEvaluator();
     this.communityCards = communityCards;
     this.allCards       = new List <Card> {
         first, second
     };
     this.allCards.AddRange(communityCards.ToList());
 }
コード例 #16
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            var raise = context.MoneyLeft;

            if (this.HandStrength > .95 && raise > 0)
            {
                return(PlayerAction.Raise(raise));
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #17
0
 public override PlayerAction GetTurn(GetTurnContext context)
 {
     if (context.MoneyLeft > 0)
     {
         return(PlayerAction.Raise(context.MoneyLeft));
     }
     else
     {
         return(PlayerAction.CheckOrCall());
     }
 }
コード例 #18
0
        private PlayerAction AllInProtection(GetTurnContext context)
        {
            var bigBlind   = context.SmallBlind * 2;
            var blindRatio = bigBlind / this.initialMoney;
            var moneyLeft  = context.MoneyLeft;

            if (this.HandStrength < HandStrengthMargin &&
                blindRatio < BlindRatioMargin &&
                moneyLeft != 0)
            {
                return(PlayerAction.Fold());
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #19
0
 public override PlayerAction GetTurn(GetTurnContext context)
 {
     if (context.CanCheck && this.HandStrength > .1)
     {
         return PlayerAction.Raise(context.MoneyLeft);
     }
     else if (context.CanCheck && this.HandStrength <= .1)
     {
         return PlayerAction.CheckOrCall();
     }
     else
     {
         return PlayerAction.CheckOrCall();
     }
 }
コード例 #20
0
 public override PlayerAction GetTurn(GetTurnContext context)
 {
     if (context.CanCheck && this.HandStrength > .1)
     {
         return(PlayerAction.Raise(context.MoneyLeft));
     }
     else if (context.CanCheck && this.HandStrength <= .1)
     {
         return(PlayerAction.CheckOrCall());
     }
     else
     {
         return(PlayerAction.CheckOrCall());
     }
 }
コード例 #21
0
ファイル: TodorPlayer.cs プロジェクト: ekov1/TelerikAcademy
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            switch (this.state)
            {
            case PlayerStateType.SafeAllIn:
                return(this.SafeAllInState(context));

            case PlayerStateType.AllInProtection:
                return(this.AllInProtectionState(context));

            default:
                break;
            }

            throw new InvalidOperationException("No such state found.");
        }
コード例 #22
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            foreach (var action in context.PreviousRoundActions.Where(x => !x.PlayerName.Contains("SmokinAces") && x.Action != PlayerAction.CheckOrCall()))
            {
                actions.Add(action);
            }

            handValue = HandEvaluator.CalculateHandValue(new List<Card> { this.FirstCard, this.SecondCard }, this.CommunityCards.ToList());
            raiseAmount = (int)(handValue * 70) / (5 - (int)context.RoundType) + context.SmallBlind;

            if (context.RoundType == GameRoundType.PreFlop)
            {
                handValue -= 0.10;
            }
            
            if (context.MoneyLeft <= 0)
            {
                return PlayerAction.CheckOrCall();
            }
            
            if (context.MoneyLeft < 100)
            {
                if (raiseAmount > 2)
                {
                    raiseAmount /= 2;
                }
            }

            var bluffer = new Bluffer();
            var lessThan50 = new LessThan50();
            var lessThan60 = new LessThan60();
            var lessThan70 = new LessThan70();
            var lessThan80 = new LessThan80();
            var lessThan90 = new LessThan90();
            var lessThan100 = new LessThan100();

            bluffer.SetSuccessor(lessThan50);
            lessThan50.SetSuccessor(lessThan60);
            lessThan60.SetSuccessor(lessThan70);
            lessThan70.SetSuccessor(lessThan80);
            lessThan80.SetSuccessor(lessThan90);
            lessThan90.SetSuccessor(lessThan100);

            return bluffer.ProcessRequest(context, handValue, raiseAmount);
        }
コード例 #23
0
ファイル: SKOFGAD.cs プロジェクト: dentia/TeamDigitron
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            if (context.MoneyLeft / this.BigBlind <= 5)
            {
                return(PlayerAction.Raise(AllIn));
            }

            var decisionMaker   = this.factory.GetDecisionMaker(context.RoundType);
            var decisionContext = new DecisionContext
            {
                CommunityCards = this.CommunityCards,
                FirstCard      = this.FirstCard,
                SecondCard     = this.SecondCard,
                TurnContext    = context
            };

            return(decisionMaker.GetAction(decisionContext, this));
        }
コード例 #24
0
ファイル: TodorPlayer.cs プロジェクト: ekov1/TelerikAcademy
        private PlayerAction AllInProtectionState(GetTurnContext context)
        {
            const double HandStrengthMargin = .6; // .6.1
            double       blindRatioMargin   = .01;
            int          initialMoney       = 1000;

            var bigBlind   = context.SmallBlind * 2;
            var blindRatio = bigBlind / initialMoney;
            var moneyLeft  = context.MoneyLeft;

            if (this.HandStrength < HandStrengthMargin &&
                blindRatio < blindRatioMargin &&
                moneyLeft != 0)
            {
                return(PlayerAction.Fold());
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #25
0
ファイル: Jesus.cs プロジェクト: tddold/Team-TheChurch
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            if (context.RoundType == GameRoundType.PreFlop)
            {
                var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard);
                if (playHand == CardValuationType.Unplayable)
                {
                    return this.GetUnplayableAction(context);
                }

                if (playHand == CardValuationType.Risky)
                {
                    var smallBlindsTimes = RandomProvider.Next(1, 8);
                    return PlayerAction.Raise(context.SmallBlind * smallBlindsTimes);
                }

                if (playHand == CardValuationType.Recommended)
                {
                    var smallBlindsTimes = RandomProvider.Next(6, 14);
                    return PlayerAction.Raise(context.SmallBlind * smallBlindsTimes);
                }

                return PlayerAction.CheckOrCall();
            }

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

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

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

            return PlayerAction.CheckOrCall();
        }
コード例 #26
0
        private static PlayerAction CheckOrFoldCustomAction(GetTurnContext context)
        {
            if (context.CanCheck)
            {
                return(PlayerAction.CheckOrCall());
            }
            else if (!context.CanCheck)
            {
                if (context.MoneyToCall < context.SmallBlind * 5)
                {
                    return(PlayerAction.CheckOrCall());
                }

                return(PlayerAction.Fold());
            }
            else
            {
                return(PlayerAction.Fold());
            }
        }
コード例 #27
0
        public static PlayerAction CheckOrFoldCustomAction(GetTurnContext context)
        {
            if (context.CanCheck)
            {
                return(PlayerAction.CheckOrCall());
            }
            else if (!context.CanCheck)
            {
                if (context.CurrentPot < context.SmallBlind * 5)
                {
                    return(PlayerAction.CheckOrCall());
                }

                return(PlayerAction.Fold());
            }
            else
            {
                return(PlayerAction.Fold());
            }
        }
コード例 #28
0
        private PlayerAction FlopLogic(Card firstCard, Card secondCard, GetTurnContext context)
        {
            var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard);
            var handRank = HandChecker.CheckHand(firstCard, secondCard, CommunityCards);

            // TODO: Change raise values
            if (handRank == HandRankType.HighCard)
            {
                return(PlayerAction.CheckOrCall());
            }
            else if (handRank == HandRankType.Pair)
            {
                return(PlayerAction.Raise(RandomProvider.Next(2, 6)));
            }
            else if (handRank == HandRankType.TwoPairs)
            {
                return(PlayerAction.Raise(RandomProvider.Next(5, 11)));
            }
            else if (handRank == HandRankType.ThreeOfAKind)
            {
                return(PlayerAction.Raise(RandomProvider.Next(8, 20)));
            }
            else if (handRank == HandRankType.Straight)
            {
                return(PlayerAction.Raise(RandomProvider.Next(10, 23)));
            }
            else if (handRank == HandRankType.Flush)
            {
                return(PlayerAction.Raise(RandomProvider.Next(11, 25)));
            }
            else if (handRank == HandRankType.FullHouse)
            {
                return(PlayerAction.Raise(RandomProvider.Next(13, 26)));
            }
            else if (handRank == HandRankType.FourOfAKind)
            {
                return(PlayerAction.Raise(RandomProvider.Next(14, 26)));
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #29
0
        private PlayerAction FlopLogic(Card firstCard, Card secondCard, GetTurnContext context)
        {
            var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard);
            var handRank = HandChecker.CheckHand(firstCard, secondCard, CommunityCards);

            // TODO: Change raise values
            if (handRank == HandRankType.HighCard)
            {
                return PlayerAction.CheckOrCall();
            }
            else if (handRank == HandRankType.Pair)
            {
                return PlayerAction.Raise(RandomProvider.Next(2,6));
            }
            else if (handRank == HandRankType.TwoPairs)
            {
                return PlayerAction.Raise(RandomProvider.Next(5,11));
            }
            else if (handRank == HandRankType.ThreeOfAKind)
            {
                return PlayerAction.Raise(RandomProvider.Next(8,20));
            }
            else if (handRank == HandRankType.Straight)
            {
                return PlayerAction.Raise(RandomProvider.Next(10,23));
            }
            else if (handRank == HandRankType.Flush)
            {
                return PlayerAction.Raise(RandomProvider.Next(11, 25));
            }
            else if (handRank == HandRankType.FullHouse)
            {
                return PlayerAction.Raise(RandomProvider.Next(13, 26));
            }
            else if (handRank == HandRankType.FourOfAKind)
            {
                return PlayerAction.Raise(RandomProvider.Next(14, 26));
            }

            return PlayerAction.CheckOrCall();
        }
コード例 #30
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            if (context.RoundType == GameRoundType.PreFlop)
            {
                var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard);
                if (playHand == CardValuationType.Unplayable)
                {
                    return(PlayerAction.Fold());
                }
                else if (playHand == CardValuationType.Recommended)
                {
                    return(PlayerAction.Raise(context.SmallBlind * 2));
                }
                else
                {
                    return(PlayerAction.CheckOrCall());
                }
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #31
0
        private PlayerAction PreflopLogic(Card firstCard, Card secondCard, GetTurnContext context)
        {
            var playHand = HandStrengthValuation.PreFlop(this.FirstCard, this.SecondCard);

            if (playHand == CardValuationType.Unplayable)
            {
                if (context.CurrentPot < 15 && context.MoneyLeft > 100)
                {
                    return(PlayerAction.CheckOrCall());
                }
                else
                {
                    return(PlayerAction.Fold());
                }
            }
            else if (playHand == CardValuationType.NotRecommended)
            {
                if (!context.CanCheck && context.MyMoneyInTheRound <= 500)
                {
                    return(PlayerAction.Fold());
                }
            }
            else if (playHand == CardValuationType.Risky)
            {
                if (context.MoneyLeft <= 500 && !context.CanCheck)
                {
                    return(PlayerAction.Fold());
                }
                var smallBlindsTimes = RandomProvider.Next(5, 15);
                return(PlayerAction.Raise(context.SmallBlind * smallBlindsTimes));
            }
            else if (playHand == CardValuationType.Recommended)
            {
                var smallBlindsTimes = RandomProvider.Next(10, 25);
                return(PlayerAction.Raise(context.SmallBlind * smallBlindsTimes));
            }

            // default
            return(PlayerAction.Fold());
        }
コード例 #32
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            this.UpdateCommonRow(context.CurrentPot);

            ConsoleHelper.WriteOnConsole(this.row + 2, 2, "Select action [C]heck/[C]all, [R]aise, [F]old, [A]ll-in");
            while (true)
            {
                var          key    = Console.ReadKey(true);
                PlayerAction action = null;
                switch (key.Key)
                {
                case ConsoleKey.C:
                    action = PlayerAction.CheckOrCall();
                    break;

                case ConsoleKey.R:
                    // TODO: Ask for the raise amount!
                    action = PlayerAction.Raise(10);
                    break;

                case ConsoleKey.F:
                    action = PlayerAction.Fold();
                    break;

                case ConsoleKey.A:
                    action = PlayerAction.Raise(context.MoneyLeft);
                    break;
                }

                // TODO: Check if the action is valid
                if (action != null)
                {
                    ConsoleHelper.WriteOnConsole(this.row + 2, 2, new string(' ', this.width - 3));
                    ConsoleHelper.WriteOnConsole(this.row + 3, 2, action + "    ");
                    return(action);
                }
            }
        }
コード例 #33
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            this.DrawPlayerOptions(context.MoneyToCall);

            while (true)
            {
                var          key    = Console.ReadKey(true);
                PlayerAction action = null;
                switch (key.Key)
                {
                case ConsoleKey.C:
                    action = PlayerAction.CheckOrCall();
                    break;

                case ConsoleKey.R:
                    // ConsoleHelper.WriteOnConsole(this.row + 2, 2, $"Raise amount [1-{context.MoneyLeft}]:                                ");
                    // continue;
                    var amount = int.Parse(Console.ReadLine());
                    action = PlayerAction.Raise(amount);
                    break;

                case ConsoleKey.F:
                    action = PlayerAction.Fold();
                    break;

                case ConsoleKey.A:
                    action = context.MoneyLeft > 0
                                     ? PlayerAction.Raise(context.MoneyLeft)
                                     : PlayerAction.CheckOrCall();
                    break;
                }

                if (action != null)
                {
                    return(action);
                }
            }
        }
コード例 #34
0
        private PlayerAction AlwaysRaiseProtection(GetTurnContext context)
        {
            if (context.PreviousRoundActions.Count > 0 && context.PreviousRoundActions.Last().Action.Type == PlayerActionType.Raise)
            {
                if (context.MoneyToCall >= context.MoneyLeft / 2 && this.HandStrength < .8)
                {
                    return(PlayerAction.Fold());
                }
            }

            if (this.HandStrength < .42)
            {
                return(PlayerAction.Fold());
            }

            var raise = context.MoneyLeft;

            if (this.HandStrength > .95 && raise > 0)
            {
                return(PlayerAction.Raise(raise));
            }

            return(PlayerAction.CheckOrCall());
        }
コード例 #35
0
        // http://www.rakebackpros.net/texas-holdem-starting-hands/
        public static CardValueType PreFlop(GetTurnContext context, Card firstCard, Card secondCard)
        {
            var value = firstCard.Suit == secondCard.Suit
                          ? (firstCard.Type > secondCard.Type
                                 ? StartingHandRecommendations[MaxCardTypeValue - (int)firstCard.Type, MaxCardTypeValue - (int)secondCard.Type]
                                 : StartingHandRecommendations[MaxCardTypeValue - (int)secondCard.Type, MaxCardTypeValue - (int)firstCard.Type])
                          : (firstCard.Type > secondCard.Type
                                 ? StartingHandRecommendations[MaxCardTypeValue - (int)secondCard.Type, MaxCardTypeValue - (int)firstCard.Type]
                                 : StartingHandRecommendations[MaxCardTypeValue - (int)firstCard.Type, MaxCardTypeValue - (int)secondCard.Type]);

            switch (value)
            {
                case 0:
                    return CardValueType.Unplayable;
                case 1:
                    return CardValueType.NotRecommended;
                case 2:
                    return CardValueType.Risky;
                case 3:
                    return CardValueType.Recommended;
                default:
                    return CardValueType.Unplayable;
            }
        }
コード例 #36
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            Card firstCard  = this.FirstCard;
            Card secondCard = this.SecondCard;

            if (context.RoundType == GameRoundType.PreFlop)
            {
                return(PreflopLogic(firstCard, secondCard, context));
            }
            else if (context.RoundType == GameRoundType.Flop)
            {
                return(FlopLogic(firstCard, secondCard, context));
            }
            else if (context.RoundType == GameRoundType.Turn)
            {
                return(FlopLogic(firstCard, secondCard, context));
            }
            else if (context.RoundType == GameRoundType.River)
            {
                return(FlopLogic(firstCard, secondCard, context));
            }

            return(PlayerAction.Fold());
        }
コード例 #37
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            Card firstCard = this.FirstCard;
            Card secondCard = this.SecondCard;

            if (context.RoundType == GameRoundType.PreFlop)
            {
                return PreflopLogic(firstCard, secondCard, context);
            }
            else if (context.RoundType == GameRoundType.Flop)
            {
                return FlopLogic(firstCard, secondCard, context);
            }
            else if (context.RoundType == GameRoundType.Turn)
            {
                return FlopLogic(firstCard, secondCard, context);
            }
            else if (context.RoundType == GameRoundType.River)
            {
                return FlopLogic(firstCard, secondCard, context);
            }

            return PlayerAction.Fold();
        }
コード例 #38
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            var actionProvider = this.actionProviderFactory.GetActionProvider(context, this.FirstCard, this.SecondCard, this.CommunityCards);

            return actionProvider.GetAction();
        }
コード例 #39
0
ファイル: Jesus.cs プロジェクト: tddold/Team-TheChurch
 private PlayerAction GetUnplayableAction(GetTurnContext context)
 {
     if (context.CanCheck)
     {
         return PlayerAction.CheckOrCall();
     }
     else
     {
         return PlayerAction.Fold();
     }
 }
コード例 #40
0
ファイル: Jesus.cs プロジェクト: tddold/Team-TheChurch
        private PlayerAction GetTurnAction(GetTurnContext context)
        {
            var playHand = HandStrengthValuation.Turn(this.FirstCard, this.SecondCard, this.CommunityCards);

            return this.GetActionByCardValuationType(playHand, context);
        }
コード例 #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SuperAggressivePreFlopActionProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 internal SuperAggressivePreFlopActionProvider(GetTurnContext context, Card first, Card second, bool isFirst)
     : base(context, first, second, isFirst)
 {
     this.handEvaluator = new PreFlopHandEvaluator();
 }
コード例 #42
0
 public virtual PlayerAction GetTurn(GetTurnContext context)
 {
     return this.Player.GetTurn(context);
 }
コード例 #43
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            // antiCrash prefix - do not delete
            if (context.MoneyLeft <= 0)
            {
                return PlayerAction.CheckOrCall();
            }

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

            if (context.RoundType == GameRoundType.Flop && (context.MoneyLeft + context.CurrentPot == 2000 || context.MoneyLeft == 0))
            {
                if (context.PreviousRoundActions.Any() && context.PreviousRoundActions.Last().Action.Type == PlayerActionType.Fold)
                {
                    magic = true;
                }
            }

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

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

            if (this.opponentActions.Any() && ((!flag && context.SmallBlind == 2) ||
                (flag && context.SmallBlind == 10)))
            {
                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 && !this.isAlwaysAllIn) ||
                (context.MoneyToCall < MagicFishingNumber &&
                context.RoundType != GameRoundType.PreFlop))
            {
                if (context.RoundType != GameRoundType.River)
                {
                    if (context.RoundType == GameRoundType.Turn)
                    {
                        if (this.FirstCard.Type == this.SecondCard.Type)
                        {
                            this.DoIt(this.hand, HandRankType.ThreeOfAKind);
                        }
                        else if (this.CurrentHandRank < HandRankType.Straight &&
                            this.FirstCard.Type != this.SecondCard.Type)
                        {
                            this.DoIt(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
                    && this.outs.Count < 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();
        }
コード例 #44
0
 public abstract PlayerTurn GetTurn(GetTurnContext context);
コード例 #45
0
ファイル: TestBot.cs プロジェクト: DimitarSD/Teamwork-Sparta
        private static PlayerAction CheckOrFoldCustomAction(GetTurnContext context)
        {
            if (context.CanCheck)
            {
                return PlayerAction.CheckOrCall();
            }
            else if (!context.CanCheck)
            {
                if (context.CurrentPot < context.SmallBlind * 5)
                {
                    return PlayerAction.CheckOrCall();
                }

                return PlayerAction.Fold();
            }
            else
            {
                return PlayerAction.Fold();
            }
        }
コード例 #46
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();
        }
コード例 #47
0
        private PlayerAction TurnLogic(GetTurnContext context)
        {
            if (isCallingStation && this.CurrentHandRank > HandRankType.Pair)
            {
                return PlayerAction.Raise((context.CurrentPot * 2) + MagicNumber);
            }

            if (this.CurrentHandRank >= HandRankType.TwoPairs)
            {
                if (this.lastAction < PlayerActionType.Raise)
                {
                    return PlayerAction.Raise(context.CurrentPot + MagicNumber);
                }

                if (this.CurrentHandRank >= HandRankType.Straight)
                {
                    return PlayerAction.Raise(AllIn(context.MoneyLeft));
                }

                return PlayerAction.CheckOrCall();
            }

            if (this.lastAction < PlayerActionType.Raise && !isCallingStation && !this.isAlwaysRaise)
            {
                return PlayerAction.Raise((context.CurrentPot / 3) + MagicNumber);
            }

            if (this.CurrentHandRank < HandRankType.Straight)
            {
                this.DoIt(this.hand, HandRankType.Straight);
            }

            if (this.outs.Count > 10)
            {
                if (this.lastAction == PlayerActionType.Raise)
                {
                    if (context.MoneyToCall * 100 / context.CurrentPot < (this.outs.Count * 2) + 5)
                    {
                        if (isVeryAggressive && !this.isAlwaysRaise)
                        {
                            return PlayerAction.Raise(AllIn(context.MoneyLeft));
                        }

                        return PlayerAction.CheckOrCall();
                    }

                    return PlayerAction.Fold();
                }

                return PlayerAction.Raise(((context.CurrentPot * 2) / 3) + MagicNumber);
            }

            if (isVeryAggressive && this.CurrentHandRank >= HandRankType.Pair &&
                context.MoneyToCall <= context.CurrentPot * 2 / 3)
            {
                return PlayerAction.CheckOrCall();
            }

            if (this.outs.Count <= 10)
            {
                if (this.lastAction == PlayerActionType.Raise &&
                    context.MoneyToCall * 100 / context.CurrentPot > this.outs.Count * 2)
                {
                    return PlayerAction.Fold();
                }
            }

            return PlayerAction.CheckOrCall();
        }
コード例 #48
0
        private PlayerAction FlopLogic(GetTurnContext context)
        {
            if (isCallingStation && this.CurrentHandRank > HandRankType.Pair)
            {
                return PlayerAction.Raise((context.CurrentPot * 2) - MagicNumber);
            }

            if (isVeryAggressive)
            {
                if (this.CurrentHandRank >= HandRankType.TwoPairs)
                {
                    return PlayerAction.Raise((context.MoneyToCall * 2) + MagicNumber);
                }

                if (context.MoneyToCall <= context.CurrentPot && this.CurrentHandRank >= HandRankType.Pair)
                {
                    return PlayerAction.CheckOrCall();
                }
            }

            if (this.lastAction < PlayerActionType.Raise && !isCallingStation && !this.isAlwaysRaise)
            {
                return PlayerAction.Raise((context.CurrentPot / 3) + MagicNumber);
            }

            if (this.CurrentHandRank > HandRankType.TwoPairs)
            {
                if (this.lastAction < PlayerActionType.Raise)
                {
                    return PlayerAction.Raise(context.CurrentPot + MagicNumber);
                }

                if (this.CurrentHandRank >= HandRankType.Straight)
                {
                    return PlayerAction.Raise((context.CurrentPot * 2) - MagicNumber);
                }

                return PlayerAction.CheckOrCall();
            }

            if (this.FirstCard.Type == this.SecondCard.Type)
            {
                this.DoIt(this.hand, HandRankType.ThreeOfAKind);
            }
            else if (this.CurrentHandRank < HandRankType.Straight &&
                this.FirstCard.Type != this.SecondCard.Type)
            {
                this.DoIt(this.hand, HandRankType.Straight);
            }

            if (this.lastAction == PlayerActionType.Raise && isVeryAggressive && !this.isAlwaysRaise)
            {
                if (this.outs.Count >= 9)
                {
                    return PlayerAction.Raise(AllIn(context.MoneyLeft));
                }
            }

            if (this.lastAction < PlayerActionType.Raise && !isCallingStation && !this.isAlwaysRaise)
            {
                return PlayerAction.Raise((context.CurrentPot / 3) + MagicNumber);
            }

            if (this.outs.Count > 11)
            {
                if (this.lastAction < PlayerActionType.Raise)
                {
                    return PlayerAction.Raise(context.CurrentPot * 2 / 3 + MagicNumber);
                }
                else
                {
                    return PlayerAction.CheckOrCall();
                }
            }

            if (this.outs.Count > 8)
            {
                if (this.lastAction < PlayerActionType.Raise &&
                    context.MoneyToCall * 100 / context.CurrentPot < this.outs.Count * 5)
                {
                    return PlayerAction.CheckOrCall();
                }

                return PlayerAction.Raise((context.CurrentPot * 2 / 3) - MagicNumber);
            }

            if (this.outs.Count < 6)
            {
                if (this.lastAction == PlayerActionType.Raise)
                {
                    return PlayerAction.Fold();
                }

                return PlayerAction.CheckOrCall();
            }

            return PlayerAction.CheckOrCall();
        }
コード例 #49
0
 private PlayerAction RiverLogic(Card firstCard, Card secondCard, GetTurnContext context)
 {
     // default
     return PlayerAction.CheckOrCall();
 }
コード例 #50
0
 public override PlayerAction GetTurn(GetTurnContext context)
 {
     return this.state.GetTurn(context);
 }
コード例 #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PreFlopActionProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 internal PreFlopActionProvider(GetTurnContext context, Card first, Card second, bool isFirst)
     : base(context, first, second, isFirst)
 {
 }
コード例 #52
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            #region Preflop
            if (context.RoundType == GameRoundType.PreFlop)
            {
                var handValue = HandStrengthValuationBluffasaurus.PreFlop(this.FirstCard, this.SecondCard);
                var optimalValueCoeff = 2;

                var extreme = 64 - optimalValueCoeff;
                var powerful = 60 - optimalValueCoeff;
                var normal = 55 - optimalValueCoeff;
                var weak = 50 - (optimalValueCoeff * 2);
                var awful = 43 - (optimalValueCoeff * 2);
                var lowerLimit = 40 - optimalValueCoeff;

                // if we are first to act on a small blind
                if (context.MoneyToCall == context.SmallBlind && context.CurrentPot == context.SmallBlind * 3)
                {
                    inPosition = true;

                    if (handValue >= extreme)
                    {
                        return PlayerAction.Raise(context.SmallBlind * 20);
                    }
                    else if (handValue >= powerful)
                    {
                        return PlayerAction.Raise(context.SmallBlind * 16);
                    }
                    else if (handValue >= normal)
                    {
                        return PlayerAction.Raise(context.SmallBlind * 12);
                    }
                    else if (handValue >= awful) // that makes around 74% of all possible hands
                    {
                        // can be further optimized
                        if (context.SmallBlind > context.MoneyLeft / 50)
                        {
                            return PlayerAction.CheckOrCall();
                        }

                        return PlayerAction.Raise(context.SmallBlind * 10);
                    }
                    else if (handValue > lowerLimit && context.SmallBlind < context.MoneyLeft / 40)
                    {
                        return PlayerAction.CheckOrCall();
                    }
                    else
                    {
                        return this.Fold();
                    }
                }
                else  // we are on big blind or opp has raised
                {
                    // opponent has not raised
                    if (context.MoneyToCall == 0)
                    {
                        if (handValue >= extreme) // cards like AA, KK, AKs
                        {
                            return PlayerAction.Raise(context.SmallBlind * 20);
                        }
                        else if (handValue >= powerful)
                        {
                            return PlayerAction.Raise(context.SmallBlind * 16);
                        }
                        else if (handValue >= awful) // that makes around 74% of all possible hands
                        {
                            // can be further optimized
                            if (context.SmallBlind > context.MoneyLeft / 50)
                            {
                                return PlayerAction.CheckOrCall();
                            }

                            return PlayerAction.Raise(context.SmallBlind * 6);
                        }
                        else
                        {
                            return PlayerAction.CheckOrCall();
                        }
                    }
                    else // opponent has raised
                    {
                        // if opp has raised a lot(has a very strong hand)
                        if (context.MoneyToCall > context.SmallBlind * 8 && context.MoneyToCall > 40)
                        {
                            if (handValue >= extreme) // cards like AA, KK, AKs
                            {
                                return PlayerAction.Raise(context.SmallBlind * 16);
                            }
                            else if (handValue >= powerful)
                            {
                                // we have some more money and want to wait for a better shot
                                if (context.MoneyToCall > context.MoneyLeft / 4 && context.MoneyToCall > context.SmallBlind * 6)
                                {
                                    return this.Fold();
                                }
                                else
                                {
                                    return PlayerAction.CheckOrCall();
                                }
                            }
                            else
                            {
                                return this.Fold();
                            }
                        }
                        else // opponent has not raised a lot
                        {
                            if (handValue >= extreme) // cards like AA, KK, AKs
                            {
                                return PlayerAction.Raise(context.SmallBlind * 20);
                            }
                            else if (handValue >= powerful)
                            {
                                // if we have already raised enough this round
                                if (context.MyMoneyInTheRound > context.SmallBlind * 10)
                                {
                                    return PlayerAction.CheckOrCall();
                                }
                                else
                                {
                                    return PlayerAction.Raise(context.SmallBlind * 12);
                                }
                            }
                            else if (handValue >= normal)
                            {
                                return PlayerAction.CheckOrCall();
                            }
                            else if (handValue >= weak && (context.MoneyToCall <= 20 || context.MoneyToCall <= context.SmallBlind * 3))
                            {
                                return PlayerAction.CheckOrCall();
                            }
                            else if (handValue >= awful && (context.MoneyToCall <= 20 || context.MoneyToCall <= context.SmallBlind * 2))
                            {
                                return PlayerAction.CheckOrCall();
                            }
                            else
                            {
                                return this.Fold();
                            }
                        }
                    }
                }
            }
            #endregion

            #region Flop
            else if (context.RoundType == GameRoundType.Flop)
            {
                var raiseCoeff = context.SmallBlind * 0;

                if (context.MoneyLeft == 0)
                {
                    return PlayerAction.CheckOrCall();
                }

                var flopCardStrength = CardsStrengthEvaluation.RateCards
                    (new List<Card> { FirstCard, SecondCard, CommunityCards.ElementAt(0), CommunityCards.ElementAt(1), CommunityCards.ElementAt(2) });

                if (inPosition)
                {
                    if (flopCardStrength >= 2000)
                    {
                        return PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff);
                    }
                    else if (flopCardStrength >= 1000)
                    {
                        var pairInfo = this.GetPairInfo();

                        if (pairInfo == 0)
                        {
                            return PlayerAction.CheckOrCall();
                        }
                        else
                        {
                            if (pairInfo >= 11)
                            {
                                return PlayerAction.Raise(context.SmallBlind * 12 + raiseCoeff);
                            }
                            else
                            {
                                return PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff);
                            }
                        }
                    }
                    else
                    {
                        return PlayerAction.CheckOrCall();
                    }
                }
                else
                {
                    // opponent has raised
                    if (context.MoneyToCall > 0)
                    {
                        // a lot
                        if (context.MoneyToCall > context.CurrentPot - context.MoneyToCall && context.MoneyToCall > 50)
                        {
                            if (flopCardStrength >= 3000)
                            {
                                return PlayerAction.Raise(context.SmallBlind * 30 + raiseCoeff);
                            }
                            if (flopCardStrength >= 2000)
                            {
                                return PlayerAction.Raise(context.SmallBlind * 10 + raiseCoeff);
                            }
                            else if (flopCardStrength >= 1000)
                            {
                                // is common pair logic
                                var pairInfo = this.GetPairInfo();

                                if (pairInfo == 0)
                                {
                                    return this.Fold();
                                }
                                else
                                {
                                    // money are a lot and we fold
                                    if (context.MoneyToCall > context.MoneyLeft / 3 && context.MoneyLeft > 300)
                                    {
                                        return this.Fold();
                                    }
                                    else
                                    {
                                        if (pairInfo >= 11)
                                        {
                                            return PlayerAction.CheckOrCall();
                                        }
                                        else
                                        {
                                            return this.Fold();
                                        }
                                    }
                                }
                            }
                            else
                            {
                                return this.Fold();
                            }
                        }
                        else //not a lot
                        {
                            if (flopCardStrength >= 2000)
                            {
                                return PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff);
                            }
                            else if (flopCardStrength >= 1000)
                            {
                                var pairInfo = this.GetPairInfo();

                                if (pairInfo == 0)
                                {
                                    return PlayerAction.CheckOrCall();
                                }
                                else
                                {
                                    if (pairInfo >= 11)
                                    {
                                        return PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff);
                                    }
                                    else
                                    {
                                        return PlayerAction.CheckOrCall();
                                    }
                                }
                            }
                            else
                            {
                                if (context.MoneyToCall >= 20)
                                {
                                    return this.Fold();
                                }
                                else
                                {
                                    return PlayerAction.CheckOrCall();
                                }
                            }
                        }
                    }
                    else // opp has checked (has bad hand)
                    {
                        if (flopCardStrength >= 2000)
                        {
                            return PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff);
                        }
                        else if (flopCardStrength >= 1000)
                        {
                            return PlayerAction.Raise(context.SmallBlind * 16 + raiseCoeff);
                        }

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

            #region Turn
            else if (context.RoundType == GameRoundType.Turn || context.RoundType == GameRoundType.River)
            {
                if (context.RoundType == GameRoundType.River)
                {
                    inPosition = false;
                }

                if (context.MoneyLeft == 0)
                {
                    return PlayerAction.CheckOrCall();
                }

                var flopCardStrength = CardsStrengthEvaluation.RateCards
                    (new List<Card> { FirstCard, SecondCard, CommunityCards.ElementAt(0), CommunityCards.ElementAt(1), CommunityCards.ElementAt(2) });

                if (flopCardStrength >= 2000)
                {
                    return PlayerAction.Raise(context.CurrentPot);
                }
                else
                {

                    var hand = new List<Card>();
                    hand.Add(this.FirstCard);
                    hand.Add(this.SecondCard);

                    var ehs = EffectiveHandStrenghtCalculator.CalculateEHS(hand, this.CommunityCards);

                    if (ehs < 0.3)
                    {
                        if (context.MoneyToCall <= context.MoneyLeft / 200)
                        {
                            return PlayerAction.CheckOrCall();
                        }
                        else
                        {
                            return this.Fold();
                        }
                    }
                    else if (ehs < 0.5)
                    {
                        if (context.MoneyToCall <= context.MoneyLeft / 40)
                        {
                            return PlayerAction.CheckOrCall();
                        }
                        else
                        {
                            return this.Fold();
                        }
                    }
                    else if (ehs < 0.62)
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = (int)(currentPot * 0.55);

                        if (context.MoneyToCall == 0)
                        {
                            return PlayerAction.Raise(moneyToBet);
                        }
                        else if (context.MoneyToCall < context.MoneyLeft / 20 || context.MoneyToCall < 50)
                        {
                            if (context.MoneyToCall < moneyToBet && context.MyMoneyInTheRound == 0)
                            {
                                return PlayerAction.Raise(moneyToBet - context.MoneyToCall + 1);
                            }
                            else
                            {
                                return PlayerAction.CheckOrCall();
                            }
                        }
                        else
                        {
                            return this.Fold();
                        }
                    }
                    else if (ehs < 0.75)
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = (int)(currentPot * 0.75);

                        if (context.MoneyToCall == 0)
                        {
                            return PlayerAction.Raise(moneyToBet);
                        }
                        else if (context.MoneyToCall < context.MoneyLeft / 10 || context.MoneyToCall < 70) // TODO:
                        {
                            if (context.MoneyToCall < moneyToBet && context.MyMoneyInTheRound == 0)
                            {
                                return PlayerAction.Raise(moneyToBet - context.MoneyToCall + 1);
                            }
                            else
                            {
                                return PlayerAction.CheckOrCall();
                            }
                        }
                        else
                        {
                            return this.Fold();
                        }
                    }
                    else if (ehs < 0.85)
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = (int)(currentPot * 0.85);

                        if (context.MoneyToCall == 0)
                        {

                            if (moneyToBet < 50)
                            {
                                moneyToBet = 50;
                            }

                            return PlayerAction.Raise(moneyToBet);
                        }
                        else if (context.MoneyToCall < context.MoneyLeft / 2 || context.MoneyToCall < 250)
                        {
                            if (context.MoneyToCall < moneyToBet && context.MyMoneyInTheRound == 0)
                            {
                                return PlayerAction.Raise(moneyToBet - context.MoneyToCall + 1);
                            }
                            else
                            {
                                return PlayerAction.CheckOrCall();
                            }
                        }
                        else
                        {
                            return this.Fold();
                        }
                    }
                    else
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = currentPot;
                        if (moneyToBet < 80)
                        {
                            moneyToBet = 80;
                        }

                        return PlayerAction.Raise(moneyToBet);
                    }
                }
            }
            #endregion

            return PlayerAction.CheckOrCall(); // It should never reach this point
        }
コード例 #53
0
ファイル: TestBot.cs プロジェクト: DimitarSD/Teamwork-Sparta
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            var preFlopCards = CustomHandEvaluator.PreFlop(context, this.FirstCard, this.SecondCard);

            List<Card> currentCards = new List<Card>();
            currentCards.Add(this.FirstCard);
            currentCards.Add(this.SecondCard);

            if (context.RoundType == GameRoundType.PreFlop)
            {
                if (preFlopCards == CardValueType.Unplayable)
                {
                    return CheckOrFoldCustomAction(context);
                }

                if (preFlopCards == CardValueType.Risky || preFlopCards == CardValueType.NotRecommended)
                {
                    if (preFlopCards == CardValueType.NotRecommended && context.MoneyToCall > context.SmallBlind * 11)
                    {
                        return CheckOrFoldCustomAction(context);
                    }

                    if (preFlopCards == CardValueType.Risky && context.MoneyToCall > context.SmallBlind * 21)
                    {
                        return CheckOrFoldCustomAction(context);
                    }

                    return PlayerAction.Raise(context.SmallBlind * 3);
                }

                if (preFlopCards == CardValueType.Recommended)
                {
                    return PlayerAction.Raise(context.SmallBlind * 6);
                }

                return PlayerAction.CheckOrCall();
            }
            else if (context.RoundType == GameRoundType.Flop)
            {
                // TODO
                // add strong logic for FLOP
                // (do we have good card conmbination from our 2 cards and the floppef 3 cards)
                // иif we have already played aggresivly (all-in) we should check/call
                // if NOT god combination - we can check or fold
                // if strong combination we can put more agressiong and raise/all-in
                currentCards.AddRange(this.CommunityCards);

                var combination = Logic.Helpers.Helpers.GetHandRank(currentCards);

                if (GotStrongHand(combination))
                {
                    if (preFlopCards == CardValueType.Recommended && context.MoneyLeft > 0)
                    {
                        return PlayerAction.Raise(context.MoneyLeft);
                    }

                    return PlayerAction.CheckOrCall();
                }
                else
                {
                    return CheckOrFoldCustomAction(context);
                }
            }
            else if (context.RoundType == GameRoundType.Turn)
            {
                // TODO
                // add strong logic for FLOP
                // (do we have good card conmbination from our 2 cards and the floppef 4 cards)
                // иif we have already played aggresivly (all-in) we should check/call
                // if NOT god combination - we can check or fold
                // if strong combination we can put more agressiong and raise/all-in
                currentCards.Clear();
                currentCards.Add(this.FirstCard);
                currentCards.Add(this.SecondCard);
                currentCards.AddRange(this.CommunityCards);

                var combination = Logic.Helpers.Helpers.GetHandRank(currentCards);

                if (GotStrongHand(combination))
                {
                    if (preFlopCards == CardValueType.Recommended && context.MoneyLeft > 0)
                    {
                        return PlayerAction.Raise(context.MoneyLeft);
                    }

                    return PlayerAction.CheckOrCall();
                }
                else
                {
                    return CheckOrFoldCustomAction(context);
                }
            }
            else
            {
                // GameRoundType.River (final card)
                // TODO
                // add strong logic for FLOP
                // (do we have good card conmbination from our 2 cards and the floppef 5 cards)
                // иif we have already played aggresivly (all-in) we should check/call
                // if NOT god combination - we can check or fold
                // if strong combination we can put more agressiong and raise/all-in
                currentCards.Clear();
                currentCards.Add(this.FirstCard);
                currentCards.Add(this.SecondCard);
                currentCards.AddRange(this.CommunityCards);

                var combination = Logic.Helpers.Helpers.GetHandRank(currentCards);

                if (GotVeryStrongHand(combination))
                {
                    if (context.MoneyLeft > 0)
                    {
                        return PlayerAction.Raise(context.MoneyLeft);
                    }

                    return PlayerAction.Raise(context.CurrentPot * 2);
                }
                else
                {
                    if (GotStrongHand(combination))
                    {
                        if (preFlopCards == CardValueType.Recommended && context.MoneyLeft > 0)
                        {
                            return PlayerAction.Raise(context.MoneyLeft);
                        }

                        return PlayerAction.CheckOrCall();
                    }
                    else
                    {
                        return CheckOrFoldCustomAction(context);
                    }
                }
            }
        }
コード例 #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PreFlopActionProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 internal PreFlopActionProvider(GetTurnContext context, Card first, Card second, bool isFirst)
     : base(context, first, second, isFirst)
 {
 }
コード例 #55
0
 public PlayerAction GetTurn(GetTurnContext context)
 {
     return(this.state.GetTurn(context));
 }
コード例 #56
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            // Calculate pot odds & rate of return in the beginning
            this.PotOdds = OddsCalculator.CalculatePotOdds(
                context.CurrentPot,
                context.MoneyToCall,
                context.SmallBlind * 2);

            this.RateOfReturn = OddsCalculator.CalculateRateOfReturn(this.HandStrength, this.PotOdds);

            /*If RR < 0.8 then 95% fold, 0 % call, 5% raise (bluff)   // Not playable threshold
              If RR < 1.0 then 80% fold, 5% call, 15% raise (bluff)   // Not reccomended threshold
              If RR <1.3 then 0% fold, 60% call, 40% raise            // Playable threshold
              Else (RR >= 1.3) 0% fold, 30% call, 70% raise
              If fold and amount to call is zero, then call.*/

            // If we can check or call without paying any money, do so
            if (this.HandStrength < .4 && context.CanCheck == true)
            {
                return PlayerAction.CheckOrCall();
            }

            // Fold in all win scenarios with weak hand
            double allWinPlayHandStrength = 0.95;
            bool opponentIsAllIn = (context.MoneyLeft + context.CurrentPot) == 2000;
            if (opponentIsAllIn && this.HandStrength <= allWinPlayHandStrength)
            {
                return PlayerAction.Fold();
            }

            if (opponentIsAllIn && this.HandStrength > allWinPlayHandStrength)
            {
                return PlayerAction.CheckOrCall();
            }

            // Calculate random between 0.0 and 1.0 for bluff scenarios
            double decisionCoefficient = this.random.GetRandomDouble();

            if (this.RateOfReturn <= NotPlayableThreshold)
            {
                if (decisionCoefficient <= .95)
                {
                    return PlayerAction.Fold();
                }
                else
                {
                    return PlayerAction.Raise(context.SmallBlind * 2);
                }
            }
            else if (this.RateOfReturn > NotPlayableThreshold && this.RateOfReturn <= NotReccomendedThreshold)
            {
                if (decisionCoefficient <= .8) // 0.8
                {
                    return PlayerAction.Fold();
                }
                else if (decisionCoefficient > .8 && decisionCoefficient <= .85) // 0.80 - 0.85
                {
                    return PlayerAction.CheckOrCall();
                }
                else
                {
                    return PlayerAction.Raise(context.SmallBlind * 2);
                }
            }
            else if (this.RateOfReturn > NotReccomendedThreshold && this.RateOfReturn < PlayableThreshold)
            {
                if (decisionCoefficient <= .6)
                {
                    return PlayerAction.CheckOrCall();
                }
                else
                {
                    return PlayerAction.Raise(context.SmallBlind * 2);
                }
            }
            else
            {
                if (decisionCoefficient <= .3)
                {
                    return PlayerAction.CheckOrCall();
                }
                else
                {
                    return PlayerAction.Raise(context.SmallBlind * 2);
                }
            }
        }
コード例 #57
0
        public override PlayerAction GetTurn(GetTurnContext context)
        {
            #region Preflop
            if (context.RoundType == GameRoundType.PreFlop)
            {
                var handValue         = HandStrengthValuationBluffasaurus.PreFlop(this.FirstCard, this.SecondCard);
                var optimalValueCoeff = 2;

                var extreme    = 64 - optimalValueCoeff;
                var powerful   = 60 - optimalValueCoeff;
                var normal     = 55 - optimalValueCoeff;
                var weak       = 50 - (optimalValueCoeff * 2);
                var awful      = 43 - (optimalValueCoeff * 2);
                var lowerLimit = 40 - optimalValueCoeff;

                // if we are first to act on a small blind
                if (context.MoneyToCall == context.SmallBlind && context.CurrentPot == context.SmallBlind * 3)
                {
                    inPosition = true;

                    if (handValue >= extreme)
                    {
                        return(PlayerAction.Raise(context.SmallBlind * 20));
                    }
                    else if (handValue >= powerful)
                    {
                        return(PlayerAction.Raise(context.SmallBlind * 16));
                    }
                    else if (handValue >= normal)
                    {
                        return(PlayerAction.Raise(context.SmallBlind * 12));
                    }
                    else if (handValue >= awful) // that makes around 74% of all possible hands
                    {
                        // can be further optimized
                        if (context.SmallBlind > context.MoneyLeft / 50)
                        {
                            return(PlayerAction.CheckOrCall());
                        }

                        return(PlayerAction.Raise(context.SmallBlind * 10));
                    }
                    else if (handValue > lowerLimit && context.SmallBlind < context.MoneyLeft / 40)
                    {
                        return(PlayerAction.CheckOrCall());
                    }
                    else
                    {
                        return(this.Fold());
                    }
                }
                else  // we are on big blind or opp has raised
                {
                    // opponent has not raised
                    if (context.MoneyToCall == 0)
                    {
                        if (handValue >= extreme) // cards like AA, KK, AKs
                        {
                            return(PlayerAction.Raise(context.SmallBlind * 20));
                        }
                        else if (handValue >= powerful)
                        {
                            return(PlayerAction.Raise(context.SmallBlind * 16));
                        }
                        else if (handValue >= awful) // that makes around 74% of all possible hands
                        {
                            // can be further optimized
                            if (context.SmallBlind > context.MoneyLeft / 50)
                            {
                                return(PlayerAction.CheckOrCall());
                            }

                            return(PlayerAction.Raise(context.SmallBlind * 6));
                        }
                        else
                        {
                            return(PlayerAction.CheckOrCall());
                        }
                    }
                    else // opponent has raised
                    {
                        // if opp has raised a lot(has a very strong hand)
                        if (context.MoneyToCall > context.SmallBlind * 8 && context.MoneyToCall > 40)
                        {
                            if (handValue >= extreme) // cards like AA, KK, AKs
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 16));
                            }
                            else if (handValue >= powerful)
                            {
                                // we have some more money and want to wait for a better shot
                                if (context.MoneyToCall > context.MoneyLeft / 4 && context.MoneyToCall > context.SmallBlind * 6)
                                {
                                    return(this.Fold());
                                }
                                else
                                {
                                    return(PlayerAction.CheckOrCall());
                                }
                            }
                            else
                            {
                                return(this.Fold());
                            }
                        }
                        else // opponent has not raised a lot
                        {
                            if (handValue >= extreme) // cards like AA, KK, AKs
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 20));
                            }
                            else if (handValue >= powerful)
                            {
                                // if we have already raised enough this round
                                if (context.MyMoneyInTheRound > context.SmallBlind * 10)
                                {
                                    return(PlayerAction.CheckOrCall());
                                }
                                else
                                {
                                    return(PlayerAction.Raise(context.SmallBlind * 12));
                                }
                            }
                            else if (handValue >= normal)
                            {
                                return(PlayerAction.CheckOrCall());
                            }
                            else if (handValue >= weak && (context.MoneyToCall <= 20 || context.MoneyToCall <= context.SmallBlind * 3))
                            {
                                return(PlayerAction.CheckOrCall());
                            }
                            else if (handValue >= awful && (context.MoneyToCall <= 20 || context.MoneyToCall <= context.SmallBlind * 2))
                            {
                                return(PlayerAction.CheckOrCall());
                            }
                            else
                            {
                                return(this.Fold());
                            }
                        }
                    }
                }
            }
            #endregion

            #region Flop
            else if (context.RoundType == GameRoundType.Flop)
            {
                var raiseCoeff = context.SmallBlind * 0;

                if (context.MoneyLeft == 0)
                {
                    return(PlayerAction.CheckOrCall());
                }

                var flopCardStrength = CardsStrengthEvaluation.RateCards
                                           (new List <Card> {
                    FirstCard, SecondCard, CommunityCards.ElementAt(0), CommunityCards.ElementAt(1), CommunityCards.ElementAt(2)
                });

                if (inPosition)
                {
                    if (flopCardStrength >= 2000)
                    {
                        return(PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff));
                    }
                    else if (flopCardStrength >= 1000)
                    {
                        var pairInfo = this.GetPairInfo();

                        if (pairInfo == 0)
                        {
                            return(PlayerAction.CheckOrCall());
                        }
                        else
                        {
                            if (pairInfo >= 11)
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 12 + raiseCoeff));
                            }
                            else
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff));
                            }
                        }
                    }
                    else
                    {
                        return(PlayerAction.CheckOrCall());
                    }
                }
                else
                {
                    // opponent has raised
                    if (context.MoneyToCall > 0)
                    {
                        // a lot
                        if (context.MoneyToCall > context.CurrentPot - context.MoneyToCall && context.MoneyToCall > 50)
                        {
                            if (flopCardStrength >= 3000)
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 30 + raiseCoeff));
                            }
                            if (flopCardStrength >= 2000)
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 10 + raiseCoeff));
                            }
                            else if (flopCardStrength >= 1000)
                            {
                                // is common pair logic
                                var pairInfo = this.GetPairInfo();

                                if (pairInfo == 0)
                                {
                                    return(this.Fold());
                                }
                                else
                                {
                                    // money are a lot and we fold
                                    if (context.MoneyToCall > context.MoneyLeft / 3 && context.MoneyLeft > 300)
                                    {
                                        return(this.Fold());
                                    }
                                    else
                                    {
                                        if (pairInfo >= 11)
                                        {
                                            return(PlayerAction.CheckOrCall());
                                        }
                                        else
                                        {
                                            return(this.Fold());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                return(this.Fold());
                            }
                        }
                        else //not a lot
                        {
                            if (flopCardStrength >= 2000)
                            {
                                return(PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff));
                            }
                            else if (flopCardStrength >= 1000)
                            {
                                var pairInfo = this.GetPairInfo();

                                if (pairInfo == 0)
                                {
                                    return(PlayerAction.CheckOrCall());
                                }
                                else
                                {
                                    if (pairInfo >= 11)
                                    {
                                        return(PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff));
                                    }
                                    else
                                    {
                                        return(PlayerAction.CheckOrCall());
                                    }
                                }
                            }
                            else
                            {
                                if (context.MoneyToCall >= 20)
                                {
                                    return(this.Fold());
                                }
                                else
                                {
                                    return(PlayerAction.CheckOrCall());
                                }
                            }
                        }
                    }
                    else // opp has checked (has bad hand)
                    {
                        if (flopCardStrength >= 2000)
                        {
                            return(PlayerAction.Raise(context.SmallBlind * 8 + raiseCoeff));
                        }
                        else if (flopCardStrength >= 1000)
                        {
                            return(PlayerAction.Raise(context.SmallBlind * 16 + raiseCoeff));
                        }

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

            #region Turn
            else if (context.RoundType == GameRoundType.Turn || context.RoundType == GameRoundType.River)
            {
                if (context.RoundType == GameRoundType.River)
                {
                    inPosition = false;
                }

                if (context.MoneyLeft == 0)
                {
                    return(PlayerAction.CheckOrCall());
                }

                var flopCardStrength = CardsStrengthEvaluation.RateCards
                                           (new List <Card> {
                    FirstCard, SecondCard, CommunityCards.ElementAt(0), CommunityCards.ElementAt(1), CommunityCards.ElementAt(2)
                });

                if (flopCardStrength >= 2000)
                {
                    return(PlayerAction.Raise(context.CurrentPot));
                }
                else
                {
                    var hand = new List <Card>();
                    hand.Add(this.FirstCard);
                    hand.Add(this.SecondCard);

                    var ehs = EffectiveHandStrenghtCalculator.CalculateEHS(hand, this.CommunityCards);

                    if (ehs < 0.3)
                    {
                        if (context.MoneyToCall <= context.MoneyLeft / 200)
                        {
                            return(PlayerAction.CheckOrCall());
                        }
                        else
                        {
                            return(this.Fold());
                        }
                    }
                    else if (ehs < 0.5)
                    {
                        if (context.MoneyToCall <= context.MoneyLeft / 40)
                        {
                            return(PlayerAction.CheckOrCall());
                        }
                        else
                        {
                            return(this.Fold());
                        }
                    }
                    else if (ehs < 0.62)
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = (int)(currentPot * 0.55);

                        if (context.MoneyToCall == 0)
                        {
                            return(PlayerAction.Raise(moneyToBet));
                        }
                        else if (context.MoneyToCall < context.MoneyLeft / 20 || context.MoneyToCall < 50)
                        {
                            if (context.MoneyToCall < moneyToBet && context.MyMoneyInTheRound == 0)
                            {
                                return(PlayerAction.Raise(moneyToBet - context.MoneyToCall + 1));
                            }
                            else
                            {
                                return(PlayerAction.CheckOrCall());
                            }
                        }
                        else
                        {
                            return(this.Fold());
                        }
                    }
                    else if (ehs < 0.75)
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = (int)(currentPot * 0.75);

                        if (context.MoneyToCall == 0)
                        {
                            return(PlayerAction.Raise(moneyToBet));
                        }
                        else if (context.MoneyToCall < context.MoneyLeft / 10 || context.MoneyToCall < 70) // TODO:
                        {
                            if (context.MoneyToCall < moneyToBet && context.MyMoneyInTheRound == 0)
                            {
                                return(PlayerAction.Raise(moneyToBet - context.MoneyToCall + 1));
                            }
                            else
                            {
                                return(PlayerAction.CheckOrCall());
                            }
                        }
                        else
                        {
                            return(this.Fold());
                        }
                    }
                    else if (ehs < 0.85)
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = (int)(currentPot * 0.85);

                        if (context.MoneyToCall == 0)
                        {
                            if (moneyToBet < 50)
                            {
                                moneyToBet = 50;
                            }

                            return(PlayerAction.Raise(moneyToBet));
                        }
                        else if (context.MoneyToCall < context.MoneyLeft / 2 || context.MoneyToCall < 250)
                        {
                            if (context.MoneyToCall < moneyToBet && context.MyMoneyInTheRound == 0)
                            {
                                return(PlayerAction.Raise(moneyToBet - context.MoneyToCall + 1));
                            }
                            else
                            {
                                return(PlayerAction.CheckOrCall());
                            }
                        }
                        else
                        {
                            return(this.Fold());
                        }
                    }
                    else
                    {
                        var currentPot = context.CurrentPot;
                        int moneyToBet = currentPot;
                        if (moneyToBet < 80)
                        {
                            moneyToBet = 80;
                        }

                        return(PlayerAction.Raise(moneyToBet));
                    }
                }
            }
            #endregion

            return(PlayerAction.CheckOrCall()); // It should never reach this point
        }
コード例 #58
0
 public abstract PlayerAction GetTurn(GetTurnContext context);
コード例 #59
0
        private PlayerAction TurnLogic(GetTurnContext context)
        {
            if (isCallingStation && this.CurrentHandRank > HandRankType.Pair)
            {
                return PlayerAction.Raise((context.CurrentPot * 2) + MagicNumber);
            }

            if (this.CurrentHandRank >= HandRankType.TwoPairs)
            {
                if (this.lastAction < PlayerActionType.Raise)
                {
                    return PlayerAction.Raise(context.CurrentPot + MagicNumber);
                }

                if (this.CurrentHandRank >= HandRankType.Straight)
                {
                    return PlayerAction.Raise(AllIn(context.MoneyLeft));
                }

                return PlayerAction.CheckOrCall();
            }

            if (this.CurrentHandRank < HandRankType.Straight)
            {
                outs = this.CountOuts(this.hand, HandRankType.Straight);
            }

            if (outs > 11)
            {
                if (this.lastAction == PlayerActionType.Raise)
                {
                    if (context.MoneyToCall * 100 / context.CurrentPot < outs * 2)
                    {
                        if (isVeryAggressive)
                        {
                            return PlayerAction.Raise(AllIn(context.MoneyLeft));
                        }

                        return PlayerAction.CheckOrCall();
                    }

                    return PlayerAction.Fold();
                }

                return PlayerAction.Raise(((context.CurrentPot * 2) / 3) + MagicNumber);
            }

            if (isVeryAggressive && this.CurrentHandRank == HandRankType.Pair &&
                context.MoneyToCall <= context.CurrentPot * 2 / 3)
            {
                return PlayerAction.CheckOrCall();
            }

            if (outs < 8)
            {
                if (this.lastAction == PlayerActionType.Raise && context.MoneyToCall * 100 / context.CurrentPot > outs * 2)
                {
                    return PlayerAction.Fold();
                }
            }

            return PlayerAction.CheckOrCall();
        }
コード例 #60
0
        private PlayerAction RiverLogic(GetTurnContext context)
        {
            if (isCallingStation && this.CurrentHandRank > HandRankType.Pair &&
                this.lastAction < PlayerActionType.Raise)
            {
                return PlayerAction.Raise((context.CurrentPot * 2) - MagicNumber);
            }

            if (isVeryAggressive &&
                this.lastAction == PlayerActionType.Raise
                && context.MoneyToCall <= ((context.CurrentPot / 2) + 1))
            {
                if (this.FirstCard.Type >= CardType.King || this.SecondCard.Type >= CardType.King)
                {
                    return PlayerAction.CheckOrCall();
                }

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

            if (this.lastAction < PlayerActionType.Raise && !isCallingStation && !this.isAlwaysRaise)
            {
                return PlayerAction.Raise((context.CurrentPot / 3) + MagicNumber);
            }

            // TODO: add handrank
            if (this.lastAction == PlayerActionType.Raise)
            {
                if (this.CurrentHandRank >= HandRankType.Straight && this.CommunityImproved())
                {
                    return PlayerAction.Raise(context.CurrentPot + MagicNumber);
                }

                if (this.CurrentHandRank >= HandRankType.TwoPairs)
                {
                    return PlayerAction.CheckOrCall();
                }

                if (!isCallingStation && context.MoneyToCall <= context.CurrentPot / 2 && this.CurrentHandRank >= HandRankType.Pair)
                {
                    return PlayerAction.CheckOrCall();
                }

                return PlayerAction.Fold();
            }

            if (this.CurrentHandRank >= HandRankType.TwoPairs && this.CommunityImproved())
            {
                return PlayerAction.Raise(context.CurrentPot + MagicNumber);
            }

            return PlayerAction.CheckOrCall();
        }