More Everleaf updates, may have a functional regex for action in NLHE

This commit is contained in:
Worros 2008-11-16 13:44:16 +09:00
parent 7aa0cff8d8
commit 55332d4983
3 changed files with 30 additions and 4 deletions

View File

@ -74,6 +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.compileRegexes() self.rexx.compileRegexes()
def readSupportedGames(self): def readSupportedGames(self):
@ -118,6 +119,19 @@ class Everleaf(HandHistoryConverter):
hand.players = players hand.players = players
def markStreets(self, hands):
# 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>.*)', hands.string,re.DOTALL)
print "DEBUG: Group 1 = %s - %s - %s" %(m.group(1), m.start(1), len(hands.string))
print "DEBUG: Group 2 = %s - %s - %s" %(m.group(2), m.start(2), len(hands.string))
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:
m = self.rexx.small_blind_re.search(hand.string) m = self.rexx.small_blind_re.search(hand.string)
@ -144,8 +158,10 @@ class Everleaf(HandHistoryConverter):
hand.holecards = hand.holecards.replace('j','J') hand.holecards = hand.holecards.replace('j','J')
hand.holecards = hand.holecards.replace('t','T') hand.holecards = hand.holecards.replace('t','T')
def readAction(self): def readAction(self, hand, street):
pass m = self.rexx.rexx.action_re.search(hand.obs)
print m.groups()
if __name__ == "__main__": if __name__ == "__main__":
c = Configuration.Config() c = Configuration.Config()

View File

@ -64,6 +64,7 @@ class HandHistoryConverter:
for hand in self.hands: for hand in self.hands:
self.readHandInfo(hand) self.readHandInfo(hand)
self.readPlayerStacks(hand) self.readPlayerStacks(hand)
self.markStreets(hand)
self.readBlinds(hand) self.readBlinds(hand)
self.readHeroCards(hand) self.readHeroCards(hand)
if(hand.involved == True): if(hand.involved == True):
@ -87,12 +88,14 @@ 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 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,
# addtional players are assumed to post a bb oop # addtional players are assumed to post a bb oop
def readBlinds(self, hand): abstract def readBlinds(self, hand): abstract
def readHeroCards(self, hand): abstract def readHeroCards(self, hand): abstract
def readAction(self): abstract def readAction(self, hand, street): abstract
def sanityCheck(self): def sanityCheck(self):
sane = False sane = False
@ -167,7 +170,7 @@ class HandHistoryConverter:
## ACTION STUFF ## ACTION STUFF
# #
print "*** SUMMARY ***" print "*** SUMMARY ***"
# print "Total pot $" + totalpot + " | Rake $" + rake # print "Total pot $%s | Rake $%s)" %(hand.totalpot $" + hand.rake)
# print "Board [" + boardcards + "]" # print "Board [" + boardcards + "]"
# #
## SUMMARY STUFF ## SUMMARY STUFF
@ -195,6 +198,9 @@ 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 }
# Value in characters.
self.handid = 0 self.handid = 0
self.sb = gametype[3] self.sb = gametype[3]
self.bb = gametype[4] self.bb = gametype[4]
@ -209,6 +215,8 @@ class Hand:
self.hero = "Hiro" self.hero = "Hiro"
self.holecards = "Xx Xx" self.holecards = "Xx Xx"
self.action = [] self.action = []
self.totalpot = 0
self.rake = 0
def printHand(self): def printHand(self):
print self.sitename print self.sitename
@ -226,3 +234,4 @@ class Hand:
print self.posted print self.posted
print self.action print self.action
print self.involved print self.involved
print self.hero

View File

@ -49,6 +49,7 @@ class TestSequenceFunctions(unittest.TestCase):
self.mysql_settings['db-password']) self.mysql_settings['db-password'])
self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB') self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB')
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c) self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
self.mysqlimporter.setCallHud(False)
# """Configure Postgres settings/database and establish connection""" # """Configure Postgres settings/database and establish connection"""
# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"} # self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}