public void IsNotStraight()
        {
            // 00000000 000//0.0000 0000.0000 0/000.0000 0001.00/01 0001.0001 000/1.0001 0001.0001
            long hand = 0x0000000001111111;

            Assert.False(CardsAnalyzer.IsStraight(hand), "Hand did not got a straight, straight not expected");
        }
        public void IsFullHouse()
        {
            // 00000000 0000//0000 0000.0000 1/000.0110 0000.00/10 0000.0000 001/1.0000 0000.0001
            long fullHouse = 0x0000008602003001;

            Assert.True(CardsAnalyzer.IsFullHouse(fullHouse), "Hand did got a full house, full house is expected");
        }
        public void HandIsNotAFlush()
        {
            // 00000000 000//0.0000 0000.0000 0/000.0000 0001.00/01 0001.0001 000/1.0001 0001.0001
            long hand = 0x0000000001111111;

            Assert.False(CardsAnalyzer.IsFlush(hand), "Hand did not got a flush, flush not expected");
        }
        public void HandHas52BitsSet()
        {
            // 0000.0000 0000//.0000 0000.0000 0/000.0000 0000.00/00 0100.0000 001/1.0000 0000.1110
            long hand = 0x000FFFFFFFFFFFFF;

            Assert.Equal(52, CardsAnalyzer.CountSetBits(hand));
        }
        public void CountAllCardsInAHand()
        {
            // 00000000 0000//0000 0000.0000 1/000.0000 0000.01/00 0000.0000 001/0.0000 0000.0001
            long hand = 0x0000008004002001;

            CardsAnalyzer.CountCards(hand);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Two]);
            // 00000000 000//0.0000 0000.0000 0/000.0000 0000.00/00 0000.0000 001/0.0010 0001.1111
            hand = 0x000000000000331F;
            CardsAnalyzer.CountCards(hand);
            Assert.Equal(2, CardsAnalyzer.CardsCount[(long)Card.CardName.Two]);
            Assert.Equal(1, CardsAnalyzer.CardsCount[(long)Card.CardName.Three]);
            Assert.Equal(1, CardsAnalyzer.CardsCount[(long)Card.CardName.Four]);
            Assert.Equal(1, CardsAnalyzer.CardsCount[(long)Card.CardName.Five]);
            Assert.Equal(1, CardsAnalyzer.CardsCount[(long)Card.CardName.Six]);
            Assert.Equal(1, CardsAnalyzer.CardsCount[(long)Card.CardName.Jack]);

            hand = 0x000FFFFFFFFFFFFF;
            CardsAnalyzer.CountCards(hand);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Two]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Three]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Four]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Five]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Six]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Seven]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Eight]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Nine]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Ten]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Jack]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Queen]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.King]);
            Assert.Equal(4, CardsAnalyzer.CardsCount[(long)Card.CardName.Ace]);
        }
        public void IsTwoPairs()
        {
            // 00000000 0000//0000 0000.0000 0/000.0010 0000.00/10 0100.0000 001/1.0010 0000.0001
            long twoPairs = 0x0000000602003001;

            Assert.True(CardsAnalyzer.IsTwoPairs(twoPairs), "Hand did got two pairs, two pairs are expected");
        }
        public void HandHas6BitsSet()
        {
            // 00000000 0000//0000 00000000 0/0000000 000000/00 01000000 001/10000 00001110
            long hand = 0x000000000040201E;

            Assert.Equal(6, CardsAnalyzer.CountSetBits(hand));
        }
        public void OnePair()
        {
            // 00000000 00000000 00000000 00000000 00000000 00000000 00100000 00000001
            long aPair = 0x0000000000002001;

            Assert.True(CardsAnalyzer.IsAPair(aPair), "Hand got a pair, pair expected");
        }
        public void NotOnePair()
        {
            // 00000000 00000000 00000000 10000000 00000101 00000000 00100000 00000111
            long aPair = 0x0000008005002007;

            Assert.False(CardsAnalyzer.IsAPair(aPair), "Hand got four of a kind, pair not expected");
        }
        public void NotThreeOfAKind()
        {
            // 00000000 00000000 00000000 10000000 00000101 00000000 00100000 00000111
            long threeOfAKind = 0x0000008005002007;

            Assert.False(CardsAnalyzer.IsThreeOfAKind(threeOfAKind), "Hand got four of a kind, three of a kind not expected");
        }
        public void ThreeOfAKind()
        {
            // 00000000 00000000 00000000 00000000 00000100 00000000 00100000 00000001
            long threeOfAKind = 0x0000000004002001;

            Assert.True(CardsAnalyzer.IsThreeOfAKind(threeOfAKind), "Hand got three of a kind, three of a kind expected");
        }
        public void NotFourOfAKind()
        {
            // 00000000 0000//0000 0000.0000 1/000.0000 0000.00/11 0000.0000 001/0.0000 0000.0001
            long notFourOfAKind = 0x0000008003002001;

            Assert.False(CardsAnalyzer.IsFourOfAKind(notFourOfAKind));
        }
        public void HandIsAFlush()
        {
            // 00000000 000//0.0000 0000.0000 0/000.0000 0000.00/00 0000.0000 001/0.0010 0001.1111
            long hand = 0x000000000000331F;

            Assert.True(CardsAnalyzer.IsFlush(hand), "Hand got a flush, flush expected");
        }
        public void IsStraightAndSpecialStraight()
        {
            // 00000000 000//0.0000 0000.0000 0/000.0000 0000.00/00 0000.0000 000/1.0001 0001.1111
            long hand = 0x000000000000111F;

            Assert.True(CardsAnalyzer.IsStraight(hand), "Hand got a straight, straight expected");
            // 00000000 000//0.0000 0000.0000 0/000.0000 0000.00/00 0000.0000 000/1.1001 0000.1111
            hand = 0x000000000000190F;
            Assert.True(CardsAnalyzer.IsStraight(hand), "Hand got a special straight (12345), straight expected");
        }
        public void IsNotFullHouse()
        {
            // 00000000 0000//0000 0000.0000 1/000.0000 0000.00/11 0000.0000 001/0.0000 0000.0111
            long notFullHouse = 0x0000008003002007;

            Assert.False(CardsAnalyzer.IsFullHouse(notFullHouse), "Hand did not got a full house, full house is not expected");
            // 00000000 0000//1000 0000.0000 0/100.0000 0000.01/10 0000.0000 001/1.0000 0000.0001
            notFullHouse = 0x0008004006003001;
            Assert.False(CardsAnalyzer.IsFullHouse(notFullHouse), "Hand got four of a kind, full house is not expected");
        }
