Update to work with recent Hand.py changes.
This commit is contained in:
parent
5b5c38f3e9
commit
52ecc64505
|
@ -27,10 +27,22 @@ from HandHistoryConverter import *
|
||||||
class Fulltilt(HandHistoryConverter):
|
class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_GameInfo = re.compile('- (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<LIMIT>(No Limit|Pot Limit|Limit))? (?P<GAME>(Hold\'em|Omaha Hi|Razz))')
|
re_GameInfo = re.compile('''-\s(?P<CURRENCY>\$|)?
|
||||||
|
(?P<SB>[.0-9]+)/
|
||||||
|
\$?(?P<BB>[.0-9]+)\s
|
||||||
|
(Ante\s\$(?P<ANTE>[.0-9]+)\s)?-\s
|
||||||
|
(?P<LIMIT>(No\sLimit|Pot\sLimit|Limit))?\s
|
||||||
|
(?P<GAME>(Hold\'em|Omaha\sHi|Omaha\sH/L|7\sCard\sStud|Stud\sH/L|Razz))
|
||||||
|
''', re.VERBOSE)
|
||||||
re_SplitHands = re.compile(r"\n\n+")
|
re_SplitHands = re.compile(r"\n\n+")
|
||||||
re_TailSplitHands = re.compile(r"(\n\n+)")
|
re_TailSplitHands = re.compile(r"(\n\n+)")
|
||||||
re_HandInfo = re.compile('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[- a-zA-Z]+) (\((?P<TABLEATTRIBUTES>.+)\) )?- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<GAMETYPE>[a-zA-Z\' ]+) - (?P<DATETIME>.*)')
|
re_HandInfo = re.compile('''.*\#(?P<HID>[0-9]+):\s
|
||||||
|
Table\s(?P<TABLE>[-\sa-zA-Z]+)\s
|
||||||
|
(\((?P<TABLEATTRIBUTES>.+)\)\s)?-\s
|
||||||
|
\$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)\s(Ante\s\$(?P<ANTE>[.0-9]+)\s)?-\s
|
||||||
|
(?P<GAMETYPE>[a-zA-Z\/\'\s]+)\s-\s
|
||||||
|
(?P<DATETIME>.*)
|
||||||
|
''', re.VERBOSE)
|
||||||
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
||||||
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[.0-9]+)\)\n')
|
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[.0-9]+)\)\n')
|
||||||
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
|
@ -96,19 +108,18 @@ follow : whether to tail -f the input"""
|
||||||
games = { # base, category
|
games = { # base, category
|
||||||
"Hold'em" : ('hold','holdem'),
|
"Hold'em" : ('hold','holdem'),
|
||||||
'Omaha Hi' : ('hold','omahahi'),
|
'Omaha Hi' : ('hold','omahahi'),
|
||||||
|
'Omaha H/L' : ('hold','omahahilo'),
|
||||||
'Razz' : ('stud','razz'),
|
'Razz' : ('stud','razz'),
|
||||||
'7 Card Stud' : ('stud','studhi')
|
'7 Card Stud' : ('stud','studhi'),
|
||||||
|
'Stud H/L' : ('stud', 'studhilo')
|
||||||
}
|
}
|
||||||
currencies = { u' €':'EUR', '$':'USD', '':'T$' }
|
currencies = { u' €':'EUR', '$':'USD', '':'T$' }
|
||||||
if 'LIMIT' in mg:
|
|
||||||
info['limitType'] = limits[mg['LIMIT']]
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
if 'GAME' in mg:
|
|
||||||
(info['base'], info['category']) = games[mg['GAME']]
|
|
||||||
if 'SB' in mg:
|
|
||||||
info['sb'] = mg['SB']
|
info['sb'] = mg['SB']
|
||||||
if 'BB' in mg:
|
|
||||||
info['bb'] = mg['BB']
|
info['bb'] = mg['BB']
|
||||||
if 'CURRENCY' in mg:
|
if mg['GAME'] != None:
|
||||||
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
|
if mg['CURRENCY'] != None:
|
||||||
info['currency'] = currencies[mg['CURRENCY']]
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
# 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.
|
||||||
|
|
||||||
|
@ -121,7 +132,7 @@ follow : whether to tail -f the input"""
|
||||||
logging.info("Didn't match re_HandInfo")
|
logging.info("Didn't match re_HandInfo")
|
||||||
logging.info(hand.handText)
|
logging.info(hand.handText)
|
||||||
return None
|
return None
|
||||||
|
print "group_dict =", m.groupdict()
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
||||||
|
@ -204,73 +215,40 @@ follow : whether to tail -f the input"""
|
||||||
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
m = self.re_HeroCards.search(hand.handText)
|
# streets PREFLOP, PREDRAW, and THIRD are special cases beacause
|
||||||
if(m == None):
|
# we need to grab hero's cards
|
||||||
#Not involved in hand
|
for street in ('PREFLOP', 'DEAL'):
|
||||||
hand.involved = False
|
if street in hand.streets.keys():
|
||||||
else:
|
|
||||||
hand.hero = m.group('PNAME')
|
|
||||||
# "2c, qh" -> set(["2c","qc"])
|
|
||||||
# Also works with Omaha hands.
|
|
||||||
cards = m.group('NEWCARDS')
|
|
||||||
cards = [c.strip() for c in cards.split(' ')]
|
|
||||||
hand.addHoleCards(cards, m.group('PNAME'))
|
|
||||||
|
|
||||||
def readStudPlayerCards(self, hand, street):
|
|
||||||
# This could be the most tricky one to get right.
|
|
||||||
# It looks for cards dealt in 'street',
|
|
||||||
# which may or may not be in the section of the hand designated 'street' by markStreets earlier.
|
|
||||||
# Here's an example at FTP of what 'THIRD' and 'FOURTH' look like to hero PokerAscetic
|
|
||||||
#
|
|
||||||
#"*** 3RD STREET ***
|
|
||||||
#Dealt to BFK23 [Th]
|
|
||||||
#Dealt to cutiepr1nnymaid [8c]
|
|
||||||
#Dealt to PokerAscetic [7c 8s] [3h]
|
|
||||||
#..."
|
|
||||||
#
|
|
||||||
#"*** 4TH STREET ***
|
|
||||||
#Dealt to cutiepr1nnymaid [8c] [2s]
|
|
||||||
#Dealt to PokerAscetic [7c 8s 3h] [5s]
|
|
||||||
#..."
|
|
||||||
#Note that hero's first two holecards are only reported at 3rd street as 'old' cards.
|
|
||||||
logging.debug("readStudPlayerCards")
|
|
||||||
m = self.re_HeroCards.finditer(hand.streets[street])
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
for player in m:
|
for found in m:
|
||||||
logging.debug(player.groupdict())
|
# if m == None:
|
||||||
(pname, oldcards, newcards) = (player.group('PNAME'), player.group('OLDCARDS'), player.group('NEWCARDS'))
|
# hand.involved = False
|
||||||
if oldcards:
|
# else:
|
||||||
oldcards = [c.strip() for c in oldcards.split(' ')]
|
hand.hero = found.group('PNAME')
|
||||||
if newcards:
|
newcards = found.group('NEWCARDS').split(' ')
|
||||||
newcards = [c.strip() for c in newcards.split(' ')]
|
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
|
||||||
# options here:
|
|
||||||
# (1) we trust the hand will know what to do -- probably check that the old cards match what it already knows, and add the newcards to this street.
|
for street, text in hand.streets.iteritems():
|
||||||
# (2) we're the experts at this particular history format and we know how we're going to be called (once for each street in Hand.streetList)
|
if not text or street in ('PREFLOP', 'DEAL'): continue # already done these
|
||||||
# so call addPlayerCards with the appropriate information.
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
# I favour (2) here but I'm afraid it is rather stud7-specific.
|
for found in m:
|
||||||
# in the following, the final list of cards will be in 'newcards' whilst if the first list exists (most of the time it does) it will be in 'oldcards'
|
player = found.group('PNAME')
|
||||||
if street=='ANTES':
|
if found.group('NEWCARDS') == None:
|
||||||
return
|
newcards = []
|
||||||
elif street=='THIRD':
|
else:
|
||||||
# we'll have observed hero holecards in CARDS and thirdstreet open cards in 'NEWCARDS'
|
newcards = found.group('NEWCARDS').split(' ')
|
||||||
# hero: [xx][o]
|
if found.group('OLDCARDS') == None:
|
||||||
# others: [o]
|
oldcards = []
|
||||||
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = oldcards, open = newcards)
|
else:
|
||||||
elif street in ('FOURTH', 'FIFTH', 'SIXTH'):
|
oldcards = found.group('OLDCARDS').split(' ')
|
||||||
# 4th:
|
|
||||||
# hero: [xxo] [o]
|
if street == 'THIRD' and len(newcards) == 3: # hero in stud game
|
||||||
# others: [o] [o]
|
hand.hero = player
|
||||||
# 5th:
|
hand.dealt.add(player) # need this for stud??
|
||||||
# hero: [xxoo] [o]
|
hand.addHoleCards(street, player, closed=newcards[0:2], open=[newcards[2]], shown=False, mucked=False, dealt=False)
|
||||||
# others: [oo] [o]
|
else:
|
||||||
# 6th:
|
hand.addHoleCards(street, player, open=newcards, closed=oldcards, shown=False, mucked=False, dealt=False)
|
||||||
# hero: [xxooo] [o]
|
|
||||||
# others: [ooo] [o]
|
|
||||||
hand.addPlayerCards(player = player.group('PNAME'), street = street, open = newcards)
|
|
||||||
# we may additionally want to check the earlier streets tally with what we have but lets trust it for now.
|
|
||||||
elif street=='SEVENTH' and newcards:
|
|
||||||
# hero: [xxoooo] [x]
|
|
||||||
# others: not reported.
|
|
||||||
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = newcards)
|
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.re_Action.finditer(hand.streets[street])
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
|
@ -326,4 +304,5 @@ if __name__ == "__main__":
|
||||||
LOG_FILENAME = './logging.out'
|
LOG_FILENAME = './logging.out'
|
||||||
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
||||||
|
|
||||||
|
print "ipath =", options.ipath
|
||||||
e = Fulltilt(in_path = options.ipath, out_path = options.opath, follow = options.follow)
|
e = Fulltilt(in_path = options.ipath, out_path = options.opath, follow = options.follow)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user