public PlayerAction GetNextAction()
        {
            EVCalculator  ev        = new EVCalculator(_pokerGame, _pokerGame.Settings);
            List <Card>   evalCards = GetCardsToEvaluate();
            List <double> ExpectedValues;
            double        mtcWin  = 0,
                          mtcLoss = 0;

            if (_pokerGame.CurrentRoundNumber() > 1)
            {
                ExpectedValues = new List <double>(ev.CalculateMonteCarlo(_player.Cards, _pokerGame.Hand, _pokerGame.Settings));
                mtcWin         = ExpectedValues[0];
                mtcLoss        = ExpectedValues[1];
            }

            if (_pokerGame.CurrentRoundNumber() == 1)
            {
                return(PreFlop());
            }
            if (_pokerGame.CurrentRoundNumber() == 2 || _pokerGame.CurrentRoundNumber() == 3)
            {
                return(FlopTurn(mtcWin, mtcLoss));
            }
            if (_pokerGame.CurrentRoundNumber() == 4)
            {
                return(River(mtcWin, mtcLoss));
            }

            return(CheckFold());
        }
Esempio n. 2
0
        private PlayerAction MonteCarloOld()
        {
            WinConditions  wc = new WinConditions();
            RangeParser    rc = new RangeParser();
            EVCalculator   ev = new EVCalculator(_pokerGame, _settings);
            OutsCalculator oc = new OutsCalculator();

            List <string> RaisePreflop = new List <string>
            {
                "88+", "A2s+", "K5s+", "Q8s+", "J9s+", "T9s+", "98s", "87s", "A10o+", "K9o+", "Q9o+", "J9o+", "T9o"
            };
            List <string> CallPreflop = new List <string>
            {
                "22+", "A2s+", "K2s+", "Q2s+", "J2s+", "T6s+", "97s+", "87s", "A2o+", "K2o+", "Q2o+", "J9o+", "T9o"
            };

            List <Card> cardsToEvaluate = new List <Card>(_player.Cards);

            cardsToEvaluate.AddRange(_street);

            var handsToRaisePreflop = rc.Parse(RaisePreflop);
            var handsToCallPreflop  = rc.Parse(CallPreflop).Except(handsToRaisePreflop).ToList();
            var cardHand            = _player.Cards;

            List <double> ExpectedValues =
                new List <double>(ev.CalculateMonteCarlo(cardHand, _hand, _settings));

            var mtcBet  = ExpectedValues[0];
            var mtcCall = 0.00;

            if (ExpectedValues.Count > 1)
            {
                mtcCall = ExpectedValues[1];
            }

            if (_pokerGame.CurrentRoundNumber() == 1)
            {
                if (ContainsCardHand(handsToRaisePreflop, cardHand))
                {
                    if (_player.IsSmallBlind)
                    {
                        if (_pokerGame.CanRaise())
                        {
                            return(PlayerAction.Raise);
                        }

                        if (_pokerGame.CanCall())
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }

                if (ContainsCardHand(handsToCallPreflop, cardHand))
                {
                    if (_pokerGame.CanCall())
                    {
                        return(PlayerAction.Call);
                    }
                }
            }
            else if (_pokerGame.CurrentRoundNumber() == 2 || _pokerGame.CurrentRoundNumber() == 3)
            {
                // Flop + Turn

                var currentScore = wc.Evaluate(cardsToEvaluate);
                var compareOuts  = oc.CompareOuts(_player.Cards, _street);

                if (currentScore <= Score.Pair)
                {
                    if (_pokerGame.CanCall() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }

                    if (_pokerGame.CanCheck() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }


                    if (_pokerGame.CanCall() && !_pokerGame.CanCheck())
                    {
                        if (mtcBet > 0.00)
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }


                if (compareOuts > 0)
                {
                    if (oc.CompareOuts(cardHand, _street) > 5)
                    {
                        if (_pokerGame.CanRaise())
                        {
                            return(PlayerAction.Raise);
                        }

                        if (_pokerGame.CanCall())
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }
            }
            else if (_pokerGame.CurrentRoundNumber() == 4)
            {
                var currentScore = wc.Evaluate(cardsToEvaluate);

                if (currentScore >= Score.Pair)
                {
                    if (_pokerGame.CanCall() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }

                    if (_pokerGame.CanCheck() && _pokerGame.CanRaise())
                    {
                        if (mtcBet > mtcCall)
                        {
                            return(PlayerAction.Raise);
                        }

                        return(PlayerAction.Call);
                    }


                    if (_pokerGame.CanCall() && !_pokerGame.CanCheck())
                    {
                        if (mtcBet > 0.00)
                        {
                            return(PlayerAction.Call);
                        }
                    }
                }
            }

            if (_pokerGame.CanCheck())
            {
                return(PlayerAction.Check);
            }

            return(PlayerAction.Fold);
        }