public void ParseCollectedLine_MainPot_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseCollectedLine(@"bozzoTHEclow collected $245.23 from main pot", Street.Preflop);

            Assert.AreEqual(new WinningsAction("bozzoTHEclow", HandActionType.WINS, 245.23m, 0), handAction);
        }
예제 #2
0
        public void ParseRegularActionLine_Calls_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"MECO-LEO: calls $1.23", 8, Street.Turn);

            Assert.AreEqual(new HandAction("MECO-LEO", HandActionType.CALL, 1.23m, Street.Turn), handAction);
        }
예제 #3
0
        private void ProcessAnte(Ante ante, HandHistory handHistory)
        {
            var anteAmount = (decimal)ante.Amount / handHistory.Players.Count;

            handHistory.GameDescription.Limit.Ante        = anteAmount;
            handHistory.GameDescription.Limit.IsAnteTable = true;

            var sbAction = handHistory.HandActions.FirstOrDefault(x => x.HandActionType == HandActionType.SMALL_BLIND);

            IEnumerable <Player> players;

            if (sbAction != null)
            {
                players = handHistory.Players
                          .SkipWhile(x => x.PlayerName != sbAction.PlayerName)
                          .Concat(handHistory.Players.TakeWhile(x => x.PlayerName != sbAction.PlayerName))
                          .Reverse();
            }
            else
            {
                players = handHistory.Players.Reverse();
            }

            foreach (var player in players)
            {
                var anteAction = new HandAction(player.PlayerName,
                                                HandActionType.ANTE,
                                                anteAmount,
                                                Street.Preflop);

                handHistory.HandActions.Insert(0, anteAction);
            }
        }
예제 #4
0
        public void ParseRegularActionLine_Raise_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"chrisvb75: raises $2 to $3.55", 9, Street.Preflop);

            Assert.AreEqual(new HandAction("chrisvb75", HandActionType.RAISE, 3.55m, Street.Preflop), handAction);
        }
예제 #5
0
        public void ParseRegularActionLine_BetsAllIn_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"zeranex88: bets $3.03 and is all-in", 9, Street.Flop);

            Assert.AreEqual(new HandAction("zeranex88", HandActionType.BET, 3.03m, Street.Flop, true), handAction);
        }
예제 #6
0
        public void ParseMiscShowdownLine_Mucks_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseMiscShowdownLine(@"Fjell_konge: mucks hand", 11);

            Assert.AreEqual(new HandAction("Fjell_konge", HandActionType.MUCKS, 0m, Street.Showdown), handAction);
        }
예제 #7
0
        public void ParseRegularActionLine_RaisesReachesCap_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"WANGZHEGL: raises $7.10 to $9.01 and has reached the $10 cap", 9, Street.Preflop);

            Assert.AreEqual(new HandAction("WANGZHEGL", HandActionType.RAISE, 9.01m, Street.Preflop), handAction);
        }
예제 #8
0
        private static decimal GetRemainingStack(string playerName, HandAction action, HandHistory currentHandHistory)
        {
            var playerActions = currentHandHistory.HandActions.Take(currentHandHistory.HandActions.ToList().IndexOf(action) + 1).Where(x => x.PlayerName == playerName);
            var startingStack = currentHandHistory.Players.FirstOrDefault(x => x.PlayerName == playerName)?.StartingStack ?? 0;

            return(startingStack == 0 ? 0 : startingStack - playerActions.Sum(x => Math.Abs(x.Amount)));
        }
예제 #9
0
        public static string ActionToString(HandAction action)
        {
            if (action is StreetAction)
            {
                return(",");
            }

            if (action.IsRaise())
            {
                return("R");
            }

            if (action.IsCall())
            {
                return("C");
            }

            if (action.IsBet())
            {
                return("B");
            }

            if (action.HandActionType == HandActionType.FOLD)
            {
                return("F");
            }

            if (action.HandActionType == HandActionType.CHECK)
            {
                return("X");
            }

            return(string.Empty);
        }
