예제 #1
0
        public void TestOpenEndedBeatNutsTextureAnalyzer()
        {
            var analyzer = new OpenEndedBeatNutsTextureAnalyzer();

            var item3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 1, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.EqualTo, "")
            };

            /* true */
            var boardCards  = BoardCards.FromCards("6s 8s 5s 9s");
            var boardCards2 = BoardCards.FromCards("Js 8s 2s Ts 9h");
            var boardCards3 = BoardCards.FromCards("5s 4s Js 2s");
            var boardCards4 = BoardCards.FromCards("8s 6s 4s 8h 4h");
            var boardCards5 = BoardCards.FromCards("Ks Ts 8s 7s As");
            var boardCards8 = BoardCards.FromCards("3s 5h As 5s 2s");


            /* false */
            var boardCards6 = BoardCards.FromCards("8s Ks Qs 7s Js");
            var boardCards7 = BoardCards.FromCards("3s Ks 7s Qs Kh");

            Assert.That(analyzer.Analyze(boardCards, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards3, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards4, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards5, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards6, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, item3), Is.True);
        }
        public void ParseCommunityCardsTest(string handHistoryFile, string expectedBoard)
        {
            BoardCards expectedCards = BoardCards.FromCards(expectedBoard);
            var        handHistory   = ParseHandHistory(handHistoryFile);

            Assert.AreEqual(handHistory.CommunityCards, expectedCards);
        }
예제 #3
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            // Expect the end of the hand to have something like this:
            //------ Summary ------
            //Pot: 80. Rake 2
            //Board: [3d 6h 2c Ah]

            BoardCards boardCards = BoardCards.ForPreflop();

            for (int lineNumber = handLines.Length - 4; lineNumber >= 0; lineNumber--)
            {
                string line = handLines[lineNumber];
                if (line[0] == '-')
                {
                    return(boardCards);
                }

                if (line[0] != 'B')
                {
                    continue;
                }

                const int firstSquareBracketEnd = 8;
                int       lastSquareBracket     = line.Length - 1;

                return(BoardCards.FromCards(line.Substring(firstSquareBracketEnd, lastSquareBracket - firstSquareBracketEnd).Replace("10", "T")));
            }

            throw new CardException(string.Empty, "Read through hand backwards and didn't find a board or summary.");
        }
예제 #4
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            for (int i = handLines.Length - 1; i >= 0; i--)
            {
                string handLine = handLines[i];

                if (string.IsNullOrWhiteSpace(handLine))
                {
                    continue;
                }

                if (handLine.StartsWith("Dealer:"))
                {
                    break;
                }

                if (handLine.StartsWith("River ") || handLine.StartsWith("Flop ") || handLine.StartsWith("Turn "))
                {
                    int    firstSpaceIndex = handLine.IndexOf(' ');
                    string board           = handLine.Substring(firstSpaceIndex, handLine.Length - firstSpaceIndex);

                    return(BoardCards.FromCards(board.Replace(" ", "").Replace("-", "")));
                }
            }

            return(BoardCards.ForPreflop());
        }
예제 #5
0
        /// <summary>
        /// Parses community cards
        /// </summary>
        /// <param name="handLines">Lines of hand history to parse</param>
        /// <returns>Community cards</returns>
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            var boardCards = BoardCards.ForPreflop();

            for (var i = handLines.Length - 1; i > 0; i--)
            {
                if (handLines[i].StartsWith("Board: ", StringComparison.OrdinalIgnoreCase))
                {
                    var cardText = handLines[i].TakeBetween("[", "]", true);

                    if (string.IsNullOrEmpty(cardText))
                    {
                        throw new CardException(handLines[i], "Could not parse community cards.");
                    }

                    boardCards.AddCards(BoardCards.FromCards(cardText));
                }
                else if (handLines[i].StartsWith("***", StringComparison.Ordinal))
                {
                    break;
                }
            }

            return(boardCards);
        }