Esempio n. 16
0
 public override bool Parse(PokerHand pokerHand)
 {
     pokerHand.Strength = Strength;
     CardsAnalyzer.SetHighCardsKickers(pokerHand.ToLong());
     pokerHand.Kickers.Add(new Card(CardsAnalyzer.Kickers[0]));
     pokerHand.Kickers.Add(new Card(CardsAnalyzer.Kickers[1]));
     pokerHand.Kickers.Add(new Card(CardsAnalyzer.Kickers[2]));
     pokerHand.Kickers.Add(new Card(CardsAnalyzer.Kickers[3]));
     pokerHand.Kickers.Add(new Card(CardsAnalyzer.Kickers[4]));
     return(true);
 }
        public void IsNotTwoPairs()
        {
            // 00000000 0000//0000 0000.0000 1/000.0000 0000.00/11 0000.0000 001/0.0000 0000.0001
            long notTwoPairs = 0x0000008003002001;

            Assert.False(CardsAnalyzer.IsTwoPairs(notTwoPairs), "Hand did not got a full house, full house is not expected");
            // Four of a kind + three of a kind
            // 00000000 0000//1000 0000.0000 0/100.0000 0000.01/10 0000.0000 001/1.0000 0000.0001
            notTwoPairs = 0x0008004006003001;
            Assert.False(CardsAnalyzer.IsTwoPairs(notTwoPairs), "Hand did not got a full house, full house is not expected");
        }
Esempio n. 18
0
        public override bool Parse(PokerHand pokerHand)
        {
            var result = false;

            if (CardsAnalyzer.IsStraight(pokerHand.ToLong()))
            {
                result             = true;
                pokerHand.Strength = Strength;
                pokerHand.Kickers.Add(new Card(CardsAnalyzer.Kickers[0]));
            }
            return(result);
        }
        public void FourOfAKind()
        {
            // 00000000 0000//0000 0000.0000 1/000.0000 0000.01/00 0000.0000 001/0.0000 0000.0001
            long fourOfAKind = 0x0000008004002001;

            Assert.True(CardsAnalyzer.IsFourOfAKind(fourOfAKind), "Hand got four of a kind only (all aces), four of a kind expected");
            // 00000000 0000//0000 0000.0000 1/000.0000 0000.01/01 0000.0000 001/0.0000 0000.0111
            fourOfAKind = 0x0000008005002007;
            Assert.True(CardsAnalyzer.IsFourOfAKind(fourOfAKind), "Hand got four of a kind among other cards, four of a kind expected");
            // 00000000 0000//1000 0000.0000 0/100.0000 0000.00/10 0000.0000 000/1.0000 0000.0000
            fourOfAKind = 0x0000008005002007;
            Assert.True(CardsAnalyzer.IsFourOfAKind(fourOfAKind), "Hand got four of a kind (all kings), four of a kind expected");
        }
        public void StraightFlush()
        {
            // 00000000 00000000 00000000 00000000 00000000 01000000 00100000 00011111
            long straightFlushHand = 0x000000000040201F;

            Assert.True(CardsAnalyzer.IsStraightFlush(straightFlushHand));
            straightFlushHand = 0x00000000004020F8;
            Assert.True(CardsAnalyzer.IsStraightFlush(straightFlushHand));
            straightFlushHand = 0x00000F8000000000;
            Assert.True(CardsAnalyzer.IsStraightFlush(straightFlushHand));
            straightFlushHand = 0x000F800000000000;
            Assert.True(CardsAnalyzer.IsStraightFlush(straightFlushHand));
            // 00000000 0000//0000 0000.0000 0/000.0000 0000.00/00 0100.0000 001/1.0000 0000.1111
            straightFlushHand = 0x000000000040300F;
            Assert.True(CardsAnalyzer.IsStraightFlush(straightFlushHand), "Hand got a `petite` straight flush i.e. 12345 ");
        }
Esempio n. 21
0
        private static void FindAllStraightFlush()
        {
            var num = 0;

            using (var sr = new StreamReader(@"poker-all-7-hands.txt"))
            {
                while (sr.Peek() >= 0)
                {
                    var hand = Convert.ToInt64(sr.ReadLine());
                    if (CardsAnalyzer.IsStraightFlush(hand))
                    {
                        num++;
                    }
                }
            }
            Console.WriteLine($"Done. {num} straight flush have been found.");
        }