Winamax: Make my version much closer to Forrests

This commit is contained in:
Worros 2010-10-08 12:26:24 +08:00
parent d8e3c1418e
commit 717c1e61bc

View File

@ -80,8 +80,9 @@ class Winamax(HandHistoryConverter):
# Winamax Poker - CashGame - HandId: #279823-223-1285031451 - Holdem no limit (0.02€/0.05€) - 2010/09/21 03:10:51 UTC # Winamax Poker - CashGame - HandId: #279823-223-1285031451 - Holdem no limit (0.02€/0.05€) - 2010/09/21 03:10:51 UTC
# Table: 'Charenton-le-Pont' 9-max (real money) Seat #5 is the button
re_HandInfo = re.compile(u""" re_HandInfo = re.compile(u"""
\s*Winamax\sPoker\s-\sCashGame\s-\sHandId:\s\#(?P<HID>[-A-Z\d]+).*\s \s*Winamax\sPoker\s-\sCashGame\s-\sHandId:\s\#(?P<HID1>\d+)-(?P<HID2>\d+)-(?P<HID3>\d+).*\s
(?P<GAME>Holdem|Omaha)\s (?P<GAME>Holdem|Omaha)\s
(?P<LIMIT>no\slimit|pot\slimit)\s (?P<LIMIT>no\slimit|pot\slimit)\s
\( \(
@ -89,6 +90,7 @@ class Winamax(HandHistoryConverter):
((%(LS)s)?(?P<BB>[.0-9]+)(%(LS)s)?) ((%(LS)s)?(?P<BB>[.0-9]+)(%(LS)s)?)
\)\s-\s \)\s-\s
(?P<DATETIME>.*) (?P<DATETIME>.*)
Table:\s\'(?P<TABLE>[^']+)\'\s(?P<MAXPLAYER>\d+)\-max
""" % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE) """ % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE)
re_TailSplitHands = re.compile(r'\n\s*\n') re_TailSplitHands = re.compile(r'\n\s*\n')
@ -104,10 +106,9 @@ class Winamax(HandHistoryConverter):
UTC UTC
""", re.MULTILINE|re.VERBOSE) """, re.MULTILINE|re.VERBOSE)
# Seat 1: floflo...76 (5€) # Seat 1: some_player (5€)
# Seat 2: francksp76 (6.33€) # Seat 2: some_other_player21 (6.33€)
# Seat 3: Tonton73 (4.80€)
# Seat 4: chris67poker (4.60€)
re_PlayerInfo = re.compile(u'Seat\s(?P<SEAT>[0-9]+):\s(?P<PNAME>.*)\s\((%(LS)s)?(?P<CASH>[.0-9]+)(%(LS)s)?\)' % substitutions) re_PlayerInfo = re.compile(u'Seat\s(?P<SEAT>[0-9]+):\s(?P<PNAME>.*)\s\((%(LS)s)?(?P<CASH>[.0-9]+)(%(LS)s)?\)' % substitutions)
def compilePlayerRegexs(self, hand): def compilePlayerRegexs(self, hand):
@ -130,20 +131,10 @@ class Winamax(HandHistoryConverter):
self.re_PostDead = re.compile('(?P<PNAME>.*) posts dead blind \((%(CUR)s)?(?P<DEAD>[\.0-9]+)(%(CUR)s)?\)' % subst, re.MULTILINE) self.re_PostDead = re.compile('(?P<PNAME>.*) posts dead blind \((%(CUR)s)?(?P<DEAD>[\.0-9]+)(%(CUR)s)?\)' % subst, re.MULTILINE)
self.re_HeroCards = re.compile('Dealt\sto\s%(PLYR)s\s\[(?P<CARDS>.*)\]' % subst) self.re_HeroCards = re.compile('Dealt\sto\s%(PLYR)s\s\[(?P<CARDS>.*)\]' % subst)
#lopllopl checks, Eurolll checks, .Lucchess checks.
#chumley. calls $0.25
self.re_Action = re.compile('(, )?(?P<PNAME>.*?)(?P<ATYPE> bets| checks| raises| calls| folds)( (%(CUR)s)?(?P<BET>[\d\.]+)(%(CUR)s)?)?( and is all-in)?' % subst) self.re_Action = re.compile('(, )?(?P<PNAME>.*?)(?P<ATYPE> bets| checks| raises| calls| folds)( (%(CUR)s)?(?P<BET>[\d\.]+)(%(CUR)s)?)?( and is all-in)?' % subst)
#self.re_Board = re.compile(r"\[board cards (?P<CARDS>.+) \]") self.re_ShowdownAction = re.compile('(?P<PNAME>[^\(\)\n]*) (\((small blind|big blind|button)\) )?shows \[(?P<CARDS>.+)\]')
#Uchilka shows [ KC,JD ]
self.re_ShowdownAction = re.compile('(?P<PNAME>.*) shows \[(?P<CARDS>.+)\]')
#Main pot: $3.57 won by mleo17 ($3.40)
#Side pot 1: $3.26 won by maac_5 ($3.10)
#Main pot: $2.87 won by maac_5 ($1.37), sagi34 ($1.36)
# self.re_CollectPot = re.compile('\s*(?P<PNAME>.*)\scollected\s(%(CUR)s)?(?P<POT>[\.\d]+)(%(CUR)s)?\sfrom\spot' % subst)
self.re_CollectPot = re.compile('\s*(?P<PNAME>.*)\scollected\s(%(CUR)s)?(?P<POT>[\.\d]+)(%(CUR)s)?.*' % subst) self.re_CollectPot = re.compile('\s*(?P<PNAME>.*)\scollected\s(%(CUR)s)?(?P<POT>[\.\d]+)(%(CUR)s)?.*' % subst)
#Seat 5: mleo17 ($3.40), net: +$2.57, [Jd, Qd] (TWO_PAIR QUEEN, JACK)
self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %(PLYR)s showed \[(?P<CARDS>.*)\].*" % subst, re.MULTILINE) self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %(PLYR)s showed \[(?P<CARDS>.*)\].*" % subst, re.MULTILINE)
self.re_sitsOut = re.compile('(?P<PNAME>.*) sits out') self.re_sitsOut = re.compile('(?P<PNAME>.*) sits out')
@ -186,7 +177,6 @@ class Winamax(HandHistoryConverter):
if 'BB' in mg: if 'BB' in mg:
info['bb'] = mg['BB'] info['bb'] = mg['BB']
#log.debug("determinegametype: returning "+str(info))
return info return info
def readHandInfo(self, hand): def readHandInfo(self, hand):
@ -199,11 +189,6 @@ class Winamax(HandHistoryConverter):
#log.debug("readHandInfo: %s" % info) #log.debug("readHandInfo: %s" % info)
for key in info: for key in info:
if key == 'DATETIME': if key == 'DATETIME':
#'Wed Aug 18 19:45:30 GMT+0100 2010
# %a %b %d %H:%M:%S %z %Y
#hand.startTime = time.strptime(m.group('DATETIME'), "%a %b %d %H:%M:%S GMT%z %Y")
# Stupid library doesn't seem to support %z (http://docs.python.org/library/time.html?highlight=strptime#time.strptime)
# So we need to re-interpret te string to be useful
a = self.re_DateTime.search(info[key]) a = self.re_DateTime.search(info[key])
if a: if a:
datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'),a.group('M'), a.group('D'), a.group('H'),a.group('MIN'),a.group('S')) datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'),a.group('M'), a.group('D'), a.group('H'),a.group('MIN'),a.group('S'))
@ -211,15 +196,13 @@ class Winamax(HandHistoryConverter):
else: else:
datetimestr = "2010/Jan/01 01:01:01" datetimestr = "2010/Jan/01 01:01:01"
log.error(_("readHandInfo: DATETIME not matched: '%s'" % info[key])) log.error(_("readHandInfo: DATETIME not matched: '%s'" % info[key]))
print "DEBUG: readHandInfo: DATETIME not matched: '%s'" % info[key] # print "DEBUG: readHandInfo: DATETIME not matched: '%s'" % info[key]
# TODO: Manually adjust time against OFFSET # TODO: Manually adjust time against OFFSET
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET" hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
# hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, tzoffset, "UTC") hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "CET", "UTC")
if key == 'HID': if key == 'HID1':
hand.handid = info[key] hand.handid = "1%.4d%s%s"%(int(info['HID2']),info['HID1'],info['HID3'])
# Need to remove non-alphanumerics for MySQL # Need to remove non-alphanumerics for MySQL
hand.handid = hand.handid.replace('R','')
hand.handid = hand.handid.replace('-','')
if key == 'TABLE': if key == 'TABLE':
hand.tablename = info[key] hand.tablename = info[key]
@ -229,53 +212,13 @@ class Winamax(HandHistoryConverter):
hand.mixed = None hand.mixed = None
def readPlayerStacks(self, hand): def readPlayerStacks(self, hand):
log.info("readplayerstacks: re is '%s'" % self.re_PlayerInfo) log.debug("readplayerstacks: re is '%s'" % self.re_PlayerInfo)
m = self.re_PlayerInfo.finditer(hand.handText) m = self.re_PlayerInfo.finditer(hand.handText)
for a in m: for a in m:
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH')) hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
def markStreets(self, hand): def markStreets(self, hand):
# *** ANTE/BLINDS ***
# francksp76 posts small blind 0.02€
# Tonton73 posts big blind 0.05€
# Dealt to johnny_nd [5d Kh 9c Tc]
# *** PRE-FLOP ***
# chris67poker folds
# luckyluck21_ calls 0.05€
# arawak folds
# johnny_nd calls 0.05€
# KILLAROUNDER calls 0.05€
# floflo...76 folds
# francksp76 calls 0.03€
# Tonton73 checks
# *** FLOP *** [5h 8d 3h]
# francksp76 checks
# Tonton73 checks
# luckyluck21_ checks
# johnny_nd checks
# KILLAROUNDER checks
# *** TURN *** [5h 8d 3h][7h]
# francksp76 checks
# Tonton73 checks
# luckyluck21_ checks
# johnny_nd checks
# KILLAROUNDER checks
# *** RIVER *** [5h 8d 3h 7h][2d]
# francksp76 checks
# Tonton73 checks
# luckyluck21_ checks
# johnny_nd bets 0.25€
# KILLAROUNDER folds
# francksp76 folds
# Tonton73 folds
# luckyluck21_ calls 0.25€
# *** SHOW DOWN ***
# johnny_nd shows [5d Kh 9c Tc] (One pair : 5)
# luckyluck21_ shows [6h Js 9s Td] (Straight 9 high)
# luckyluck21_ collected 0.71€ from pot
# *** SUMMARY ***
# Total pot 0.71€ | Rake 0.04€
m = re.search(r"\*\*\* ANTE\/BLINDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)" m = re.search(r"\*\*\* ANTE\/BLINDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?" r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S](?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?" r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S](?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
@ -283,7 +226,8 @@ class Winamax(HandHistoryConverter):
try: try:
hand.addStreets(m) hand.addStreets(m)
print "add street" # print "adding street", m.group(0)
# print "---"
except: except:
print ("Failed to add streets. handtext=%s") print ("Failed to add streets. handtext=%s")
@ -312,12 +256,11 @@ class Winamax(HandHistoryConverter):
hand.setCommunityCards(street, m.group('CARDS').split(' ')) hand.setCommunityCards(street, m.group('CARDS').split(' '))
def readBlinds(self, hand): def readBlinds(self, hand):
try:
m = self.re_PostSB.search(hand.handText) m = self.re_PostSB.search(hand.handText)
if m:
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB')) hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
except exceptions.AttributeError: # no small blind else:
log.exception( _("readBlinds in noSB exception - no SB created")+str(sys.exc_info()) ) log.warning(_("readBlinds in noSB exception - no SB created"))
#hand.addBlind(None, None, None)
for a in self.re_PostBB.finditer(hand.handText): for a in self.re_PostBB.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB')) hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
for a in self.re_PostDead.finditer(hand.handText): for a in self.re_PostDead.finditer(hand.handText):
@ -350,7 +293,7 @@ class Winamax(HandHistoryConverter):
for found in m: for found in m:
hand.hero = found.group('PNAME') hand.hero = found.group('PNAME')
newcards = found.group('CARDS').split(' ') newcards = found.group('CARDS').split(' ')
print "DEBUG: addHoleCards(%s, %s, %s)" %(street, hand.hero, newcards) # print "DEBUG: addHoleCards(%s, %s, %s)" %(street, hand.hero, newcards)
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True) hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
log.debug("Hero cards %s: %s"%(hand.hero, newcards)) log.debug("Hero cards %s: %s"%(hand.hero, newcards))
@ -358,7 +301,6 @@ class Winamax(HandHistoryConverter):
m = self.re_Action.finditer(hand.streets[street]) m = self.re_Action.finditer(hand.streets[street])
for action in m: for action in m:
acts = action.groupdict() acts = action.groupdict()
#log.debug("readaction: acts: %s" %acts)
if action.group('ATYPE') == ' raises': if action.group('ATYPE') == ' raises':
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') ) hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
elif action.group('ATYPE') == ' calls': elif action.group('ATYPE') == ' calls':
@ -375,21 +317,43 @@ class Winamax(HandHistoryConverter):
hand.addStandsPat( street, action.group('PNAME')) hand.addStandsPat( street, action.group('PNAME'))
else: else:
log.fatal("DEBUG: unimplemented readAction: '%s' '%s'") %(action.group('PNAME'),action.group('ATYPE'),) log.fatal("DEBUG: unimplemented readAction: '%s' '%s'") %(action.group('PNAME'),action.group('ATYPE'),)
# print "Processed %s"%acts
# print "committed=",hand.pot.committed
def readShowdownActions(self, hand): def readShowdownActions(self, hand):
for shows in self.re_ShowdownAction.finditer(hand.handText): for shows in self.re_ShowdownAction.finditer(hand.handText):
log.debug("add show actions %s"%shows) log.debug("add show actions %s"%shows)
cards = shows.group('CARDS') cards = shows.group('CARDS')
cards = cards.split(' ') cards = cards.split(' ')
print "DEBUG: addShownCards(%s, %s)" %(cards, shows.group('PNAME')) # print "DEBUG: addShownCards(%s, %s)" %(cards, shows.group('PNAME'))
hand.addShownCards(cards, shows.group('PNAME')) hand.addShownCards(cards, shows.group('PNAME'))
@Trace
def readCollectPot(self,hand): def readCollectPot(self,hand):
# Winamax has unfortunately thinks that a sidepot is created
# when there is uncalled money in the pot - something that can
# only happen when a player is all-in
# The first side pot mentioned is always the uncalled money, so we can remove it.
# If there is only 1 collected line, then add it
hand.totalPot()
collectees = []
for m in self.re_CollectPot.finditer(hand.handText): for m in self.re_CollectPot.finditer(hand.handText):
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT')) collectees.append([m.group('PNAME'), m.group('POT')])
committed = sorted([ (v,k) for (k,v) in hand.pot.committed.items()])
lastbet = committed[-1][0] - committed[-2][0]
if lastbet > 0: # uncalled
returnto = committed[-1][1]
for plyr, p in collectees:
if plyr == returnto and p == lastbet:
pass
else:
print "DEBUG: addCollectPot(%s, %s)" %(plyr, p)
hand.addCollectPot(player=plyr,pot=p)
else:
for plyr, p in collectees[1:]:
print "DEBUG: addCollectPot(%s, %s)" %(plyr, p)
hand.addCollectPot(player=plyr,pot=p)
@Trace
def readShownCards(self,hand): def readShownCards(self,hand):
for m in self.re_ShownCards.finditer(hand.handText): for m in self.re_ShownCards.finditer(hand.handText):
log.debug("Read shown cards: %s"%m.group(0)) log.debug("Read shown cards: %s"%m.group(0))