예제 #6
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            // Expect the end of the hand to have something like this:
            //*** SUMMARY ***
            //Total pot $90 | Rake $2.80
            //Board [4s 7d Ad]
            //Seat 4: TopKat5757 (small blind) folded before Flop
            //Seat 5: Masic.Almir (big blind) folded before Flop

            BoardCards boardCards = BoardCards.ForPreflop();

            for (int lineNumber = handLines.Length - 2; lineNumber >= 0; lineNumber--)
            {
                string line = handLines[lineNumber];
                if (line[0] == '*')
                {
                    return(boardCards);
                }

                if (line[0] != 'B')
                {
                    continue;
                }

                int firstSquareBracket = 6;
                int lastSquareBracket  = line.Length - 1;

                return
                    (BoardCards.FromCards(line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1))));
            }

            throw new CardException(string.Empty, "Read through hand backwards and didn't find a board or summary.");
        }
예제 #7
0
        private void ParseSummaryRoomStateChange(SCGameRoomStateChange startRoomStateChange, HandHistory handHistory, long heroId)
        {
            var gameRoomInfo      = GetGameRoomInfo(startRoomStateChange, handHistory);
            var userGameInfos     = GetUserGameInfos(gameRoomInfo, handHistory);
            var gameResultInfo    = gameRoomInfo.GameResultInfo ?? throw new HandBuilderException(handHistory.HandId, "GameResultInfo has not been found.");
            var gamePotResultInfo = gameResultInfo.GamePotResultInfo ?? throw new HandBuilderException(handHistory.HandId, "GamePotResultInfo has not been found.");

            if (gameResultInfo.OriginalUserStacks == null || gameResultInfo.OriginalUserStacks.Length != userGameInfos.Length)
            {
                throw new HandBuilderException(handHistory.HandId, "OriginalUserStacks are empty or has wrong length.");
            }

            // update original stacks
            for (var seat = 0; seat < userGameInfos.Length; seat++)
            {
                if (!userGameInfos[seat].IsActive)
                {
                    continue;
                }

                var player = AddOrUpdatePlayer(userGameInfos[seat], seat + 1, handHistory, heroId);
                player.StartingStack = gameResultInfo.OriginalUserStacks[seat];
            }

            // parse win amounts
            for (var potResultNum = 0; potResultNum < gamePotResultInfo.Length; potResultNum++)
            {
                var userWinners = gamePotResultInfo[potResultNum].UserWiner;
                var userPots    = gamePotResultInfo[potResultNum].UserPots;

                if (userWinners.Length != userPots.Length)
                {
                    throw new HandBuilderException(handHistory.HandId, "UserWinners length isn't equal to UserPots length.");
                }

                for (var winnerNum = 0; winnerNum < userWinners.Length; winnerNum++)
                {
                    var userWinner = userWinners[winnerNum];

                    var winner = handHistory.Players[userWinner.ShowID];

                    if (winner == null)
                    {
                        throw new HandBuilderException(handHistory.HandId, $"UserWinner [{userWinner.ShowID}] has not been found in the player list.");
                    }

                    winner.Win += userPots[winnerNum];
                }
            }

            // parse community cards
            if (gameRoomInfo.CurrentCards != null && gameRoomInfo.CurrentCards.Length > 0)
            {
                handHistory.CommunityCards = BoardCards.FromCards(gameRoomInfo
                                                                  .CurrentCards
                                                                  .Select(c => Card.GetPMCardFromIntValue(c))
                                                                  .ToArray());
            }
        }
예제 #8
0
        public void SpecialCards()
        {
            var expectedBoard = BoardCards.FromCards("4dKs2hTcKd");

            var actualBoard = GetExtraHand("SpecialCards").CommunityCards;

            Assert.AreEqual(expectedBoard, actualBoard);
        }
예제 #9
0
        private static BoardCards ParseBoard(string line)
        {
            int firstSquareBracket = 7;
            int lastSquareBracket  = line.Length - 1;

            string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1));

            return(BoardCards.FromCards(cards));
        }
예제 #10
0
        /// <summary>
        /// Determines if board contains enough cards to display specified street
        /// </summary>
        /// <param name="boardCards"></param>
        /// <param name="street"></param>
        /// <returns></returns>
        public static bool IsStreetAvailable(string boardCards, Street street)
        {
            if (string.IsNullOrEmpty(boardCards))
            {
                return(false);
            }

            return(IsStreetAvailable(BoardCards.FromCards(boardCards), street));
        }
