From 4636e244ea99eff81248afb36aa5c39ea58bfcb3 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Sun, 31 Jan 2010 17:58:48 +0100 Subject: [PATCH 1/8] Codec errors seem to lock up HUD with windows. I've made a trap for each error that I observed. don't want to halt the program so I return the original string. The de/recoding is not needed for >95% of the playernames anyway. --- pyfpdb/Charset.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Charset.py b/pyfpdb/Charset.py index 6b5e6b7c..02b5c098 100644 --- a/pyfpdb/Charset.py +++ b/pyfpdb/Charset.py @@ -41,7 +41,13 @@ def to_utf8(s): return _out except UnicodeDecodeError: sys.stderr.write('Could not convert: "%s"\n' % s) - raise + return s + except UnicodeEncodeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s + except TypeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s def to_db_utf8(s): if not_needed2: return s @@ -51,7 +57,13 @@ def to_db_utf8(s): return _out except UnicodeDecodeError: sys.stderr.write('Could not convert: "%s"\n' % s) - raise + return s + except UnicodeEncodeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s + except TypeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s def to_gui(s): if not_needed3: return s @@ -61,5 +73,11 @@ def to_gui(s): return _out except UnicodeDecodeError: sys.stderr.write('Could not convert: "%s"\n' % s) - raise + return s + except UnicodeEncodeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s + except TypeError: + sys.stderr.write('Could not convert: "%s"\n' % s) + return s From 0db3cecf650c65ad4cd57a421a5cc91e83c18f89 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Sat, 13 Feb 2010 20:41:01 +0100 Subject: [PATCH 2/8] Action Reg_ex updated Due to the added end of line marker to eliminate playersnames that start with card, all-in actions are no longer supported. --- pyfpdb/PokerStarsToFpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 90a8bfd0..39eb0892 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -102,7 +102,7 @@ class PokerStars(HandHistoryConverter): self.re_HeroCards = re.compile(r"^Dealt to %(PLYR)s(?: \[(?P.+?)\])?( \[(?P.+?)\])" % subst, re.MULTILINE) self.re_Action = re.compile(r""" ^%(PLYR)s:(?P\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat) - (\s(%(CUR)s)?(?P[.\d]+))?(\sto\s%(CUR)s(?P[.\d]+))? # the number discarded goes in + (\s(%(CUR)s)?(?P[.\d]+))?(\sto\s%(CUR)s(?P[.\d]+))?(\sand\sis\sall-in)? # the number discarded goes in (\scards?(\s\[(?P.+?)\])?)?$""" % subst, re.MULTILINE|re.VERBOSE) self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P.*)\]" % player_re, re.MULTILINE) From 466988ea4acc1736358bcdca234ee56c5478b111 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Sat, 13 Feb 2010 22:44:00 +0100 Subject: [PATCH 3/8] Tournement support for PartyPoker --- pyfpdb/PartyPokerToFpdb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfpdb/PartyPokerToFpdb.py b/pyfpdb/PartyPokerToFpdb.py index 1d1d0e4d..5fdeae0c 100755 --- a/pyfpdb/PartyPokerToFpdb.py +++ b/pyfpdb/PartyPokerToFpdb.py @@ -465,8 +465,9 @@ class PartyPoker(HandHistoryConverter): def getTableTitleRe(type, table_name=None, tournament = None, table_number=None): "Returns string to search in windows titles" if type=="tour": - print 'party', 'getTableTitleRe', "%s.+Table\s#%s" % (table_name, table_number) - return "%s.+Table\s#%s" % (table_name, table_number) + TableName = table_name.split(" ") + print 'party', 'getTableTitleRe', "%s.+Table\s#%s" % (TableName[0], table_number) + return "%s.+Table\s#%s" % (TableName[0], table_number) else: print 'party', 'getTableTitleRe', table_number return table_name From a27bc45f6dbc2bb954f98c991ae86a7458ef7bbf Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 18 Feb 2010 16:17:08 +0100 Subject: [PATCH 4/8] fix for dead blinds and antes in the player stat calculation Posted dead blinds messed up the rake and profit calculation in the player stats. This fix should also work for antes The fix has been done for omaha and holdem game types (without antes) I don't have draw or stud hands to check this --- pyfpdb/DerivedStats.py | 2 +- pyfpdb/Hand.py | 36 ++++++++++++++++++++---------------- pyfpdb/PokerStarsToFpdb.py | 18 ++++++++---------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 166034a5..32c7c874 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -162,7 +162,7 @@ class DerivedStats(): self.handsplayers[player]['wonAtSD'] = 1.0 for player in hand.pot.committed: - self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player])) + self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player])- (100*hand.pot.common[player])) self.calcCBets(hand) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 73dd7600..c5e2dea7 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -321,8 +321,10 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio self.stacks[player] -= Decimal(ante) act = (player, 'posts', "ante", ante, self.stacks[player]==0) self.actions['BLINDSANTES'].append(act) - self.pot.addMoney(player, Decimal(ante)) - +# self.pot.addMoney(player, Decimal(ante)) + self.pot.addCommonMoney(player, Decimal(ante)) +#I think the antes should be common money, don't have enough hand history to check + def addBlind(self, player, blindtype, amount): # if player is None, it's a missing small blind. # The situation we need to cover are: @@ -340,9 +342,12 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio self.actions['BLINDSANTES'].append(act) if blindtype == 'both': - amount = self.bb - self.bets['BLINDSANTES'][player].append(Decimal(self.sb)) - self.pot.addCommonMoney(Decimal(self.sb)) + # work with the real ammount. limit games are listed as $1, $2, where + # the SB 0.50 and the BB is $1, after the turn the minimum bet amount is $2.... + amount = Decimal(amount)/3 + self.bets['BLINDSANTES'][player].append(amount) + self.pot.addCommonMoney(player, amount) + amount += amount self.bets['PREFLOP'][player].append(Decimal(amount)) self.pot.addMoney(player, Decimal(amount)) @@ -504,10 +509,7 @@ Card ranks will be uppercased self.totalcollected = 0; #self.collected looks like [[p1,amount][px,amount]] for entry in self.collected: - self.totalcollected += Decimal(entry[1]) - - - + self.totalcollected += Decimal(entry[1]) def getGameTypeAsString(self): """\ @@ -986,11 +988,12 @@ class DrawHand(Hand): self.lastBet['DEAL'] = Decimal(amount) elif blindtype == 'both': # extra small blind is 'dead' - self.lastBet['DEAL'] = Decimal(self.bb) + amount = Decimal(amount)/3 + amount += amount + self.lastBet['DEAL'] = Decimal(amount) self.posted = self.posted + [[player,blindtype]] #print "DEBUG: self.posted: %s" %(self.posted) - def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False): if player == self.hero: # we have hero's cards just update shown/mucked if shown: self.shown.add(player) @@ -1405,7 +1408,7 @@ class Pot(object): self.contenders = set() self.committed = {} self.streettotals = {} - self.common = Decimal(0) + self.common = {} self.total = None self.returned = {} self.sym = u'$' # this is the default currency symbol @@ -1415,13 +1418,14 @@ class Pot(object): def addPlayer(self,player): self.committed[player] = Decimal(0) + self.common[player] = Decimal(0) def addFold(self, player): # addFold must be called when a player folds self.contenders.discard(player) - def addCommonMoney(self, amount): - self.common += amount + def addCommonMoney(self, player, amount): + self.common[player] += amount def addMoney(self, player, amount): # addMoney must be called for any actions that put money in the pot, in the order they occur @@ -1429,7 +1433,7 @@ class Pot(object): self.committed[player] += amount def markTotal(self, street): - self.streettotals[street] = sum(self.committed.values()) + self.common + self.streettotals[street] = sum(self.committed.values()) + sum(self.common.values()) def getTotalAtStreet(self, street): if street in self.streettotals: @@ -1437,7 +1441,7 @@ class Pot(object): return 0 def end(self): - self.total = sum(self.committed.values()) + self.common + self.total = sum(self.committed.values()) + sum(self.common.values()) # Return any uncalled bet. committed = sorted([ (v,k) for (k,v) in self.committed.items()]) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 39066b8e..6874c708 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -287,16 +287,14 @@ class PokerStars(HandHistoryConverter): hand.addBringIn(m.group('PNAME'), m.group('BRINGIN')) def readBlinds(self, hand): - try: - count = 0 - for a in self.re_PostSB.finditer(hand.handText): - if count == 0: - hand.addBlind(a.group('PNAME'), 'small blind', a.group('SB')) - count = 1 - else: - hand.addAnte(a.group('PNAME'), a.group('SB')) - except: # no small blind - hand.addBlind(None, None, None) + liveBlind = True + for a in self.re_PostSB.finditer(hand.handText): + if liveBlind: + hand.addBlind(a.group('PNAME'), 'small blind', a.group('SB')) + liveBlind = False + else: + # Post dead blinds as ante + hand.addAnte(a.group('PNAME'), a.group('SB')) for a in self.re_PostBB.finditer(hand.handText): hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB')) for a in self.re_PostBoth.finditer(hand.handText): From 35a604dcc6094fd4cedb6a53e0100ef29d09b244 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 18 Feb 2010 16:39:51 +0100 Subject: [PATCH 5/8] Add support for posting dead small blind --- pyfpdb/FulltiltToFpdb.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index af55fd41..4ee12fa4 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -128,6 +128,7 @@ class Fulltilt(HandHistoryConverter): player_re = "(?P" + "|".join(map(re.escape, players)) + ")" logging.debug("player_re: " + player_re) self.re_PostSB = re.compile(r"^%s posts the small blind of \$?(?P[.0-9]+)" % player_re, re.MULTILINE) + self.re_PostDead = re.compile(r"^%s posts a dead small blind of \$?(?P[.0-9]+)" % player_re, re.MULTILINE) self.re_PostBB = re.compile(r"^%s posts (the big blind of )?\$?(?P[.0-9]+)" % player_re, re.MULTILINE) self.re_Antes = re.compile(r"^%s antes \$?(?P[.0-9]+)" % player_re, re.MULTILINE) self.re_BringIn = re.compile(r"^%s brings in for \$?(?P[.0-9]+)" % player_re, re.MULTILINE) @@ -298,6 +299,8 @@ class Fulltilt(HandHistoryConverter): hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB')) except: # no small blind hand.addBlind(None, None, None) + for a in self.re_PostDead.finditer(hand.handText): + hand.addAnte(a.group('PNAME'), a.group('SB')) for a in self.re_PostBB.finditer(hand.handText): hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB')) for a in self.re_PostBoth.finditer(hand.handText): From 6272c057b93fadf675159414e31d4db7ea0739b4 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 18 Feb 2010 22:12:01 +0100 Subject: [PATCH 6/8] Pokerstar Big and Small blind for limit games now derived form lookup table. This also needs to be done for PokerStars, don't know for the other sites.... --- pyfpdb/Hand.py | 11 +++++------ pyfpdb/PokerStarsToFpdb.py | 30 ++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 262ac4ad..b740a341 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -344,15 +344,14 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio if blindtype == 'both': # work with the real ammount. limit games are listed as $1, $2, where # the SB 0.50 and the BB is $1, after the turn the minimum bet amount is $2.... - amount = Decimal(amount)/3 - self.bets['BLINDSANTES'][player].append(amount) - self.pot.addCommonMoney(player, amount) - amount += amount + amount = self.bb + self.bets['BLINDSANTES'][player].append(Decimal(self.sb)) + self.pot.addCommonMoney(player, Decimal(self.sb)) if blindtype == 'secondsb': amount = Decimal(0) self.bets['BLINDSANTES'][player].append(Decimal(self.sb)) - self.pot.addCommonMoney(Decimal(self.sb)) + self.pot.addCommonMoney(player, Decimal(self.sb)) self.bets['PREFLOP'][player].append(Decimal(amount)) self.pot.addMoney(player, Decimal(amount)) @@ -1450,7 +1449,7 @@ class Pot(object): # Return any uncalled bet. committed = sorted([ (v,k) for (k,v) in self.committed.items()]) - print "DEBUG: committed: %s" % committed + #print "DEBUG: committed: %s" % committed #ERROR below. lastbet is correct in most cases, but wrong when # additional money is committed to the pot in cash games # due to an additional sb being posted. (Speculate that diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 87574e9d..8c222e12 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -140,6 +140,14 @@ class PokerStars(HandHistoryConverter): mg = m.groupdict() # translations from captured groups to fpdb info strings + Lim_Blinds = { '0.04': ('0.01', '0.02'), '0.10': ('0.02', '0.05'), '0.20': ('0.05', '0.10'), + '0.50': ('0.10', '0.25'), '1.00': ('0.25', '0.50'), '2.00': ('0.50', '1.00'), + '4.00': ('1.00', '2.00'), '6.00': ('1.00', '3.00'), '10.00': ('2.00', '5.00'), + '20.00': ('5.00', '10.00'), '30.00': ('10.00', '15.00'), '60.00': ('15.00', '30.00'), + '100.00': ('25.00', '50.00'),'200.00': ('50.00', '100.00'),'400.00': ('100.00', '200.00'), + '1000.00': ('250.00', '500.00')} + + limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' } games = { # base, category "Hold'em" : ('hold','holdem'), @@ -173,6 +181,10 @@ class PokerStars(HandHistoryConverter): else: info['type'] = 'tour' + if info['limitType'] == 'fl' and info['bb'] != None: + info['sb'] = Lim_Blinds[mg['BB']][0] + info['bb'] = Lim_Blinds[mg['BB']][1] + # NB: SB, BB must be interpreted as blinds or bets depending on limit type. return info @@ -287,16 +299,14 @@ class PokerStars(HandHistoryConverter): hand.addBringIn(m.group('PNAME'), m.group('BRINGIN')) def readBlinds(self, hand): - try: - count = 0 - for a in self.re_PostSB.finditer(hand.handText): - if count == 0: - hand.addBlind(a.group('PNAME'), 'small blind', a.group('SB')) - count = 1 - else: - hand.addBlind(a.group('PNAME'), 'secondsb', a.group('SB')) - except: # no small blind - hand.addBlind(None, None, None) + liveBlind = True + for a in self.re_PostSB.finditer(hand.handText): + if liveBlind: + hand.addBlind(a.group('PNAME'), 'small blind', a.group('SB')) + liveBlind = False + else: + # Post dead blinds as ante + hand.addBlind(a.group('PNAME'), 'secondsb', a.group('SB')) for a in self.re_PostBB.finditer(hand.handText): hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB')) for a in self.re_PostBoth.finditer(hand.handText): From aceb94d26055cf05bd7fdbbda74eb9bb712d5489 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 18 Feb 2010 22:24:25 +0100 Subject: [PATCH 7/8] Oops... Lookup is only for ring games.... --- pyfpdb/PokerStarsToFpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 8c222e12..946d5ea2 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -181,7 +181,7 @@ class PokerStars(HandHistoryConverter): else: info['type'] = 'tour' - if info['limitType'] == 'fl' and info['bb'] != None: + if info['limitType'] == 'fl' and info['bb'] != None and info['type'] == 'ring': info['sb'] = Lim_Blinds[mg['BB']][0] info['bb'] = Lim_Blinds[mg['BB']][1] From af6dbc8d5fffda420f27ea9a37a58f2dcbfb95c6 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 18 Feb 2010 22:32:53 +0100 Subject: [PATCH 8/8] Copied same dead blind procedure from Pokerstars to Full Tilt --- pyfpdb/FulltiltToFpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index 4ee12fa4..2a3050ab 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -300,7 +300,7 @@ class Fulltilt(HandHistoryConverter): except: # no small blind hand.addBlind(None, None, None) for a in self.re_PostDead.finditer(hand.handText): - hand.addAnte(a.group('PNAME'), a.group('SB')) + hand.addBlind(a.group('PNAME'), 'secondsb', a.group('SB')) for a in self.re_PostBB.finditer(hand.handText): hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB')) for a in self.re_PostBoth.finditer(hand.handText):