Esempio n. 1
0
        public void CalculateShouldReturnPlausibleHandStrength3()
        {
            var handStrength = OddsCalculator.CalculateHandStrength(new List <Card>(), averagePlayerHand);

            //Assert.AreEqual(1, handStrength);
            Assert.IsTrue(handStrength <.6 && handStrength> .4);
        }
Esempio n. 2
0
        public virtual void StartRound(StartRoundContext context)
        {
            this.HandStrength = OddsCalculator.CalculateHandStrength(context.CommunityCards.ToList(), new List <Card> {
                this.FirstCard, this.SecondCard
            });

            this.CommunityCards = context.CommunityCards;
        }
Esempio n. 3
0
        public override void StartRound(StartRoundContext context)
        {
            this.HandStrength = OddsCalculator.CalculateHandStrength(context.CommunityCards.ToList(), new List <Card> {
                this.FirstCard, this.SecondCard
            });

            base.StartRound(context);
        }
Esempio n. 4
0
        public void GetDeckShouldRemoveProperAmountOfCards1()
        {
            var deck = OddsCalculator.GetDeck(new List <Card>(), new List <Card> {
                new Card(CardSuit.Club, CardType.Ace)
            });

            Assert.AreEqual(51, deck.Count);
        }
Esempio n. 5
0
        public void Play()
        {
            while (true)
            {
                while (!_eye.MyTurn())
                {
                    Thread.Sleep(2000);
                }

                var playerCards = _eye.GetPlayerCards();
                var tableCards  = _eye.GetTableCards();
                var hand        = new MyHand(playerCards, tableCards);

                Console.WriteLine($"Player Hand: {hand.BestCombination}");


                var playerCount = _eye.GetPlayerCount();

                double minimumCallAmount = _eye.GetMinimumCall();
                double potAmount         = _eye.GetPotAmount();


                if (!_eye.OnlyCall() && minimumCallAmount == 0)
                {
                    _control.Check();
                    Console.WriteLine("Checking");
                }
                else
                {
                    var potOdds = minimumCallAmount / (minimumCallAmount + potAmount) * 100;

                    double oddsOffset;

                    if (tableCards.Count == 0)
                    {
                        oddsOffset = (110 - minimumCallAmount) / 100;
                    }
                    else
                    {
                        oddsOffset = 0;
                    }


                    var winOdds = OddsCalculator.CalculateOdds(playerCards, tableCards, playerCount);


                    if (oddsOffset > 0)
                    {
                        winOdds *= 1 + oddsOffset;
                        Console.WriteLine($"Increasing Win Odds by {oddsOffset * 100:0,##}%");
                    }


                    Console.WriteLine($"Player {_id}: Pot Odds: {potOdds} | Odds of winning {winOdds}");

                    if (winOdds < potOdds)
                    {
                        Console.WriteLine("Folding");
                        _control.Fold();
                    }
                    else
                    {
                        Console.WriteLine("Calling");
                        if (_eye.OnlyCall())
                        {
                            _control.CallAll();
                        }
                        else
                        {
                            _control.Check();
                        }
                    }
                }

                Thread.Sleep(3000);
            }
        }
Esempio n. 6
0
 //------------------------------------------------------------------------------------
 /// <summary>
 /// Figure the odds for this hand
 /// </summary>
 //------------------------------------------------------------------------------------
 public OddsResults CalculateOdds(Deck deck, int playerCount)
 {
     return(OddsCalculator.Calculate(deck, _playerHand, playerCount, TimeSpan.FromMilliseconds(100)));
 }
Esempio n. 7
0
        public void CalculateShouldReturnPlausibleHandStrength1()
        {
            var handStrength = OddsCalculator.CalculateHandStrength(straightFlushCommunityCards, straightFlushPlayerCards);

            Assert.AreEqual(1, handStrength);
        }
Esempio n. 8
0
        public void GetDeckShouldRemoveProperAmountOfCards2()
        {
            var deck = OddsCalculator.GetDeck(straightFlushCommunityCards, straightFlushPlayerCards);

            Assert.AreEqual(45, deck.Count);
        }
        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.RateOfReturn < 1 && context.CanCheck == true)
            {
                return(PlayerAction.CheckOrCall());
            }

            // Fold in all win scenarios with weak hand
            if (context.IsAllIn && this.HandStrength < .5)
            {
                return(PlayerAction.Fold());
            }

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

            if (this.RateOfReturn <= NotPlayableThreshold)
            {
                if (decisionCoefficient <= .65)
                {
                    return(PlayerAction.Fold());
                }
                else
                {
                    return(PlayerAction.Raise(context.SmallBlind * 2));
                }
            }
            else if (this.RateOfReturn > NotPlayableThreshold && this.RateOfReturn <= NotReccomendedThreshold)
            {
                if (decisionCoefficient <= .3) // 0.8
                {
                    return(PlayerAction.Fold());
                }
                else if (decisionCoefficient > .3 && decisionCoefficient <= .65) // 0.80 - 0.85
                {
                    return(PlayerAction.CheckOrCall());
                }
                else
                {
                    return(PlayerAction.Raise(context.SmallBlind * 2));
                }
            }
            else if (this.RateOfReturn > NotReccomendedThreshold && this.RateOfReturn < PlayableThreshold)
            {
                if (decisionCoefficient <= .4)
                {
                    return(PlayerAction.CheckOrCall());
                }
                else
                {
                    return(PlayerAction.Raise(context.SmallBlind * 2));
                }
            }
            else
            {
                if (decisionCoefficient <= .1)
                {
                    return(PlayerAction.CheckOrCall());
                }
                else
                {
                    return(PlayerAction.Raise(context.SmallBlind * 2));
                }
            }
        }