예제 #11
0
        public void TestGutShotBeatNutsTextureAnalyzer()
        {
            var analyzer = new GutShotBeatNutsTextureAnalyzer();

            var item3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 3, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.EqualTo, "")
            };
            var itemLessThan3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 3, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.LessThan, "")
            };
            var item2 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 1, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.EqualTo, "")
            };

            /* 3 */
            var boardCards  = BoardCards.FromCards("6s 8s 5s 9s");
            var boardCards2 = BoardCards.FromCards("Js 8s 2s Ts 9s");
            var boardCards3 = BoardCards.FromCards("2s 5s Js 4s");
            var boardCards4 = BoardCards.FromCards("5s 4s Js 2h 3h");
            var boardCards5 = BoardCards.FromCards("2s Ts Js 8s 7s");
            var boardCards6 = BoardCards.FromCards("4s 6s 7s 2s 5s");

            /* less than 3 */
            var boardCards7 = BoardCards.FromCards("3s 8s 6s 4s 4h");
            var boardCards8 = BoardCards.FromCards("Qs Qh 9s Js 5s");

            Assert.That(analyzer.Analyze(boardCards, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards3, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards4, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards5, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards6, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards7, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards8, item3), Is.False);

            Assert.That(analyzer.Analyze(boardCards, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards5, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards6, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, itemLessThan3), Is.True);

            Assert.That(analyzer.Analyze(boardCards, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards5, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards6, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, item2), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, item2), Is.True);
        }
예제 #12
0
        public void TestMadeStraightTextureAnalyzer()
        {
            var analyzer = new MadeStraightTextureAnalyzer();

            var item3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 3, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.EqualTo, "")
            };
            var itemLessThan3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 3, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.LessThan, "")
            };
            var itemGreaterThan2 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Turn, SelectedNumber = 2, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.GreaterThan, "")
            };

            /* 3 */
            var boardCards  = BoardCards.FromCards("Ks Qs 8s Js 4s"); // !
            var boardCards2 = BoardCards.FromCards("6s 5s 7s 5h");
            var boardCards3 = BoardCards.FromCards("3s 8s 6s 4s 4h"); // !
            var boardCards4 = BoardCards.FromCards("6s 4s 5s Qh 3h");
            var boardCards5 = BoardCards.FromCards("Qs 8s 7s 6s 6h");

            /* less than 3*/
            var boardCards6 = BoardCards.FromCards("4s 2s 6s 2h");
            var boardCards7 = BoardCards.FromCards("Qs 2s 3s 2h");
            var boardCards8 = BoardCards.FromCards("6s 2h Ks 2d 2s");

            Assert.That(analyzer.Analyze(boardCards, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards3, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards5, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards6, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, item3), Is.False);

            Assert.That(analyzer.Analyze(boardCards, itemLessThan3), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemLessThan3), Is.True);
            Assert.That(analyzer.Analyze(boardCards4, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards5, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards6, itemLessThan3), Is.True);
            Assert.That(analyzer.Analyze(boardCards7, itemLessThan3), Is.True);
            Assert.That(analyzer.Analyze(boardCards8, itemLessThan3), Is.True);

            Assert.That(analyzer.Analyze(boardCards, itemGreaterThan2), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards3, itemGreaterThan2), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards5, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards6, itemGreaterThan2), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, itemGreaterThan2), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, itemGreaterThan2), Is.False);
        }
