From feeb70594acb69bbaaeb96f9b844224977a0b822 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 15 Feb 2010 22:54:02 +0000 Subject: [PATCH 1/8] re-fix steal stats --- pyfpdb/DerivedStats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 166034a5..21c6cddf 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -285,9 +285,9 @@ class DerivedStats(): Fold to steal - folding blind after steal attemp wo any other callers or raisers """ steal_attempt = False - steal_positions = (1, 0, 'S') + steal_positions = ('1', '0', 'S') if hand.gametype['base'] == 'stud': - steal_positions = (2, 1, 0) + steal_positions = ('2', '1', '0') for action in hand.actions[hand.actionStreets[1]]: pname, act = action[0], action[1] posn = self.handsplayers[pname]['position'] From 4993b6619e8a3197455ef487966eeb7076397b04 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 15 Feb 2010 22:57:59 +0000 Subject: [PATCH 2/8] improve position set routine to cover folding to BB and missing SB --- pyfpdb/DerivedStats.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 21c6cddf..e9a3af45 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -195,25 +195,39 @@ class DerivedStats(): # #This function is going to get it wrong when there in situations where there # is no small blind. I can live with that. - positions = [7, 6, 5, 4, 3, 2, 1, 0, 'S', 'B'] actions = hand.actions[hand.holeStreets[0]] + # Note: pfbao list may not include big blind if all others folded players = self.pfbao(actions) - seats = len(players) - map = [] + if hand.gametype['base'] == 'stud': + positions = [7, 6, 5, 4, 3, 2, 1, 0, 'S', 'B'] + seats = len(players) + map = [] # Could posibly change this to be either -2 or -1 depending if they complete or bring-in # First player to act is -1, last player is 0 for 6 players it should look like: # ['S', 4, 3, 2, 1, 0] map = positions[-seats-1:-1] # Copy required positions from postions array anding in -1 map = map[-1:] + map[0:-1] # and move the -1 to the start of that array - else: - # For 6 players is should look like: - # [3, 2, 1, 0, 'S', 'B'] - map = positions[-seats:] # Copy required positions from array ending in -2 - for i, player in enumerate(players): - #print "player %s in posn %s" % (player, str(map[i])) - self.handsplayers[player]['position'] = map[i] + for i, player in enumerate(players): + #print "player %s in posn %s" % (player, str(map[i])) + self.handsplayers[player]['position'] = map[i] + else: + # set blinds first, then others from pfbao list, avoids problem if bb + # is missing from pfbao list or if there is no small blind + bb = [x[0] for x in hand.actions[hand.actionStreets[0]] if x[2] == 'big blind'] + sb = [x[0] for x in hand.actions[hand.actionStreets[0]] if x[2] == 'small blind'] + # if there are > 1 sb or bb only the first is used! + if bb: + self.handsplayers[bb[0]]['position'] = 'B' + if bb[0] in players: players.remove(bb[0]) + if sb: + self.handsplayers[sb[0]]['position'] = 'S' + if sb[0] in players: players.remove(sb[0]) + + #print "bb =", bb, "sb =", sb, "players =", players + for i,player in enumerate(reversed(players)): + self.handsplayers[player]['position'] = str(i) def assembleHudCache(self, hand): # No real work to be done - HandsPlayers data already contains the correct info From 78dc7ab468b7da1270ab5051ae9674655f60211e Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 15 Feb 2010 23:37:34 +0000 Subject: [PATCH 3/8] improve sawshowdown stat --- pyfpdb/DerivedStats.py | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index e9a3af45..d7ded83b 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -254,6 +254,7 @@ class DerivedStats(): # The number of unique players in the list per street gives the value for playersAtStreetXXX # FIXME?? - This isn't couting people that are all in - at least showdown needs to reflect this + # ... new code below hopefully fixes this self.hands['playersAtStreet1'] = 0 self.hands['playersAtStreet2'] = 0 @@ -261,23 +262,31 @@ class DerivedStats(): self.hands['playersAtStreet4'] = 0 self.hands['playersAtShowdown'] = 0 - alliners = set() - for (i, street) in enumerate(hand.actionStreets[2:]): - actors = set() - for action in hand.actions[street]: - if len(action) > 2 and action[-1]: # allin - alliners.add(action[0]) - actors.add(action[0]) - if len(actors)==0 and len(alliners)<2: - alliners = set() - self.hands['playersAtStreet%d' % (i+1)] = len(set.union(alliners, actors)) - - actions = hand.actions[hand.actionStreets[-1]] - pas = set.union(self.pfba(actions) - self.pfba(actions, l=('folds',)), alliners) - self.hands['playersAtShowdown'] = len(pas) +# alliners = set() +# for (i, street) in enumerate(hand.actionStreets[2:]): +# actors = set() +# for action in hand.actions[street]: +# if len(action) > 2 and action[-1]: # allin +# alliners.add(action[0]) +# actors.add(action[0]) +# if len(actors)==0 and len(alliners)<2: +# alliners = set() +# self.hands['playersAtStreet%d' % (i+1)] = len(set.union(alliners, actors)) +# +# actions = hand.actions[hand.actionStreets[-1]] +# print "p_actions:", self.pfba(actions), "p_folds:", self.pfba(actions, l=('folds',)), "alliners:", alliners +# pas = set.union(self.pfba(actions) - self.pfba(actions, l=('folds',)), alliners) + + p_in = set(x[1] for x in hand.players) + for (i, street) in enumerate(hand.actionStreets): + actions = hand.actions[street] + p_in = p_in - self.pfba(actions, l=('folds',)) + self.hands['playersAtStreet%d' % (i-1)] = len(p_in) + + self.hands['playersAtShowdown'] = len(p_in) if self.hands['playersAtShowdown'] > 1: - for player in pas: + for player in p_in: self.handsplayers[player]['sawShowdown'] = True def streetXRaises(self, hand): From 797f04aaab715c820dee94892c07176dfd113a87 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Tue, 16 Feb 2010 23:13:12 +0000 Subject: [PATCH 4/8] fix problem with position stats in sqlite --- pyfpdb/GuiPlayerStats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index cb94859d..f7789164 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -520,7 +520,7 @@ class GuiPlayerStats (threading.Thread): blindtest = str(tuple(nolims)) blindtest = blindtest.replace("L", "") blindtest = blindtest.replace(",)",")") - bbtest = bbtest + blindtest + ' ) )' + bbtest = bbtest + blindtest + ' ) ) )' else: bbtest = bbtest + '(-1) ) )' if type == 'ring': @@ -539,7 +539,7 @@ class GuiPlayerStats (threading.Thread): query = query.replace("", "") groupLevels = "show" not in str(limits) if groupLevels: - query = query.replace("", "-1") + query = query.replace("", "p.name") else: query = query.replace("", "h.gameTypeId") From 074a4e751eb203001984dc499b0b1fbc52619a58 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 17 Feb 2010 19:25:04 +0000 Subject: [PATCH 5/8] make sure filter releases any db locks it has --- pyfpdb/Filters.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index 27e5a49d..c8e8e219 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -211,6 +211,9 @@ class Filters(threading.Thread): self.Button2.connect("clicked", self.callback['button2'], "clicked") self.Button2.set_sensitive(True) + # make sure any locks on db are released: + self.db.rollback() + def get_vbox(self): """returns the vbox of this thread""" return self.mainVBox From 55b6e1ee928b0ef76b3987fe41578935b4e8e638 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 17 Feb 2010 21:18:38 +0000 Subject: [PATCH 6/8] change button text --- pyfpdb/GuiPlayerStats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index f7789164..047c1ff1 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -81,7 +81,7 @@ class GuiPlayerStats (threading.Thread): self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display) self.filters.registerButton1Name("_Filters") self.filters.registerButton1Callback(self.showDetailFilter) - self.filters.registerButton2Name("_Refresh") + self.filters.registerButton2Name("_Refresh Stats") self.filters.registerButton2Callback(self.refreshStats) # ToDo: store in config From c31a2f6cefd2c8e8ba01686f435305c281f0b559 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 17 Feb 2010 21:44:05 +0000 Subject: [PATCH 7/8] undo earlier 're-fix' that broke things --- pyfpdb/DerivedStats.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index d7ded83b..699ad068 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -227,7 +227,7 @@ class DerivedStats(): #print "bb =", bb, "sb =", sb, "players =", players for i,player in enumerate(reversed(players)): - self.handsplayers[player]['position'] = str(i) + self.handsplayers[player]['position'] = i def assembleHudCache(self, hand): # No real work to be done - HandsPlayers data already contains the correct info @@ -305,12 +305,13 @@ class DerivedStats(): """Fills stealAttempt(Chance|ed, fold(Bb|Sb)ToSteal(Chance|) Steal attempt - open raise on positions 1 0 S - i.e. MP3, CO, BU, SB + (note: I don't think PT2 counts SB steals in HU hands, maybe we shouldn't?) Fold to steal - folding blind after steal attemp wo any other callers or raisers """ steal_attempt = False - steal_positions = ('1', '0', 'S') + steal_positions = (1, 0, 'S') if hand.gametype['base'] == 'stud': - steal_positions = ('2', '1', '0') + steal_positions = (2, 1, '0') for action in hand.actions[hand.actionStreets[1]]: pname, act = action[0], action[1] posn = self.handsplayers[pname]['position'] From 0cafb75c59af0a6380b32907fb9ede41bc34d66f Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 17 Feb 2010 23:29:50 +0000 Subject: [PATCH 8/8] finish previous undo --- pyfpdb/DerivedStats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 699ad068..dddbec8b 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -311,7 +311,7 @@ class DerivedStats(): steal_attempt = False steal_positions = (1, 0, 'S') if hand.gametype['base'] == 'stud': - steal_positions = (2, 1, '0') + steal_positions = (2, 1, 0) for action in hand.actions[hand.actionStreets[1]]: pname, act = action[0], action[1] posn = self.handsplayers[pname]['position']