Move Everleaf updates - action now parsed

This commit is contained in:
Worros 2008-11-27 20:54:42 +09:00
parent 7cc8ce7757
commit b495387d94
2 changed files with 24 additions and 17 deletions

View File

@ -74,7 +74,7 @@ class Everleaf(HandHistoryConverter):
self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*): posts small blind \[') self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*): posts small blind \[')
self.rexx.setPostBbRegex('.*\n(?P<PNAME>.*): posts big 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<HOLECARDS>.*) \]')
self.rexx.setActionStepRegex('^(?P<PNAME>.*) (?P<ATYPE>bets|checks|raises|calls|folds)((\s\$([.\d]+))?(\sto\s\$([.\d]+))?)?') self.rexx.setActionStepRegex('.*\n(?P<PNAME>.*) (?P<ATYPE>bets|checks|raises|calls|folds)(\s\[\$ (?P<BET>[.\d]+) USD\])?')
self.rexx.compileRegexes() self.rexx.compileRegexes()
def readSupportedGames(self): def readSupportedGames(self):
@ -119,18 +119,12 @@ class Everleaf(HandHistoryConverter):
hand.players = players hand.players = players
def markStreets(self, hands): def markStreets(self, hand):
# PREFLOP = ** Dealing down cards ** # PREFLOP = ** Dealing down cards **
# m = re.search('(\*\* Dealing down cards \*\*)(?P<PREFLOP>.*)(\*\* Dealing Flop \*\*)?(?P<FLOP>.*)?(\*\* Dealing Turn \*\*)?(?P<TURN>.*)', hands.string,re.DOTALL) 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<FLOP>.*?\*\*)?( Dealing Turn \*\*)?(?P<TURN>.*?\*\*)?( Dealing River \*\*)?(?P<RIVER>.*)', hands.string,re.DOTALL) # for street in m.groupdict():
print "DEBUG: Group 1 = %s - %s - %s" %(m.group(1), m.start(1), len(hands.string)) # print "DEBUG: Street: %s\tspan: %s" %(street, str(m.span(street)))
print "DEBUG: Group 2 = %s - %s - %s" %(m.group(2), m.start(2), len(hands.string)) hand.streets = m
print "DEBUG: Group 3 = %s - %s - %s" %(m.group(3), m.start(3), len(hands.string))
print "DEBUG: Group 4 = %s - %s - %s" %(m.group(4), m.start(4), len(hands.string))
print "DEBUG: Group 5 = %s - %s - %s" %(m.group(5), m.start(5), len(hands.string))
print "DEBUG: Group 6 = %s - %s - %s" %(m.group(6), m.start(6), len(hands.string))
print "DEBUG: Group 7 = %s - %s - %s" %(m.group(7), m.start(7), len(hands.string))
print "DEBUG: Group 8 = %s - %s - %s" %(m.group(8), m.start(8), len(hands.string))
def readBlinds(self, hand): def readBlinds(self, hand):
try: try:
@ -159,8 +153,15 @@ class Everleaf(HandHistoryConverter):
hand.holecards = hand.holecards.replace('t','T') hand.holecards = hand.holecards.replace('t','T')
def readAction(self, hand, street): def readAction(self, hand, street):
m = self.rexx.rexx.action_re.search(hand.obs) m = self.rexx.action_re.finditer(hand.streets.group(street))
print m.groups() hand.actions = {}
hand.actions[street] = []
for action in m:
if action.group('ATYPE') == 'raises' or action.group('ATYPE') == 'calls':
hand.actions[street] += [[action.group('PNAME'), action.group('ATYPE'), action.group('BET')]]
else:
hand.actions[street] += [[action.group('PNAME'), action.group('ATYPE')]]
print "DEBUG: readAction: %s " %(hand.actions)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -67,6 +67,11 @@ class HandHistoryConverter:
self.markStreets(hand) self.markStreets(hand)
self.readBlinds(hand) self.readBlinds(hand)
self.readHeroCards(hand) self.readHeroCards(hand)
# Read action (Note: no guarantee this is in hand order.
for street in hand.streets.groupdict():
self.readAction(hand, street)
if(hand.involved == True): if(hand.involved == True):
self.writeHand("output file", hand) self.writeHand("output file", hand)
else: else:
@ -88,7 +93,8 @@ class HandHistoryConverter:
# [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]] # [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]]
def readPlayerStacks(self, hand): abstract def readPlayerStacks(self, hand): abstract
def markStreets(hand): abstract # Needs to return a MatchObject with group names identifying the streets into the Hand object
def markStreets(self, hand): abstract
#Needs to return a list in the format #Needs to return a list in the format
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb, # ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
@ -198,8 +204,8 @@ class Hand:
self.gametype = gametype self.gametype = gametype
self.string = string self.string = string
self.streets = {} # Index into string for where street starts { 'RIVER': 49 } self.streets = None # A MatchObject using a groupnames to identify streets.
# Value in characters. self.actions = None
self.handid = 0 self.handid = 0
self.sb = gametype[3] self.sb = gametype[3]