Absolute hhc: fixes, cleanups, basic trny support

This commit is contained in:
grindi 2010-11-04 12:57:39 +03:00
parent d09aa716f4
commit 79bfc8587e

View File

@ -45,19 +45,43 @@ class Absolute(HandHistoryConverter):
#Seat 6 - FETS63 ($0.75 in chips)
#Board [10s 5d Kh Qh 8c]
re_GameInfo = re.compile(ur"""^Stage #(C?[0-9]+):\s+
(?P<GAME>Holdem|Seven\sCard\sHi\/L|HORSE)
(?:\s\(1\son\s1\)|)?\s+?
(?P<LIMIT>No Limit|Pot\sLimit|Normal|)?\s?
re_GameInfo = re.compile( ur"""
^Stage\s+\#C?(?P<HID>[0-9]+):?\s+
(?:Tourney\ ID\ (?P<TRNY_ID>\d+)\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<SB>[.0-9]+)/?(?:\$|\s|)(?P<BB>[.0-9]+)?
""", re.MULTILINE|re.VERBOSE)
re_HorseGameInfo = re.compile(ur"^Game Type: (?P<LIMIT>Limit) (?P<GAME>Holdem)", re.MULTILINE)
# TODO: can set max seats via (1 on 1) to a known 2 ..
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!
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_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) \((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)", re.MULTILINE)
\s+-\s+
(?P<DATETIME>\d\d\d\d-\d\d-\d\d\ \d\d:\d\d:\d\d)\s+
(?: \( (?P<TZ>[A-Z]+) \)\s+ )?
.*?
(Table:\ (?P<TABLE>.*?)\ \(Real\ Money\))?
""", re.MULTILINE|re.VERBOSE|re.DOTALL)
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)
@ -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*
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)
# 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_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_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_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):
return [["ring", "hold", "nl"],
["ring", "hold", "pl"],
["ring", "hold", "fl"],
["ring", "studhi", "fl"],
["ring", "omahahi", "pl"]
["ring", "omahahi", "pl"],
["tour", "hold", "nl"],
]
def determineGameType(self, handText):
@ -102,7 +118,9 @@ class Absolute(HandHistoryConverter):
'type' in ('ring', 'tour')
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
'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')
'smallBlind' int?
'bigBlind' int?
@ -149,44 +167,61 @@ class Absolute(HandHistoryConverter):
(info['base'], info['category']) = games[mg['GAME']]
if 'LIMIT' in mg:
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:
info['currency'] = currencies[mg['CURRENCY']]
if info['currency'] == 'T$':
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.
if info['bb'] is None:
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
#print info;
return info
def readHandInfo(self, hand):
is_trny = hand.gametype['type']=='tour'
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(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
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
hand.handid = m.group('HID')
if m.group('TABLE'):
hand.tablename = m.group('TABLE')
else:
t = self.re_TableFromFilename.search(self.in_path)
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.tablename = fname_info.group('TABLE')
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
hand.maxseats = 6
if self.HORSEHand:
hand.maxseats = 8
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
return
def readPlayerStacks(self, hand):
@ -196,7 +231,8 @@ class Absolute(HandHistoryConverter):
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
if seatnum > 6:
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):
@ -218,10 +254,12 @@ class Absolute(HandHistoryConverter):
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
hand.addStreets(m)
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
# If this has been called, street is a street which gets dealt 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)
def readCommunityCards(self, hand, street):
# street has been matched by markStreets, so exists in this hand
# If this has been called, street is a street which gets dealt
# 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)
m = self.re_Board.search(hand.streets[street])
cards = m.group('CARDS')