From 994f0fdcccb28200f7b6b185d70f57005ed73ae6 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 4 Jun 2010 03:02:07 +0800 Subject: [PATCH] Modify recent patch from Steffen adding fold stats - Remove added whitespace - Reformatted debug strings in preferred printf style (and starting with DEBUG:) - Swapped len(aggrers)>0 and i>0 for short circuit evaluation, and reformatted spacing for consistent coding style -- (NOTE: for NLHE this will definitely be faster as less hands go to flop - may be slower for limit games) Also added a couple of comments near enumerate() calls about 2.5 to 2.6 syntax --- pyfpdb/DerivedStats.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index a951d0b7..c36201e5 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -139,6 +139,8 @@ class DerivedStats(): self.handsplayers[player[1]]['seatNo'] = player[0] self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2])) + # XXX: enumerate(list, start=x) is python 2.6 syntax; 'start' + #for i, street in enumerate(hand.actionStreets[2:], start=1): for i, street in enumerate(hand.actionStreets[2:]): self.seen(self.hand, i+1) @@ -382,6 +384,7 @@ class DerivedStats(): CG: CheckCall would be a much better name for this. """ + # XXX: enumerate(list, start=x) is python 2.6 syntax; 'start' #for i, street in enumerate(hand.actionStreets[2:], start=1): for i, street in enumerate(hand.actionStreets[2:]): actions = hand.actions[hand.actionStreets[i+1]] @@ -412,7 +415,7 @@ class DerivedStats(): aggrers = set() others = set() # Growl - actionStreets contains 'BLINDSANTES', which isn't actually an action street - + firstAggrMade=False for act in hand.actions[hand.actionStreets[i+1]]: if firstAggrMade: @@ -427,11 +430,12 @@ class DerivedStats(): self.handsplayers[player[1]]['street%sAggr' % i] = True else: self.handsplayers[player[1]]['street%sAggr' % i] = False - - if len(aggrers)>0 and i>0: + + if i > 0 and len(aggrers) > 0: for playername in others: self.handsplayers[playername]['otherRaisedStreet%s' % i] = True - #print "otherRaised detected on handid "+str(hand.handid)+" for "+playername+" on street "+str(i) + #print "DEBUG: otherRaised detected on handid %s for %s on actionStreet[%s]: %s" + # %(hand.handid, playername, hand.actionStreets[i+1], i) def calls(self, hand, i): callers = [] @@ -445,15 +449,16 @@ class DerivedStats(): for act in hand.actions[hand.actionStreets[i+1]]: if act[1] in ('bets'): self.handsplayers[act[0]]['street%sBets' % i] = 1 + self.handsplayers[act[0]]['street%sBets' % i] - + def folds(self, hand, i): for act in hand.actions[hand.actionStreets[i+1]]: if act[1] in ('folds'): if self.handsplayers[act[0]]['otherRaisedStreet%s' % i] == True: self.handsplayers[act[0]]['foldToOtherRaisedStreet%s' % i] = True - #print "fold detected on handid "+str(hand.handid)+" for "+act[0]+" on street "+str(i) - + #print "DEBUG: fold detected on handid %s for %s on actionStreet[%s]: %s" + # %(hand.handid, act[0],hand.actionStreets[i+1], i) + def countPlayers(self, hand): pass