예제 #13
0
        public void TestOpenEndedStraightTextureAnalyzer()
        {
            var analyzer = new OpenEndedStraightTextureAnalyzer();

            var item3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Flop, SelectedNumber = 3, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.EqualTo, "")
            };
            var itemLessThan3 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Flop, SelectedNumber = 3, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.LessThan, "")
            };
            var itemGreaterThan2 = new StraightBoardTextureItem()
            {
                TargetStreet = Street.Flop, SelectedNumber = 2, SelectedSign = new KeyValuePair <Model.Enums.EnumEquality, string>(Model.Enums.EnumEquality.GreaterThan, "")
            };

            /* 3 */
            var boardCards  = BoardCards.FromCards("8s 3s 6s");
            var boardCards2 = BoardCards.FromCards("3s 8s 6s");
            var boardCards3 = BoardCards.FromCards("8s 5s Ts");
            var boardCards4 = BoardCards.FromCards("8s 6s 4s 8h 4h");
            var boardCards5 = BoardCards.FromCards("Ks Ts 8s 7s As");

            /* less than 3*/
            var boardCards6 = BoardCards.FromCards("8s Ks Qs 7s Js");
            var boardCards7 = BoardCards.FromCards("3s Ks 7s Qs Kh");
            var boardCards8 = BoardCards.FromCards("3s 5h As 5s 2s");

            Assert.That(analyzer.Analyze(boardCards, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards3, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards4, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards5, item3), Is.True);
            Assert.That(analyzer.Analyze(boardCards6, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, item3), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, item3), Is.False);

            Assert.That(analyzer.Analyze(boardCards, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards2, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards4, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards5, itemLessThan3), Is.False);
            Assert.That(analyzer.Analyze(boardCards6, itemLessThan3), Is.True);
            Assert.That(analyzer.Analyze(boardCards7, itemLessThan3), Is.True);
            Assert.That(analyzer.Analyze(boardCards8, itemLessThan3), Is.True);

            Assert.That(analyzer.Analyze(boardCards, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards3, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards4, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards5, itemGreaterThan2), Is.True);
            Assert.That(analyzer.Analyze(boardCards6, itemGreaterThan2), Is.False);
            Assert.That(analyzer.Analyze(boardCards7, itemGreaterThan2), Is.False);
            Assert.That(analyzer.Analyze(boardCards8, itemGreaterThan2), Is.False);
        }
예제 #14
0
        public void TryParseCardsTest(string cardsString, string expectedCards, bool expectedResult)
        {
            var result = PokerBaaziUtils.TryParseCards(cardsString, out HandHistories.Objects.Cards.Card[] cards);

            Assert.That(result, Is.EqualTo(expectedResult));

            var boardCards = BoardCards.FromCards(cards);

            Assert.That(boardCards.ToString(), Is.EqualTo(expectedCards));
        }
예제 #15
0
        public void OmahaEquityCalcTest(string boardCards, bool isHiLo, float[] equity)
        {
            BoardCards board = BoardCards.FromCards(boardCards);
            var        cards = GetHoleCards().Select(x => CardGroup.Parse(x).Select(c => c.ToString()).ToArray()).ToArray();
            OmahaEquityCalculatorMain calc = new OmahaEquityCalculatorMain(true, isHiLo);

            var result = calc.Equity(board.Select(x => x.ToString()).ToArray(), cards, new string[] { }, 0);

            var i = 0;
        }
예제 #16
0
        private void ProcessCommunityCards(CommunityCardInfo communityCardInfo, HandHistory handHistory)
        {
            if (communityCardInfo.CommunityCard == null || communityCardInfo.CommunityCard.CommunityCards == null)
            {
                throw new HandBuilderException("Community cards must be not null.");
            }

            var boardCards = string.Join(string.Empty, communityCardInfo.CommunityCard.CommunityCards.Select(x => x.ToString()));

            handHistory.CommunityCards = BoardCards.FromCards(boardCards);
        }
예제 #17
0
        protected void RunItTwiceTest(List <HandAction> expectedActions, string expectedBoardString, string name)
        {
            BoardCards expectedBoard = BoardCards.FromCards(expectedBoardString);

            string handText = SampleHandHistoryRepository.GetHandExample(PokerFormat.CashGame, Site, "RunItTwiceTests", name);

            HandHistory actualHand = GetParser().ParseFullHandHistory(handText, true);

            Assert.AreEqual(expectedBoard, actualHand.RunItTwiceData.Board);
            Assert.AreEqual(expectedActions, actualHand.RunItTwiceData.Actions);
        }
        protected override BoardCards ParseCommunityCards(List <string> summary)
        {
            var board = summary[1];

            if (!(board.StartsWithFast("Board [") && board.EndsWith(']')))
            {
                return(BoardCards.ForPreflop());
            }
            board = board.SubstringBetween(7, board.Length - 1);
            return(BoardCards.FromCards(board));
        }
