Absolute hhc: fixes, cleanups, basic trny support
This commit is contained in:
parent
d09aa716f4
commit
79bfc8587e
|
@ -40,24 +40,48 @@ class Absolute(HandHistoryConverter):
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_SplitHands = re.compile(r"\n\n\n+")
|
re_SplitHands = re.compile(r"\n\n\n+")
|
||||||
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
||||||
#Stage #1571362962: Holdem No Limit $0.02 - 2009-08-05 15:24:06 (ET)
|
#Stage #1571362962: Holdem No Limit $0.02 - 2009-08-05 15:24:06 (ET)
|
||||||
#Table: TORONTO AVE (Real Money) Seat #6 is the dealer
|
#Table: TORONTO AVE (Real Money) Seat #6 is the dealer
|
||||||
#Seat 6 - FETS63 ($0.75 in chips)
|
#Seat 6 - FETS63 ($0.75 in chips)
|
||||||
#Board [10s 5d Kh Qh 8c]
|
#Board [10s 5d Kh Qh 8c]
|
||||||
|
|
||||||
re_GameInfo = re.compile(ur"""^Stage #(C?[0-9]+):\s+
|
re_GameInfo = re.compile( ur"""
|
||||||
(?P<GAME>Holdem|Seven\sCard\sHi\/L|HORSE)
|
^Stage\s+\#C?(?P<HID>[0-9]+):?\s+
|
||||||
(?:\s\(1\son\s1\)|)?\s+?
|
(?:Tourney\ ID\ (?P<TRNY_ID>\d+)\s+)?
|
||||||
(?P<LIMIT>No Limit|Pot\sLimit|Normal|)?\s?
|
(?P<GAME>Holdem|Seven\ Card\ Hi\/L|HORSE)\s+
|
||||||
|
(?P<TRNY_TYPE>\(1\son\s1\)|Single\ Tournament|)\s*
|
||||||
|
(?P<LIMIT>No\ Limit|Pot\ Limit|Normal|)\s?
|
||||||
(?P<CURRENCY>\$|\s€|)
|
(?P<CURRENCY>\$|\s€|)
|
||||||
(?P<SB>[.0-9]+)/?(?:\$|\s€|)(?P<BB>[.0-9]+)?
|
(?P<SB>[.0-9]+)/?(?:\$|\s€|)(?P<BB>[.0-9]+)?
|
||||||
""", re.MULTILINE|re.VERBOSE)
|
\s+-\s+
|
||||||
re_HorseGameInfo = re.compile(ur"^Game Type: (?P<LIMIT>Limit) (?P<GAME>Holdem)", re.MULTILINE)
|
(?P<DATETIME>\d\d\d\d-\d\d-\d\d\ \d\d:\d\d:\d\d)\s+
|
||||||
# TODO: can set max seats via (1 on 1) to a known 2 ..
|
(?: \( (?P<TZ>[A-Z]+) \)\s+ )?
|
||||||
re_HandInfo = re.compile(ur"^Stage #C?(?P<HID>[0-9]+): .*(?P<DATETIME>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\n(Table: (?P<TABLE>.*) \(Real Money\))?", re.MULTILINE)
|
.*?
|
||||||
re_TableFromFilename = re.compile(ur".*IHH([0-9]+) (?P<TABLE>.*) -") # on HORSE STUD games, the table name isn't in the hand info!
|
(Table:\ (?P<TABLE>.*?)\ \(Real\ Money\))?
|
||||||
re_Button = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE) # TODO: that's not the right way to match for "dead" dealer is it?
|
""", re.MULTILINE|re.VERBOSE|re.DOTALL)
|
||||||
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) \((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)", re.MULTILINE)
|
|
||||||
|
re_HorseGameInfo = re.compile(
|
||||||
|
ur"^Game Type: (?P<LIMIT>Limit) (?P<GAME>Holdem)",
|
||||||
|
re.MULTILINE)
|
||||||
|
|
||||||
|
re_HandInfo = re_GameInfo
|
||||||
|
|
||||||
|
# on HORSE STUD games, the table name isn't in the hand info!
|
||||||
|
re_RingInfoFromFilename = re.compile(ur".*IHH([0-9]+) (?P<TABLE>.*) -")
|
||||||
|
re_TrnyInfoFromFilename = re.compile(
|
||||||
|
ur".*IHH ([0-9]+) (?P<TRNY_NAME>.*) "\
|
||||||
|
"ID (?P<TRNY_ID>\d+) \((?P<TABLE>\d+)\) .* "\
|
||||||
|
"(?:\$|\s€|)(?P<BUYIN>[0-9.]+)\s*\+\s*(?:\$|\s€|)(?P<FEE>[0-9.]+)"
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: that's not the right way to match for "dead" dealer is it?
|
||||||
|
re_Button = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE)
|
||||||
|
|
||||||
|
re_PlayerInfo = re.compile(
|
||||||
|
ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) "\
|
||||||
|
"\((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)",
|
||||||
|
re.MULTILINE)
|
||||||
|
|
||||||
re_Board = re.compile(ur"\[(?P<CARDS>[^\]]*)\]? *$", re.MULTILINE)
|
re_Board = re.compile(ur"\[(?P<CARDS>[^\]]*)\]? *$", re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,27 +98,19 @@ class Absolute(HandHistoryConverter):
|
||||||
# TODO: Absolute posting when coming in new: %s - Posts $0.02 .. should that be a new Post line? where do we need to add support for that? *confused*
|
# TODO: Absolute posting when coming in new: %s - Posts $0.02 .. should that be a new Post line? where do we need to add support for that? *confused*
|
||||||
self.re_PostBoth = re.compile(ur"^%s - Posts dead (?:\$| €|)(?P<SBBB>[0-9]*[.0-9]+)" % player_re, re.MULTILINE)
|
self.re_PostBoth = re.compile(ur"^%s - Posts dead (?:\$| €|)(?P<SBBB>[0-9]*[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
self.re_Action = re.compile(ur"^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re, re.MULTILINE)
|
self.re_Action = re.compile(ur"^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re, re.MULTILINE)
|
||||||
# print "^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re
|
|
||||||
self.re_ShowdownAction = re.compile(ur"^%s - Shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
self.re_ShowdownAction = re.compile(ur"^%s - Shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
self.re_CollectPot = re.compile(ur"^Seat [0-9]: %s(?: \(dealer\)|)(?: \(big blind\)| \(small blind\)|) (?:won|collected) Total \((?:\$| €|)(?P<POT>[0-9]*[.0-9]+)\)" % player_re, re.MULTILINE)
|
self.re_CollectPot = re.compile(ur"^Seat [0-9]: %s(?: \(dealer\)|)(?: \(big blind\)| \(small blind\)|) (?:won|collected) Total \((?:\$| €|)(?P<POT>[0-9]*[.0-9]+)\)" % player_re, re.MULTILINE)
|
||||||
#self.re_PostSB = re.compile(ur"^%s: posts small blind \[(?:\$| €|) (?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
||||||
#self.re_PostBB = re.compile(ur"^%s: posts big blind \[(?:\$| €|) (?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
||||||
#self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[(?:\$| €|) (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
|
||||||
self.re_Antes = re.compile(ur"^%s - Ante \[(?:\$| €|)(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
self.re_Antes = re.compile(ur"^%s - Ante \[(?:\$| €|)(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
|
#self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
|
||||||
self.re_HeroCards = re.compile(ur"^Dealt to %s \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
self.re_HeroCards = re.compile(ur"^Dealt to %s \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
#self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.\d]+) (USD|EUR|)\])?" % player_re, re.MULTILINE)
|
|
||||||
#self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds| complete to)(\s\[?(?:\$| €|) ?(?P<BET>\d+\.?\d*)\.?\s?(USD|EUR|)\]?)?" % player_re, re.MULTILINE)
|
|
||||||
#self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
|
||||||
#self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P<POT>[.\d]+) (USD|EUR|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
|
||||||
#self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE)
|
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
return [["ring", "hold", "nl"],
|
return [["ring", "hold", "nl"],
|
||||||
["ring", "hold", "pl"],
|
["ring", "hold", "pl"],
|
||||||
["ring", "hold", "fl"],
|
["ring", "hold", "fl"],
|
||||||
["ring", "studhi", "fl"],
|
["ring", "studhi", "fl"],
|
||||||
["ring", "omahahi", "pl"]
|
["ring", "omahahi", "pl"],
|
||||||
|
["tour", "hold", "nl"],
|
||||||
]
|
]
|
||||||
|
|
||||||
def determineGameType(self, handText):
|
def determineGameType(self, handText):
|
||||||
|
@ -102,7 +118,9 @@ class Absolute(HandHistoryConverter):
|
||||||
'type' in ('ring', 'tour')
|
'type' in ('ring', 'tour')
|
||||||
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
||||||
'base' in ('hold', 'stud', 'draw')
|
'base' in ('hold', 'stud', 'draw')
|
||||||
'category' in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
|
'category' in ('holdem', 'omahahi', omahahilo', 'razz',
|
||||||
|
'studhi', 'studhilo', 'fivedraw', '27_1draw',
|
||||||
|
'27_3draw', 'badugi')
|
||||||
'hilo' in ('h','l','s')
|
'hilo' in ('h','l','s')
|
||||||
'smallBlind' int?
|
'smallBlind' int?
|
||||||
'bigBlind' int?
|
'bigBlind' int?
|
||||||
|
@ -149,44 +167,61 @@ class Absolute(HandHistoryConverter):
|
||||||
(info['base'], info['category']) = games[mg['GAME']]
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
if 'LIMIT' in mg:
|
if 'LIMIT' in mg:
|
||||||
info['limitType'] = limits[mg['LIMIT']]
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
if 'SB' in mg:
|
|
||||||
info['sb'] = mg['SB']
|
|
||||||
else:
|
|
||||||
info['sb'] = str(float(mg['BB']) * 0.5) # TODO: Apparently AP doesn't provide small blind info!? must search to see if it's posted, I guess
|
|
||||||
if 'BB' in mg:
|
|
||||||
info['bb'] = mg['BB']
|
|
||||||
if 'CURRENCY' in mg:
|
if 'CURRENCY' in mg:
|
||||||
info['currency'] = currencies[mg['CURRENCY']]
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
if info['currency'] == 'T$':
|
if info['currency'] == 'T$':
|
||||||
info['type'] = 'tour'
|
info['type'] = 'tour'
|
||||||
|
if 'SB' in mg:
|
||||||
|
info['sb'] = mg['SB']
|
||||||
|
if 'BB' in mg:
|
||||||
|
info['bb'] = mg['BB']
|
||||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
if info['bb'] is None:
|
if info['bb'] is None:
|
||||||
info['bb'] = mg['SB']
|
info['bb'] = mg['SB']
|
||||||
info['sb'] = str(float(mg['SB']) * 0.5) # TODO: AP does provide Small BET for Limit .. I think? at least 1-on-1 limit they do.. sigh
|
info['sb'] = str(float(mg['SB']) * 0.5) # TODO: AP does provide Small BET for Limit .. I think? at least 1-on-1 limit they do.. sigh
|
||||||
|
|
||||||
#print info;
|
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
|
is_trny = hand.gametype['type']=='tour'
|
||||||
|
|
||||||
m = self.re_HandInfo.search(hand.handText)
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
if(m == None):
|
fname_re = self.re_TrnyInfoFromFilename if is_trny \
|
||||||
|
else self.re_RingInfoFromFilename
|
||||||
|
fname_info = fname_re.search(self.in_path)
|
||||||
|
|
||||||
|
if m is None or fname_info is None:
|
||||||
|
if m is None:
|
||||||
logging.info(_("Didn't match re_HandInfo"))
|
logging.info(_("Didn't match re_HandInfo"))
|
||||||
logging.info(hand.handText)
|
logging.info(hand.handText)
|
||||||
|
elif fname_info is None:
|
||||||
|
logging.info(_("File name didn't match re_*InfoFromFilename"))
|
||||||
|
logging.info(_("File name: %s") % self.in_path)
|
||||||
return None
|
return None
|
||||||
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
if m.group('TABLE'):
|
if m.group('TABLE'):
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
else:
|
else:
|
||||||
t = self.re_TableFromFilename.search(self.in_path)
|
hand.tablename = fname_info.group('TABLE')
|
||||||
hand.tablename = t.group('TABLE')
|
|
||||||
hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since absolute doesn't give seat max info
|
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
if is_trny:
|
||||||
|
hand.fee = fname_info.group('FEE')
|
||||||
|
hand.buyin = fname_info.group('BUYIN')
|
||||||
|
hand.tourNo = m.group('TRNY_ID')
|
||||||
|
hand.tourneyComment = fname_info.group('TRNY_NAME')
|
||||||
|
|
||||||
|
# assume 6-max unless we have proof it's a larger/smaller game,
|
||||||
|
#since absolute doesn't give seat max info
|
||||||
# TODO: (1-on-1) does have that info in the game type line
|
# TODO: (1-on-1) does have that info in the game type line
|
||||||
|
hand.maxseats = 6
|
||||||
|
|
||||||
if self.HORSEHand:
|
if self.HORSEHand:
|
||||||
hand.maxseats = 8
|
hand.maxseats = 8
|
||||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
|
@ -196,7 +231,8 @@ class Absolute(HandHistoryConverter):
|
||||||
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
||||||
if seatnum > 6:
|
if seatnum > 6:
|
||||||
hand.maxseats = 10 # absolute does 2/4/6/8/10 games
|
hand.maxseats = 10 # absolute does 2/4/6/8/10 games
|
||||||
# TODO: implement lookup list by table-name to determine maxes, then fall back to 6 default/10 here, if there's no entry in the list?
|
# TODO: implement lookup list by table-name to determine maxes,
|
||||||
|
# then fall back to 6 default/10 here, if there's no entry in the list?
|
||||||
|
|
||||||
|
|
||||||
def markStreets(self, hand):
|
def markStreets(self, hand):
|
||||||
|
@ -218,10 +254,12 @@ class Absolute(HandHistoryConverter):
|
||||||
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
def readCommunityCards(self, hand, street):
|
||||||
# If this has been called, street is a street which gets dealt community cards by type hand
|
# street has been matched by markStreets, so exists in this hand
|
||||||
# but it might be worth checking somehow.
|
# If this has been called, street is a street which gets dealt
|
||||||
# if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
# community cards by type hand but it might be worth checking somehow.
|
||||||
|
# if street in ('FLOP','TURN','RIVER'):
|
||||||
|
# a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
||||||
logging.debug("readCommunityCards (%s)" % street)
|
logging.debug("readCommunityCards (%s)" % street)
|
||||||
m = self.re_Board.search(hand.streets[street])
|
m = self.re_Board.search(hand.streets[street])
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user