hole cards / community cards extracted and added to printout

This commit is contained in:
Matt Turnbull 2008-12-03 23:57:20 +00:00
parent 85f64b42fb
commit 92656ae6a0
2 changed files with 67 additions and 60 deletions

25
pyfpdb/EverleafToFpdb.py Normal file → Executable file
View File

@ -73,14 +73,14 @@ class Everleaf(HandHistoryConverter):
self.rexx.setPlayerInfoRegex('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \( \$ (?P<CASH>[.0-9]+) USD \)')
self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*): posts small blind \[')
self.rexx.setPostBbRegex('.*\n(?P<PNAME>.*): posts big blind \[')
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<HOLECARDS>.*) \]')
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<HOLE1>\S\S), (?P<HOLE2>\S\S) \]')
self.rexx.setActionStepRegex('.*\n(?P<PNAME>.*) (?P<ATYPE>bets|checks|raises|calls|folds)(\s\[\$ (?P<BET>[.\d]+) USD\])?')
self.rexx.compileRegexes()
def readSupportedGames(self):
def readSupportedGames(self):
pass
def determineGameType(self):
def determineGameType(self):
# Cheating with this regex, only support nlhe at the moment
gametype = ["ring", "hold", "nl"]
@ -110,7 +110,7 @@ class Everleaf(HandHistoryConverter):
int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC')))
hand.buttonpos = int(m.group('BUTTON'))
def readPlayerStacks(self, hand):
def readPlayerStacks(self, hand):
m = self.rexx.player_info_re.finditer(hand.string)
players = []
@ -121,12 +121,12 @@ class Everleaf(HandHistoryConverter):
def markStreets(self, hand):
# PREFLOP = ** Dealing down cards **
m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\*)?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\*)?(?P<TURN>.*?\*\*)?( Dealing River \*\*)?(?P<RIVER>.*)', hand.string,re.DOTALL)
m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.string,re.DOTALL)
# for street in m.groupdict():
# print "DEBUG: Street: %s\tspan: %s" %(street, str(m.span(street)))
hand.streets = m
def readBlinds(self, hand):
def readBlinds(self, hand):
try:
m = self.rexx.small_blind_re.search(hand.string)
hand.posted = [m.group('PNAME')]
@ -143,16 +143,9 @@ class Everleaf(HandHistoryConverter):
hand.involved = False
else:
hand.hero = m.group('PNAME')
hand.holecards = m.group('HOLECARDS')
hand.holecards = hand.holecards.replace(',','')
#Must be a better way to do the following tr akqjt AKQJT
hand.holecards = hand.holecards.replace('a','A')
hand.holecards = hand.holecards.replace('k','K')
hand.holecards = hand.holecards.replace('q','Q')
hand.holecards = hand.holecards.replace('j','J')
hand.holecards = hand.holecards.replace('t','T')
hand.addHoleCards(m.group('HOLE1'), m.group('HOLE2'))
def readAction(self, hand, street):
def readAction(self, hand, street):
m = self.rexx.action_re.finditer(hand.streets.group(street))
hand.actions[street] = []
for action in m:
@ -165,7 +158,7 @@ class Everleaf(HandHistoryConverter):
if __name__ == "__main__":
c = Configuration.Config()
e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala.txt")
e = Everleaf(c, "Speed_Kuala.txt")
e.processFile()
print str(e)

View File