예제 #19
0
        public HandHistory Deserialize(string json)
        {
            var         jhand = JsonConvert.DeserializeObject <JSON_hand>(json);
            HandHistory hand  = new HandHistory();

            ReadGameInfo(hand, jhand.gameinfo);
            ReadPlayers(hand, jhand.players);
            ReadActions(hand, jhand.actions);
            ReadWinner(hand, jhand.winners);
            hand.CommunityCards = BoardCards.FromCards(jhand.board);
            return(hand);
        }
예제 #20
0
        public void TestFlushOnBoardTextureAnalyzer()
        {
            var analyzer = new FlushOnBoardTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.River
            };
            var boardCards  = BoardCards.FromCards("4s 5s 6s 7s 8s");
            var boardCards2 = BoardCards.FromCards("4s 5s 7d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
        }
        public bool Analyze(string boardCardsString, IEnumerable <BoardCardItem> targetCards)
        {
            if (string.IsNullOrEmpty(boardCardsString))
            {
                return(false);
            }

            var board = BoardCards.FromCards(boardCardsString);
            List <BoardCardItem> boardCards = new List <BoardCardItem>();

            foreach (var card in board)
            {
                boardCards.Add(new BoardCardItem()
                {
                    Suit = new RangeCardSuit().StringToSuit(card.Suit), Rank = new RangeCardRank().StringToRank(card.Rank)
                });
            }

            if (boardCards == null || boardCards.Count() == 0 || targetCards == null || targetCards.Count() == 0 || boardCards.Count() < targetCards.Count())
            {
                return(false);
            }

            int cardsCount = CardHelper.GetCardsAmountForStreet(targetCards.First().TargetStreet);
            var boardList  = boardCards.Take(cardsCount).ToList();

            foreach (var card in targetCards.Where(x => x.Rank != RangeCardRank.None))
            {
                var boardCard = boardList.FirstOrDefault(x => x.Rank == card.Rank && x.Suit == card.Suit);
                if (boardCard == null)
                {
                    return(false);
                }

                boardList.Remove(boardCard);
            }

            foreach (var card in targetCards.Where(x => x.Rank == RangeCardRank.None))
            {
                var boardCard = boardList.FirstOrDefault(x => x.Suit == card.Suit);
                if (boardCard == null)
                {
                    return(false);
                }

                boardList.Remove(boardCard);
            }

            return(true);
        }
예제 #22
0
        public void TestThreeToneTextureAnalyzer()
        {
            var analyzer = new ThreeToneTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.Flop
            };
            var boardCards  = BoardCards.FromCards("4s 5c 6d");
            var boardCards2 = BoardCards.FromCards("4s 5d 7d");
            var boardCards3 = BoardCards.FromCards("4s 6c 7d 8c");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.True);
        }
예제 #23
0
        public void TestMonotoneTextureAnalyzer()
        {
            var analyzer = new MonotoneTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.Flop
            };
            var boardCards  = BoardCards.FromCards("4s 5s 6s");
            var boardCards2 = BoardCards.FromCards("4s 5s 7c");
            var boardCards3 = BoardCards.FromCards("4s 6s 7s 6d");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.True);
        }
예제 #24
0
        public void TestNoPairTextureAnalyzer()
        {
            var analyzer = new NoPairTextureAnalyzer();
            var item     = new BoardTextureItem()
            {
                TargetStreet = Street.Turn
            };
            var boardCards  = BoardCards.FromCards("4s 5s 6s 7s 7d");
            var boardCards2 = BoardCards.FromCards("4s 7s 7d 7c 9s");
            var boardCards3 = BoardCards.FromCards("4s 7s 7d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.True);
        }
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            List <Card> boardCards = new List <Card>();

            /*
             * <cards type="Flop" player="">D6 S9 S7</cards>
             * <cards type="Turn" player="">H8</cards>
             * <cards type="River" player="">D5</cards>
             * <cards type="Pocket" player="pepealas5">CA CK</cards>
             */

            List <string> cardLines = GetCardLinesFromHandLines(handLines);

            for (int i = 0; i < cardLines.Count; i++)
            {
                string handLine = cardLines[i];
                handLine = handLine.TrimStart();

                //To make sure we know the exact character location of each card, turn 10s into Ts (these are recognized by our parser)
                handLine = handLine.Replace("10", "T");

                //The suit/ranks are reversed, so we need to reverse them when adding them to our board card string
                int  typeIndex  = handLine.IndexOfFast("e=\"");
                char streetChar = handLine[typeIndex + 3];

                int cardsStartIndex = handLine.LastIndexOf('>', handLine.Length - 9) + 1;
                //Flop
                if (streetChar == 'F')
                {
                    boardCards.Add(new Card(handLine[cardsStartIndex + 1], handLine[cardsStartIndex]));
                    boardCards.Add(new Card(handLine[cardsStartIndex + 4], handLine[cardsStartIndex + 3]));
                    boardCards.Add(new Card(handLine[cardsStartIndex + 7], handLine[cardsStartIndex + 6]));
                }
                //Turn
                if (streetChar == 'T')
                {
                    boardCards.Add(new Card(handLine[cardsStartIndex + 1], handLine[cardsStartIndex]));
                }
                //River
                if (streetChar == 'R')
                {
                    boardCards.Add(new Card(handLine[cardsStartIndex + 1], handLine[cardsStartIndex]));
                    break;
                }
            }

            return(BoardCards.FromCards(boardCards.ToArray()));
        }