예제 #10
0
        private void PlayOutHand(Hand hand)
        {
            HandAction action = strategy.DetermineActionForHand(Count, hand, upCard);

            while (action != HandAction.STAND)
            {
                action = strategy.DetermineActionForHand(Count, hand, upCard);
                switch (action)
                {
                case HandAction.HIT:
                    if (Hit(hand))
                    {
                        return;
                    }
                    else
                    {
                        break;
                    }

                case HandAction.SPLIT:
                    Split(hand);
                    PlayOutHand(hands[hands.Count - 1]);
                    PlayOutHand(hands[hands.Count - 2]);
                    return;

                case HandAction.DOUBLE_DOWN:
                    DoubleDown(hand);
                    return;
                }
            }
        }
예제 #11
0
        private List <HandAction> FixDeadMoneyPosting(List <HandAction> actions)
        {
            // sort the actions, because regular SB + BB actions are always the first actions ( although might not be the first in the hand history )
            actions = actions.OrderBy(t => t.ActionNumber).ToList();
            var bigBlindValue = 0.0m;
            var looper        = new List <HandAction>(actions);

            foreach (var action in looper)
            {
                if (action.HandActionType.Equals(HandActionType.BIG_BLIND))
                {
                    if (bigBlindValue == 0.0m)
                    {
                        bigBlindValue = Math.Abs(action.Amount);
                        continue;
                    }

                    if (Math.Abs(action.Amount) > bigBlindValue)
                    {
                        var newAction = new HandAction(action.PlayerName, HandActionType.POSTS, action.Amount, action.Street, action.ActionNumber);
                        actions.Remove(action);
                        actions.Add(newAction);
                    }
                }
            }

            return(actions);
        }
예제 #12
0
        protected override List <HandAction> ParseHandActions(string[] handLines, GameType gameType = GameType.Unknown)
        {
            List <HandAction> actions = new List <HandAction>();

            PlayerList playerList = ParsePlayers(handLines);

            XDocument document    = GetXDocumentFromLines(handLines);
            XElement  gameElement = GetGameElementFromXDocument(document);

            Street currentStreet = Street.Null;

            List <XElement> roundElements = gameElement.Elements("round").ToList();

            foreach (XElement roundElement in roundElements)
            {
                currentStreet = GetStreetFromRoundElement(roundElement);
                List <XElement> eventElements = roundElement.Elements("event").ToList();

                foreach (XElement eventElement in eventElements)
                {
                    HandAction action = GetHandActionFromEventElement(eventElement, currentStreet, playerList);
                    actions.Add(action);
                }
            }

            List <XElement> winnerElements = gameElement.Elements("round").Elements("winner").ToList();

            foreach (XElement winnerElement in winnerElements)
            {
                WinningsAction winningsAction = GetWinningsActionFromWinnerElement(winnerElement, playerList);
                actions.Add(winningsAction);
            }

            return(actions);
        }
        public void ParseCollectedLine_SidePot2()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseCollectedLine(@"CinderellaBD collected $7 from side pot-2", Street.Preflop);

            Assert.AreEqual(new WinningsAction("CinderellaBD", HandActionType.WINS_SIDE_POT, 7m, 2), handAction);
        }
        public void ParseCollectedLine_SidePot()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseCollectedLine(@"bozzoTHEclow collected $136.82 from side pot", Street.Preflop);

            Assert.AreEqual(new WinningsAction("bozzoTHEclow", HandActionType.WINS_SIDE_POT, 136.82m, 1), handAction);
        }
예제 #15
0
        public void ParseMiscShowdownLine_DoesntShow_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseMiscShowdownLine(@"woezelenpip: doesn't show hand", 11);

            Assert.AreEqual(new HandAction("woezelenpip", HandActionType.MUCKS, 0m, Street.Showdown), handAction);
        }
