Merge branch 'master' of git://git.assembla.com/fpdboz

Only seemed to conflict the [ --> \[ in the HeroCards re

Conflicts:

	pyfpdb/FulltiltToFpdb.py
This commit is contained in:
Matt Turnbull 2009-02-25 12:36:45 +00:00
commit bb4eece2f7
4 changed files with 132 additions and 10 deletions

View File

@ -31,14 +31,14 @@ class Everleaf(HandHistoryConverter):
self.sitename = "Everleaf"
self.setFileType("text", "cp1252")
self.re_GameInfo = re.compile(r".*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<LTYPE>(NL|PL)) (?P<GAME>(Hold\'em|Omaha))")
self.re_GameInfo = re.compile(r".*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<LTYPE>(NL|PL)) (?P<GAME>(Hold\'em|Omaha|7 Card Stud))")
self.re_SplitHands = re.compile(r"\n\n+")
self.re_HandInfo = re.compile(r".*#(?P<HID>[0-9]+)\n.*\nBlinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>[- a-zA-Z]+)\nSeat (?P<BUTTON>[0-9]+)")
self.re_PlayerInfo = re.compile(r"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+(\$ (?P<CASH>[.0-9]+) USD|new player|All-in) \)", re.MULTILINE)
self.re_Board = re.compile(r"\[ (?P<CARDS>.+) \]")
try:
self.ofile = os.path.join(self.hhdir, file.split("\\")[-2]+"-"+os.path.basename(file))
self.ofile = os.path.join(self.hhdir, file.split(os.path.sep)[-2]+"-"+os.path.basename(file))
except:
self.ofile = os.path.join(self.hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file))
@ -69,15 +69,21 @@ class Everleaf(HandHistoryConverter):
game = ""
m = self.re_GameInfo.search(self.obs)
if m == None:
return None
if m.group('LTYPE') == "NL":
structure = "nl"
elif m.group('LTYPE') == "PL":
structure = "pl"
else:
structure = "fl" # we don't support it, but there should be how to detect it at least.
if m.group('GAME') == "Hold\'em":
game = "hold"
if m.group('GAME') == "Omaha":
elif m.group('GAME') == "Omaha":
game = "omahahi"
elif m.group('GAME') == "7 Card Stud":
game = "studhi" # Everleaf currently only does Hi stud
gametype = ["ring", game, structure, m.group('SB'), m.group('BB')]
@ -89,6 +95,7 @@ class Everleaf(HandHistoryConverter):
print "DEBUG: re_HandInfo.search failed: '%s'" %(hand.string)
hand.handid = m.group('HID')
hand.tablename = m.group('TABLE')
hand.max_seats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
# These work, but the info is already in the Hand class - should be used for tourneys though.
# m.group('SB')
# m.group('BB')
@ -107,9 +114,12 @@ class Everleaf(HandHistoryConverter):
def readPlayerStacks(self, hand):
m = self.re_PlayerInfo.finditer(hand.string)
for a in m:
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
seatnum = int(a.group('SEAT'))
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
if seatnum > 6:
hand.max_seats = 10 # everleaf currently does 2/6/10 games, so if seats > 6 are in use, it must be 10-max.
# TODO: implement lookup list by table-name to determine maxes, then fall back to 6 default/10 here, if there's no entry in the list?
def markStreets(self, hand):
# PREFLOP = ** Dealing down cards **

View File

@ -42,7 +42,7 @@ class FullTilt(HandHistoryConverter):
self.re_PostBB = re.compile(r"^%s posts (the big blind of )?\$?(?P<BB>[.0-9]+)", player_re)
self.re_BringIn = re.compile(r"^%s brings in for \$?(?P<BRINGIN>[.0-9]+)", player_re)
self.re_PostBoth = re.compile(r"^%s posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)", player_re)
self.re_HeroCards = re.compile(r"^Dealt to %s \[(?P<CARDS>.*)\]( [(?P<NEWCARD>.*])?", player_re)
self.re_HeroCards = re.compile(r"^Dealt to %s \[(?P<CARDS>.*)\]( \[(?P<NEWCARD>.*\])?", player_re)
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| calls| folds)(\s\$(?P<BET>[.\d]+))?", player_re)
self.re_ShowdownAction = re.compile(r"^%s shows \[(?P<CARDS>.*)\]", player_re)
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)", player_re)
@ -71,7 +71,7 @@ class FullTilt(HandHistoryConverter):
structure = "nl"
elif m.group('LTYPE') == "Pot ":
structure = "pl"
elif m.group('LTYPE') == "None":
elif m.group('LTYPE') == None:
structure = "fl"
if m.group('GAME') == "Hold\'em":
@ -80,7 +80,9 @@ class FullTilt(HandHistoryConverter):
game = "omahahi"
elif m.group('GAME') == "Razz":
game = "razz"
print m.groups()
gametype = ["ring", game, structure, m.group('SB'), m.group('BB')]
return gametype

View File