예제 #26
0
        public void TestTwoFlushDrawsTextureAnalyzer()
        {
            var analyzer = new TwoFlushDrawsTextureAnalyzer();

            var item = new BoardTextureItem()
            {
                TargetStreet = Street.Turn
            };
            var boardCards  = BoardCards.FromCards("4d 5s 6d 7s");
            var boardCards2 = BoardCards.FromCards("4s 5d 7c 8c");
            var boardCards3 = BoardCards.FromCards("4s 6s 7d 6c 8c");

            Assert.That(analyzer.Analyze(boardCards, item), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, item), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, item), Is.False);
        }
예제 #27
0
        protected override BoardCards ParseCommunityCards(JObject JSON)
        {
            var handJSON    = JSON["history"][0];
            var actionsJSON = handJSON["action"];

            var lastBoardJSON = actionsJSON.LastOrDefault(p => p["type"].ToString() == "HAND_BOARD");

            if (lastBoardJSON == null)
            {
                return(BoardCards.ForPreflop());
            }

            var cards = lastBoardJSON["card"].Select(ParseCard);

            return(BoardCards.FromCards(cards.ToArray()));
        }
예제 #28
0
        public void TestFullHouseTextureAnalyzer()
        {
            var analyzer = new FullHouseTextureAnalyzer();

            var itemRiver = new BoardTextureItem()
            {
                TargetStreet = Street.River
            };

            var boardCards  = BoardCards.FromCards("5c 5s 7s 7d 5h");
            var boardCards2 = BoardCards.FromCards("7h 7s 7d 7c 4c");
            var boardCards3 = BoardCards.FromCards("4s 8h 8d 8s 9s");

            Assert.That(analyzer.Analyze(boardCards, itemRiver), Is.True);
            Assert.That(analyzer.Analyze(boardCards2, itemRiver), Is.False);
            Assert.That(analyzer.Analyze(boardCards3, itemRiver), Is.False);
        }
예제 #29
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            XDocument document    = GetXDocumentFromLines(handLines);
            XElement  gameElement = GetGameElementFromXDocument(document);
            IEnumerable <XElement> cardElements = gameElement.Elements("round").Elements("cards");

            //Find the last <card> element with type="community". This will have our board card list as its cards attribute value
            XElement lastCardElement = cardElements.LastOrDefault(element => element.Attribute("type").Value[0] == 'C');

            if (lastCardElement == null)
            {
                return(BoardCards.ForPreflop());
            }

            string boardCards = lastCardElement.Attribute("cards").Value;

            return(BoardCards.FromCards(boardCards));
        }
예제 #30
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            string[] cardLines = GetCardLinesFromHandLines(handLines);

            string boardCards = "";

            for (int i = 0; i < cardLines.Length; i++)
            {
                string handLine = cardLines[i];
                handLine = handLine.TrimStart();

                //To make sure we know the exact character location of each card, turn 10s into Ts (these are recognized by our parser)
                handLine = handLine.Replace("value=\"10\"", "value=\"T\"");

                boardCards += new Card(handLine[13], handLine[22]);
            }

            return(BoardCards.FromCards(boardCards));
        }