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

This commit is contained in:
Eratosthenes 2009-12-05 19:16:36 -05:00
commit b483686019
4 changed files with 91 additions and 9 deletions

View File

@ -149,6 +149,42 @@ class DerivedStats():
for i, card in enumerate(hcs[:7], 1): for i, card in enumerate(hcs[:7], 1):
self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card) self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card)
# position,
#Stud 3rd street card test
# denny501: brings in for $0.02
# s0rrow: calls $0.02
# TomSludge: folds
# Soroka69: calls $0.02
# rdiezchang: calls $0.02 (Seat 8)
# u.pressure: folds (Seat 1)
# 123smoothie: calls $0.02
# gashpor: calls $0.02
# tourneyTypeId,
# startCards,
# street0_3BChance,street0_3BDone,
# otherRaisedStreet1-4
# foldToOtherRaisedStreet1-4
# stealAttemptChance,stealAttempted,
# foldBbToStealChance,foldedBbToSteal,
# foldSbToStealChance,foldedSbToSteal,
# foldToStreet1-4CBChance, foldToStreet1-4CBDone,
# street1-4CheckCallRaiseChance, street1-4CheckCallRaiseDone,
# Additional stats
# 3betSB, 3betBB
# Squeeze, Ratchet?
def getPosition(hand, seat):
"""Returns position value like 'B', 'S', 0, 1, ..."""
# Flop/Draw games with blinds
# Need a better system???
# -2 BB - B (all)
# -1 SB - S (all)
# 0 Button
# 1 Cutoff
# 2 Hijack
def assembleHudCache(self, hand): def assembleHudCache(self, hand):
pass pass

View File

@ -71,6 +71,8 @@ follow : whether to tail -f the input"""
self.out_path = out_path self.out_path = out_path
self.processedHands = [] self.processedHands = []
self.numHands = 0
self.numErrors = 0
# Tourney object used to store TourneyInfo when called to deal with a Summary file # Tourney object used to store TourneyInfo when called to deal with a Summary file
self.tourney = None self.tourney = None
@ -135,17 +137,17 @@ Otherwise, finish at EOF.
return return
try: try:
numHands = 0 self.numHands = 0
numErrors = 0 self.numErrors = 0
if self.follow: if self.follow:
#TODO: See how summary files can be handled on the fly (here they should be rejected as before) #TODO: See how summary files can be handled on the fly (here they should be rejected as before)
log.info("Tailing '%s'" % self.in_path) log.info("Tailing '%s'" % self.in_path)
for handText in self.tailHands(): for handText in self.tailHands():
try: try:
self.processHand(handText) self.processHand(handText)
numHands += 1 self.numHands += 1
except FpdbParseError, e: except FpdbParseError, e:
numErrors += 1 self.numErrors += 1
log.warning("Failed to convert hand %s" % e.hid) log.warning("Failed to convert hand %s" % e.hid)
log.warning("Exception msg: '%s'" % str(e)) log.warning("Exception msg: '%s'" % str(e))
log.debug(handText) log.debug(handText)
@ -160,13 +162,13 @@ Otherwise, finish at EOF.
try: try:
self.processedHands.append(self.processHand(handText)) self.processedHands.append(self.processHand(handText))
except FpdbParseError, e: except FpdbParseError, e:
numErrors += 1 self.numErrors += 1
log.warning("Failed to convert hand %s" % e.hid) log.warning("Failed to convert hand %s" % e.hid)
log.warning("Exception msg: '%s'" % str(e)) log.warning("Exception msg: '%s'" % str(e))
log.debug(handText) log.debug(handText)
numHands = len(handsList) self.numHands = len(handsList)
endtime = time.time() endtime = time.time()
log.info("Read %d hands (%d failed) in %.3f seconds" % (numHands, numErrors, endtime - starttime)) log.info("Read %d hands (%d failed) in %.3f seconds" % (self.numHands, self.numErrors, endtime - starttime))
else: else:
self.parsedObjectType = "Summary" self.parsedObjectType = "Summary"
summaryParsingStatus = self.readSummaryInfo(handsList) summaryParsingStatus = self.readSummaryInfo(handsList)

View File

@ -434,8 +434,12 @@ class Importer:
self.pos_in_file[file] = hhc.getLastCharacterRead() self.pos_in_file[file] = hhc.getLastCharacterRead()
for hand in handlist: for hand in handlist:
#try, except duplicates here?
#hand.prepInsert() #hand.prepInsert()
hand.insert(self.database) hand.insert(self.database)
errors = getattr(hhc, 'numErrors')
stored = getattr(hhc, 'numHands')
else: else:
# conversion didn't work # conversion didn't work
# TODO: appropriate response? # TODO: appropriate response?

View File

@ -74,12 +74,52 @@ def testFlopImport():
# """regression-test-files/tour/Stars/Flop/NLHE-USD-MTT-5r-200710.txt""", site="PokerStars") # """regression-test-files/tour/Stars/Flop/NLHE-USD-MTT-5r-200710.txt""", site="PokerStars")
importer.addBulkImportImportFileOrDir( importer.addBulkImportImportFileOrDir(
"""regression-test-files/cash/Stars/Flop/PLO8-6max-USD-0.01-0.02-200911.txt""", site="PokerStars") """regression-test-files/cash/Stars/Flop/PLO8-6max-USD-0.01-0.02-200911.txt""", site="PokerStars")
#HID - 36185273365
# Besides the horrible play it contains lots of useful cases
# Preflop: raise, then 3bet chance for seat 2
# Flop: Checkraise by hero, 4bet chance not taken by villain
# Turn: Turn continuation bet by hero, called
# River: hero (continuation bets?) all-in and is not called
importer.addBulkImportImportFileOrDir(
"""regression-test-files/cash/Stars/Flop/NLHE-6max-USD-0.05-0.10-200912.Stats-comparision.txt""", site="PokerStars")
importer.setCallHud(False) importer.setCallHud(False)
(stored, dups, partial, errs, ttime) = importer.runImport() (stored, dups, partial, errs, ttime) = importer.runImport()
print "DEBUG: stored: %s dups: %s partial: %s errs: %s ttime: %s" %(stored, dups, partial, errs, ttime)
importer.clearFileList() importer.clearFileList()
# Should actually do some testing here q = """SELECT
assert 1 == 1 s.name,
g.category,
g.base,
g.type,
g.limitType,
g.hilo,
round(g.smallBlind / 100.0,2) as sb,
round(g.bigBlind / 100.0,2) as bb,
round(g.smallBet / 100.0,2) as SB,
round(g.bigBet / 100.0,2) as BB,
s.currency,
hp.playerId,
hp.sawShowdown
FROM
Hands as h,
Sites as s,
Gametypes as g,
HandsPlayers as hp,
Players as p
WHERE
h.siteHandNo = 36185273365
and g.id = h.gametypeid
and hp.handid = h.id
and p.id = hp.playerid
and s.id = p.siteid"""
c = db.get_cursor()
c.execute(q)
result = c.fetchall()
print "DEBUG: result: %s" %result
assert 1 == 0
def testStudImport(): def testStudImport():
db.recreate_tables() db.recreate_tables()