@ -365,11 +365,19 @@ Map the tuple self.gametype onto the pokerstars string describing it
"cp" : "Cap Pot Limit"
}
print "DEBUG: self.gametype: %s" %(self.gametype)
string = "%s %s" %(gs[self.gametype[1]], ls[self.gametype[2]])
return string
def writeHand(self, fh=sys.__stdout__):
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
self.writeHoldemHand(fh)
else:
self.writeStudHand(fh)
def writeHoldemHand(self, fh=sys.__stdout__):
# PokerStars format.
#print "\n### Pseudo stars format ###"
#print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %(self.sitename, self.handid, self.getGameTypeAsString(), self.sb, self.bb, self.starttime))
@ -473,6 +481,105 @@ Map the tuple self.gametype onto the pokerstars string describing it
#print "Seat %d: %s showed %s" % (player[0], player[1], hole)
#else:
#print "Seat %d: %s mucked or folded" % (player[0], player[1])
def writeStudHand(self, fh=sys.__stdout__):
# PokerStars format.
#print "\n### Pseudo stars format ###"
#print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %(self.sitename, self.handid, self.getGameTypeAsString(), self.sb, self.bb, self.starttime))
print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid, self.getGameTypeAsString(), self.sb, self.bb, time.strftime('%Y/%m/%d - %H:%M:%S (ET)', self.starttime)))
print >>fh, _("Table '%s' %d-max Seat #%s is the button" %(self.tablename, self.maxseats, self.buttonpos))
players_who_post_antes = set([x[0] for x in self.actions['ANTES']])
for player in [x for x in self.players if x[1] in players_who_post_antes]:
#Only print stacks of players who do something preflop
print >>fh, _("Seat %s: %s ($%s)" %(player[0], player[1], player[2]))
if 'THIRD' in self.actions:
print >>fh, _("*** 3RD STREET ***")
for act in self.actions['THIRD']:
self.printActionLine(act, fh)
if 'FOURTH' in self.actions:
print >>fh, _("*** 4TH STREET ***")
for act in self.actions['FOURTH']:
self.printActionLine(act, fh)
if 'FIFTH' in self.actions:
print >>fh, _("*** 5TH STREET ***")
for act in self.actions['FIFTH']:
self.printActionLine(act, fh)
if 'SIXTH' in self.actions:
print >>fh, _("*** 6TH STREET ***")
for act in self.actions['SIXTH']:
self.printActionLine(act, fh)
if 'SEVENTH' in self.actions:
print >>fh, _("*** 7TH STREET ***")
for act in self.actions['SEVENTH']:
self.printActionLine(act, fh)
#Some sites don't have a showdown section so we have to figure out if there should be one
# The logic for a showdown is: at the end of river action there are at least two players in the hand
# we probably don't need a showdown section in pseudo stars format for our filtering purposes
if 'SHOWDOWN' in self.actions:
print >>fh, _("*** SHOW DOWN ***")
# print >>fh, "DEBUG: what do they show"
# Current PS format has the lines:
# Uncalled bet ($111.25) returned to s0rrow
# s0rrow collected $5.15 from side pot
# stervels: shows [Ks Qs] (two pair, Kings and Queens)
# stervels collected $45.35 from main pot
# Immediately before the summary.
# The current importer uses those lines for importing winning rather than the summary
for name in self.pot.returned:
print >>fh, _("Uncalled bet ($%s) returned to %s" %(self.pot.returned[name],name))
for entry in self.collected:
print >>fh, _("%s collected $%s from x pot" %(entry[0], entry[1]))
print >>fh, _("*** SUMMARY ***")
print >>fh, "%s | Rake $%.2f" % (self.pot, self.rake)
#print >>fh, _("Total pot $%s | Rake $%.2f" % (self.totalpot, self.rake)) # TODO: side pots
board = []
for s in self.board.values():
board += s
if board: # sometimes hand ends preflop without a board
print >>fh, _("Board [%s]" % (" ".join(board)))
for player in [x for x in self.players if x[1] in players_who_post_antes]:
seatnum = player[0]
name = player[1]
if name in self.collectees and name in self.shown:
print >>fh, _("Seat %d: %s showed [%s] and won ($%s)" % (seatnum, name, " ".join(self.holecards[name]), self.collectees[name]))
elif name in self.collectees:
print >>fh, _("Seat %d: %s collected ($%s)" % (seatnum, name, self.collectees[name]))
elif name in self.shown:
print >>fh, _("Seat %d: %s showed [%s]" % (seatnum, name, " ".join(self.holecards[name])))
elif name in self.folded:
print >>fh, _("Seat %d: %s folded" % (seatnum, name))
else:
print >>fh, _("Seat %d: %s mucked" % (seatnum, name))
print >>fh, "\n\n"
# TODO:
# logic for side pots
# logic for which players get to showdown
# I'm just not sure we need to do this so heavily.. and if we do, it's probably better to use pokerlib
#if self.holecards[player[1]]: # empty list default is false
#hole = self.holecards[player[1]]
##board = []
##for s in self.board.values():
##board += s
##playerhand = self.bestHand('hi', board+hole)
##print "Seat %d: %s showed %s and won/lost with %s" % (player[0], player[1], hole, playerhand)
#print "Seat %d: %s showed %s" % (player[0], player[1], hole)
#else:
#print "Seat %d: %s mucked or folded" % (player[0], player[1])
def printHand(self):

View File

@ -117,9 +117,12 @@ class HandHistoryConverter:
return
self.obs = self.obs.replace('\r\n', '\n')
outfile = open(self.ofile, 'w')
self.gametype = self.determineGameType()
if self.gametype == None:
print "Unknown game type from file, aborting on this file."
return
self.hands = self.splitFileIntoHands()
outfile = open(self.ofile, 'w')
for hand in self.hands:
#print "\nDEBUG: Input:\n"+hand.string
self.readHandInfo(hand)