예제 #16
0
        protected virtual double DefineActionAmount(HandAction handAction, string inputLine)
        {
            var match  = ActionAmountRegex.Match(inputLine).Value;
            var amount = GetCleanAmount(match);

            switch (handAction.HandActionType)
            {
            case HandActionType.BET:
            case HandActionType.BIG_BLIND:
            case HandActionType.SMALL_BLIND:
            case HandActionType.DEAD_BLIND:
            case HandActionType.CALL:
            case HandActionType.ALL_IN_CALL:
            case HandActionType.ALL_IN_RAISE:
            case HandActionType.All_IN_BB:
            case HandActionType.All_IN_SB:
            case HandActionType.ANTE:
            case HandActionType.RAISE:
                return(-amount);

            case HandActionType.WINS:
            case HandActionType.WINS_SIDE_POT:
            case HandActionType.WINS_MAIN_POT:
                //case HandActionType.UNCALLED_BET:
                return(amount);
            }
            throw new Exception("Undefined amount action!");
        }
예제 #17
0
        public void ParseMiscShowdownLine_PloHiLo_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseMiscShowdownLine(@"DOT19: shows [As 8h Ac Kd] (HI: two pair, Aces and Sixes)", -1, GameType.PotLimitOmahaHiLo);

            Assert.AreEqual(new HandAction("DOT19", HandActionType.SHOW, 0m, Street.Showdown), handAction);
        }
예제 #18
0
        private static void CheckAllHandActionsForUncalled(IList <HandAction> handActions, int index)
        {
            var lastAgrassiveAction =
                handActions.LastOrDefault(ha => ha.HandActionType == HandActionType.BET || ha.HandActionType == HandActionType.RAISE ||
                                          ha.HandActionType == HandActionType.ALL_IN_RAISE);

            if (lastAgrassiveAction == null)
            {
                return;
            }
            var ind = handActions.IndexOf(lastAgrassiveAction);

            for (var i = ind; i < handActions.Count; i++)
            {
                if (handActions[i].HandActionType == HandActionType.CALL || handActions[i].HandActionType == HandActionType.ALL_IN_CALL)
                {
                    return;
                }
            }
            var uncalledBetHandAction = new HandAction
            {
                Index          = index,
                PlayerName     = lastAgrassiveAction.PlayerName,
                HandActionType = HandActionType.UNCALLED_BET,
                Street         = lastAgrassiveAction.Street,
                Amount         = -lastAgrassiveAction.Amount
            };

            handActions.Add(uncalledBetHandAction);
        }
예제 #19
0
        public void ParseMiscShowdownLine_Shows_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseMiscShowdownLine(@"RECHUK: shows [Ac Qh] (a full house, Aces full of Queens)", 6);

            Assert.AreEqual(new HandAction("RECHUK", HandActionType.SHOW, 0m, Street.Showdown), handAction);
        }
예제 #20
0
        public void ParseRegularActionLine_Checks_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"Piotr280688: checks", 11, Street.Turn);

            Assert.AreEqual(new HandAction("Piotr280688", HandActionType.CHECK, 0m, Street.Turn), handAction);
        }
예제 #21
0
        public void ParseRegularActionLine_BetsReachesCap_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"tzuiop23: bets $62.84 and has reached the $80 cap", 8, Street.Preflop);

            Assert.AreEqual(new HandAction("tzuiop23", HandActionType.BET, 62.84m, Street.Preflop), handAction);
        }
예제 #22
0
        public void ParseRegularActionLine_Bets_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"MS13ZEN: bets $1.76", 7, Street.River);

            Assert.AreEqual(new HandAction("MS13ZEN", HandActionType.BET, 1.76m, Street.River), handAction);
        }
예제 #23
0
        public void ParseRegularActionLine_RaiseAllIn_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"Piotr280688: raises $8.32 to $12.88 and is all-in", 11, Street.Flop);

            Assert.AreEqual(new HandAction("Piotr280688", HandActionType.RAISE, 12.88m, Street.Flop, true), handAction);
        }
