예제 #1
0
        public void TestingAlgorithm_Calculate_Card_Power_FourOfAKind_ShouldPass()
        {
            ICard         aceOfSpades   = new Card(12, 'S');
            ICard         aceOfClubs    = new Card(12, 'C');
            ICard         aceOfDiamonds = new Card(12, 'D');
            ICard         aceOfHearths  = new Card(12, 'H');
            IHand         hand          = new Hand();
            IList <ICard> fourOfAKind   = new List <ICard>()
            {
                aceOfSpades, aceOfClubs, aceOfDiamonds, aceOfHearths
            };

            hand.CurrentCards = fourOfAKind;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(HandStrengthEnum.FourOfAKind, hand.Strength);
        }
예제 #2
0
        public void TestingAlgorithm_Calculate_Card_Power_FullHousePairFirst_ShouldPass()
        {
            ICard         card1       = new Card(10, 'S');
            ICard         card2       = new Card(10, 'S');
            ICard         card3       = new Card(12, 'S');
            ICard         card4       = new Card(12, 'S');
            ICard         card5       = new Card(12, 'S');
            IHand         hand        = new Hand();
            IList <ICard> combination = new List <ICard>()
            {
                card1, card2, card3, card4, card5
            };

            hand.CurrentCards = combination;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(HandStrengthEnum.FullHouse, hand.Strength);
        }
예제 #3
0
        public void TestingAlgorithm_Calculate_Card_Power_RoyalFlush_ShouldPass()
        {
            ICard         aceOfSpades   = new Card(12, 'S');
            ICard         kingOfSpades  = new Card(11, 'S');
            ICard         queenOfSpades = new Card(10, 'S');
            ICard         jokerOfSpades = new Card(9, 'S');
            ICard         tenOfSpades   = new Card(8, 'S');
            IHand         hand          = new Hand();
            IList <ICard> royalFlush    = new List <ICard>()
            {
                aceOfSpades, kingOfSpades, queenOfSpades, jokerOfSpades, tenOfSpades
            };

            hand.CurrentCards = royalFlush;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(HandStrengthEnum.RoyalFlush, hand.Strength);
        }
예제 #4
0
        public void TestingAlgorithm_Calculate_HighCardPower_2()
        {
            ICard         card1       = new Card(4, 'H');
            ICard         card2       = new Card(7, 'S');
            ICard         card3       = new Card(6, 'S');
            ICard         card4       = new Card(2, 'S');
            ICard         card5       = new Card(3, 'S');
            IHand         hand        = new Hand();
            IList <ICard> combination = new List <ICard>()
            {
                card1, card2, card3, card4, card5
            };

            hand.CurrentCards = combination;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(card2.Rank, hand.HighCard.Rank);
        }
예제 #5
0
        public void TestingAlgorithm_Calculate_HighCard_RoyalFlush_ShouldPass()
        {
            ICard         card1       = new Card(11, 'S');
            ICard         card2       = new Card(10, 'S');
            ICard         card3       = new Card(12, 'S');
            ICard         card4       = new Card(9, 'S');
            ICard         card5       = new Card(8, 'S');
            IHand         hand        = new Hand();
            IList <ICard> combination = new List <ICard>()
            {
                card1, card2, card3, card4, card5
            };

            hand.CurrentCards = combination;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(card3.Rank, hand.HighCard.Rank);
        }
예제 #6
0
        public void TestingAlgorithm_Calculate_Card_Power_StraightFlush_ShouldPass()
        {
            ICard         card1       = new Card(11, 'S');
            ICard         card2       = new Card(10, 'S');
            ICard         card3       = new Card(9, 'S');
            ICard         card4       = new Card(8, 'S');
            ICard         card5       = new Card(7, 'S');
            IHand         hand        = new Hand();
            IList <ICard> combination = new List <ICard>()
            {
                card1, card2, card3, card4, card5
            };

            hand.CurrentCards = combination;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(HandStrengthEnum.StraightFlush, hand.Strength);
        }
예제 #7
0
        public void TestingAlgorithm_Calculate_Card_Power_FlushNotSequential_ShouldPass()
        {
            ICard         card1       = new Card(12, 'S');
            ICard         card2       = new Card(9, 'S');
            ICard         card3       = new Card(5, 'H');
            ICard         card4       = new Card(10, 'H');
            ICard         card5       = new Card(5, 'S');
            ICard         card6       = new Card(9, 'S');
            ICard         card7       = new Card(2, 'S');
            IHand         hand        = new Hand();
            IList <ICard> combination = new List <ICard>()
            {
                card1, card2, card3, card4, card5, card6, card7
            };

            hand.CurrentCards = combination;
            CardPowerCalculator.GetCurrentStrengthOfCards(hand);
            Assert.AreEqual(HandStrengthEnum.Flush, hand.Strength);
        }
예제 #8
0
        /// <summary>
        /// Bot makes calculations and decides how to play his turn based on several factors
        /// </summary>
        /// <param name="currentHighestBet">The current highest bet on the board.</param>
        /// <param name="playersNotFolded">The number of players not folded.</param>
        /// <param name="canCheck">if set to <c>true</c> the bot [can check]
        /// (true only if no one has called or raised before him and the turn part is past the flop).</param>
        /// <param name="currentPartOfTurn">The current part of the turn.</param>
        /// <param name="randomBehavior">The random behavior that's one of the factors in the bots decision making.</param>
        public void PlayTurn(ref int currentHighestBet, int playersNotFolded, bool canCheck, TurnParts currentPartOfTurn, Random randomBehavior)
        {
            CardPowerCalculator.GetCurrentStrengthOfCards(this.Hand);
            int feelingLucky   = randomBehavior.Next(0, 100);
            int bluff          = randomBehavior.Next(0, 10);
            int turnPartFactor = (int)currentPartOfTurn * 40;

            if (this.CheckShouldRaise(playersNotFolded, turnPartFactor, feelingLucky, bluff))
            {
                this.Raise(currentHighestBet * 2, ref currentHighestBet);
            }
            else if (this.CheckShouldCall(playersNotFolded, turnPartFactor, feelingLucky, bluff))
            {
                this.Call(currentHighestBet);
            }
            else if (canCheck)
            {
                this.Check();
            }
            else
            {
                this.Fold();
            }
        }