@ -104,7 +104,7 @@ class HandHistoryConverter:
def readAction(self, hand, street): abstract
def sanityCheck(self):
sane = False
sane = True
base_w = False
#Check if hhbase exists and is writable
#Note: Will not try to create the base HH directory
@ -175,7 +175,7 @@ class HandHistoryConverter:
print "XXXXXXXXX FIXME XXXXXXXX"
print "*** HOLE CARDS ***"
print "Dealt to %s [%s]" %(hand.hero ,hand.holecards)
print "Dealt to %s [%s %s]" %(hand.hero , hand.holecards[0], hand.holecards[1])
#
## ACTION STUFF
# This is no limit only at the moment
@ -184,17 +184,17 @@ class HandHistoryConverter:
self.printActionLine(act, 0)
if 'FLOP' in hand.actions:
print "*** FLOP *** [%s]" %("XXXXX Flop cards XXXXXX")
print "*** FLOP *** [%s %s %s]" %(hand.streets.group("FLOP1"), hand.streets.group("FLOP2"), hand.streets.group("FLOP3"))
for act in hand.actions['FLOP']:
self.printActionLine(act, 0)
if 'TURN' in hand.actions:
print "*** TURN *** [%s] [%s]" %("XXXXX Flop cards XXXXXX", "XXXXX Turn Card XXXXX")
print "*** TURN *** [%s %s %s] [%s]" %(hand.streets.group("FLOP1"), hand.streets.group("FLOP2"), hand.streets.group("FLOP3"), hand.streets.group("TURN1"))
for act in hand.actions['TURN']:
self.printActionLine(act, 0)
if 'RIVER' in hand.actions:
print "*** RIVER *** [%s %s] [%s]" %("XXXXX Flop cards XXXXXX", "XXXXX Turn Card XXXXX", "XXXXX River Card XXXXX")
print "*** RIVER *** [%s %s %s %s] [%s]" %(hand.streets.group("FLOP1"), hand.streets.group("FLOP2"), hand.streets.group("FLOP3"), hand.streets.group("TURN1"), hand.streets.group("RIVER1"))
for act in hand.actions['RIVER']:
self.printActionLine(act, 0)
@ -232,45 +232,59 @@ class HandHistoryConverter:
class Hand:
# def __init__(self, sitename, gametype, sb, bb, string):
def __init__(self, sitename, gametype, string):
self.sitename = sitename
self.gametype = gametype
self.string = string
self.streets = None # A MatchObject using a groupnames to identify streets.
self.actions = {}
ups = {'a':'A', 't':'T', 'j':'J', 'q':'Q', 'k':'K'}
self.handid = 0
self.sb = gametype[3]
self.bb = gametype[4]
self.tablename = "Slartibartfast"
self.maxseats = 10
self.counted_seats = 0
self.buttonpos = 0
self.seating = []
self.players = []
self.posted = []
self.involved = True
self.hero = "Hiro"
self.holecards = "Xx Xx"
self.action = []
self.totalpot = 0
self.rake = 0
def __init__(self, sitename, gametype, string):
self.sitename = sitename
self.gametype = gametype
self.string = string
def printHand(self):
print self.sitename
print self.gametype
print self.string
print self.handid
print self.sb
print self.bb
print self.tablename
print self.maxseats
print self.counted_seats
print self.buttonpos
print self.seating
print self.players
print self.posted
print self.action
print self.involved
print self.hero
self.streets = None # A MatchObject using a groupnames to identify streets.
self.actions = {}
self.handid = 0
self.sb = gametype[3]
self.bb = gametype[4]
self.tablename = "Slartibartfast"
self.maxseats = 10
self.counted_seats = 0
self.buttonpos = 0
self.seating = []
self.players = []
self.posted = []
self.involved = True
self.hero = "Hiro"
self.holecards = "Xx Xx"
self.action = []
self.totalpot = 0
self.rake = 0
def addHoleCards(self,h1,h2,seat=None): # generalise to add hole cards for a specific seat or player
self.holecards = [self.card(h1), self.card(h2)]
def card(self,c):
"""upper case the ranks but not suits, 'atjqk' => 'ATJQK'"""
# don't know how to make this 'static'
for k,v in self.ups.items():
c = c.replace(k,v)
return c
def printHand(self):
print self.sitename
print self.gametype
print self.string
print self.handid
print self.sb
print self.bb
print self.tablename
print self.maxseats
print self.counted_seats
print self.buttonpos
print self.seating
print self.players
print self.posted
print self.action
print self.involved
print self.hero