예제 #24
0
        public void ParsePostingActionLine_PostDead_Works()
        {
            //fertre: posts small & big blinds $0.75
            HandAction handAction = Parser.ParsePostingActionLine(@"fertre: posts small & big blinds $1.75", 6, true, true);

            Assert.AreEqual(new HandAction("fertre", HandActionType.POSTS, 1.75m, Street.Preflop), handAction);
        }
예제 #25
0
        public void ParseRegularActionLine_CallsAllIn_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"Fjell_konge: calls $7.56 and is all-in", 11, Street.Flop);

            Assert.AreEqual(new HandAction("Fjell_konge", HandActionType.CALL, 7.56m, Street.Flop, true), handAction);
        }
예제 #26
0
        public void ParseRegularActionLine_Folds_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseRegularActionLine(@"gaydaddy: folds", 8, Street.Preflop);

            Assert.AreEqual(new HandAction("gaydaddy", HandActionType.FOLD, 0, Street.Preflop), handAction);
        }
예제 #27
0
        public static decimal GetFacingBetSizePot(PlayerstatisticExtended playerstatistic, Street targetStreet)
        {
            if (targetStreet == Street.Flop || targetStreet == Street.Turn || targetStreet == Street.River)
            {
                HandAction betAction =
                    playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet)
                    .SkipWhile(x => !x.IsBet())
                    .TakeWhile(x => x.PlayerName != playerstatistic.Playerstatistic.PlayerName)
                    .LastOrDefault(x => x.IsBet() || x.IsRaise());

                if (betAction == null || betAction.PlayerName == playerstatistic.Playerstatistic.PlayerName)
                {
                    return(-1);
                }

                HandAction heroAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet)
                                        .SkipWhile(x => x != betAction)
                                        .FirstOrDefault(x => x != betAction && x.HandActionType != HandActionType.FOLD || x.PlayerName == playerstatistic.Playerstatistic.PlayerName);


                if (heroAction?.PlayerName == playerstatistic.Playerstatistic.PlayerName)
                {
                    return(ONE_HUNDRED_PERCENTS * Math.Abs(betAction.Amount) / playerstatistic.HandHistory.HandActions.TakeWhile(x => x != heroAction).Sum(x => Math.Abs(x.Amount)));
                }
            }

            return(-1);
        }
예제 #28
0
        public void ParseUncalledBetLine_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseUncalledBetLine(@"Uncalled bet ($6) returned to woeze lenpip", Street.Preflop);

            Assert.AreEqual(new HandAction("woeze lenpip", HandActionType.UNCALLED_BET, 6, Street.Preflop), handAction);
        }
        private List <HandAction> GetWinningAndShowCardActions(string[] handLines)
        {
            int actionNumber = Int32.MaxValue - 100;

            PlayerList playerList = ParsePlayers(handLines);

            var winningAndShowCardActions = new List <HandAction>();

            foreach (Player player in playerList)
            {
                if (player.hasHoleCards)
                {
                    HandAction showCardsAction = new HandAction(player.PlayerName, HandActionType.SHOW, 0, Street.Showdown, actionNumber++);
                    winningAndShowCardActions.Add(showCardsAction);
                }
            }

            string[] playerLines = GetPlayerLinesFromHandLines(handLines);
            for (int i = 0; i < playerLines.Length; i++)
            {
                string  playerLine = playerLines[i];
                decimal winnings   = GetWinningsFromPlayerLine(playerLine);
                if (winnings > 0)
                {
                    string         playerName     = GetNameFromPlayerLine(playerLine);
                    WinningsAction winningsAction = new WinningsAction(playerName, HandActionType.WINS, winnings, 0, actionNumber++);
                    winningAndShowCardActions.Add(winningsAction);
                }
            }

            return(winningAndShowCardActions);
        }
        public void ParseCollectedLine_WithColon_Works()
        {
            HandAction handAction =
                GetPokerStarsFastParser().ParseCollectedLine(@"wo_olly :D collected $0.57 from pot", Street.Preflop);

            Assert.AreEqual(new WinningsAction("wo_olly :D", HandActionType.WINS, 0.57m, 0), handAction);
        }