From db6f7989a98f474beafd002651c9e6ae74e12efe Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 10 Jun 2010 21:00:30 +0200 Subject: [PATCH] Street(x)Bet street(x)Calls were stored in (db.)handplayers. They were not yet available in (db.)hudchache. Using the Bets and Call, together with stree(x)Agression the aggression frequency and aggression factor can be calculated. --- pyfpdb/Database.py | 25 +++++++--- pyfpdb/DerivedStats.py | 1 + pyfpdb/SQL.py | 108 +++++++++++++++++++++++++++++++++++++++-- pyfpdb/Stats.py | 12 ++--- 4 files changed, 130 insertions(+), 16 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 01b78fe5..8ee07889 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1662,7 +1662,7 @@ class Database: #print "DEBUG: %s %s %s" %(hid, pids, pdata) inserts = [] for p in pdata: - line = [0]*61 + line = [0]*71 line[0] = 1 # HDs if pdata[p]['street0VPI']: line[1] = 1 @@ -1719,13 +1719,24 @@ class Database: if pdata[p]['street3CheckCallRaiseDone']: line[52] = 1 if pdata[p]['street4CheckCallRaiseChance']: line[53] = 1 if pdata[p]['street4CheckCallRaiseDone']: line[54] = 1 - line[55] = gid # gametypeId - line[56] = pids[p] # playerId - line[57] = len(pids) # activeSeats + if pdata[p]['street0Calls']: line[55] = 1 + if pdata[p]['street1Calls']: line[56] = 1 + if pdata[p]['street2Calls']: line[57] = 1 + if pdata[p]['street3Calls']: line[58] = 1 + if pdata[p]['street4Calls']: line[59] = 1 + if pdata[p]['street0Bets']: line[60] = 1 + if pdata[p]['street1Bets']: line[61] = 1 + if pdata[p]['street2Bets']: line[62] = 1 + if pdata[p]['street3Bets']: line[63] = 1 + if pdata[p]['street4Bets']: line[64] = 1 + + line[65] = gid # gametypeId + line[66] = pids[p] # playerId + line[67] = len(pids) # activeSeats pos = {'B':'B', 'S':'S', 0:'D', 1:'C', 2:'M', 3:'M', 4:'M', 5:'E', 6:'E', 7:'E', 8:'E', 9:'E' } - line[58] = pos[pdata[p]['position']] - line[59] = pdata[p]['tourneyTypeId'] - line[60] = styleKey # styleKey + line[68] = pos[pdata[p]['position']] + line[69] = pdata[p]['tourneyTypeId'] + line[70] = styleKey # styleKey inserts.append(line) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index b222fc01..d730c232 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -62,6 +62,7 @@ class DerivedStats(): for i in range(5): self.handsplayers[player[1]]['street%dCalls' % i] = 0 self.handsplayers[player[1]]['street%dBets' % i] = 0 + self.handsplayers[player[1]]['street%dRaises' % i] = 0 for i in range(1,5): self.handsplayers[player[1]]['street%dCBChance' %i] = False self.handsplayers[player[1]]['street%dCBDone' %i] = False diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index ad8ea025..bc337b9c 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -1337,6 +1337,16 @@ class Sql: sum(hc.street3CheckCallRaiseDone) AS ccr_3, sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4, sum(hc.street4CheckCallRaiseDone) AS ccr_4 + sum(hc.street0Calls) AS call_0, + sum(hc.street1Calls) AS call_1, + sum(hc.street2Calls) AS call_2, + sum(hc.street3Calls) AS call_3, + sum(hc.street4Calls) AS call_4, + sum(hc.street0Bets) AS bet_0, + sum(hc.street1Bets) AS bet_1, + sum(hc.street2Bets) AS bet_2, + sum(hc.street3Bets) AS bet_3, + sum(hc.street4Bets) AS bet_4 FROM Hands h INNER JOIN HandsPlayers hp ON (hp.handId = h.id) INNER JOIN HudCache hc ON ( hc.PlayerId = hp.PlayerId+0 @@ -1420,7 +1430,17 @@ class Sql: sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3, sum(hc.street3CheckCallRaiseDone) AS ccr_3, sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4, - sum(hc.street4CheckCallRaiseDone) AS ccr_4 + sum(hc.street4CheckCallRaiseDone) AS ccr_4, + sum(hc.street0Calls) AS call_0, + sum(hc.street1Calls) AS call_1, + sum(hc.street2Calls) AS call_2, + sum(hc.street3Calls) AS call_3, + sum(hc.street4Calls) AS call_4, + sum(hc.street0Bets) AS bet_0, + sum(hc.street1Bets) AS bet_1, + sum(hc.street2Bets) AS bet_2, + sum(hc.street3Bets) AS bet_3, + sum(hc.street4Bets) AS bet_4 FROM Hands h INNER JOIN HandsPlayers hp ON (hp.handId = h.id) INNER JOIN HudCache hc ON (hc.playerId = hp.playerId) @@ -2759,6 +2779,16 @@ class Sql: ,street3CheckCallRaiseDone ,street4CheckCallRaiseChance ,street4CheckCallRaiseDone + ,street0Calls + ,street1Calls + ,street2Calls + ,street3Calls + ,street4Calls + ,street0Bets + ,street1Bets + ,street2Bets + ,street3Bets + ,street4Bets ) SELECT h.gametypeId ,hp.playerId @@ -2834,6 +2864,16 @@ class Sql: ,sum(street3CheckCallRaiseDone) ,sum(street4CheckCallRaiseChance) ,sum(street4CheckCallRaiseDone) + ,sum(street0Calls) + ,sum(street1Calls) + ,sum(street2Calls) + ,sum(street3Calls) + ,sum(street4Calls) + ,sum(street0Bets) + ,sum(street1Bets) + ,sum(street2Bets) + ,sum(street3Bets) + ,sum(street4Bets) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) @@ -2908,6 +2948,16 @@ class Sql: ,street3CheckCallRaiseDone ,street4CheckCallRaiseChance ,street4CheckCallRaiseDone + ,street0Calls + ,street1Calls + ,street2Calls + ,street3Calls + ,street4Calls + ,street0Bets + ,street1Bets + ,street2Bets + ,street3Bets + ,street4Bets ) SELECT h.gametypeId ,hp.playerId @@ -2983,6 +3033,16 @@ class Sql: ,sum(CAST(street3CheckCallRaiseDone as integer)) ,sum(CAST(street4CheckCallRaiseChance as integer)) ,sum(CAST(street4CheckCallRaiseDone as integer)) + ,sum(CAST(street0Calls as integer)) + ,sum(CAST(street1Calls as integer)) + ,sum(CAST(street2Calls as integer)) + ,sum(CAST(street3Calls as integer)) + ,sum(CAST(street4Calls as integer)) + ,sum(CAST(street0Bets as integer)) + ,sum(CAST(street1Bets as integer)) + ,sum(CAST(street2Bets as integer)) + ,sum(CAST(street3Bets as integer)) + ,sum(CAST(street4Bets as integer)) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) @@ -3057,6 +3117,16 @@ class Sql: ,street3CheckCallRaiseDone ,street4CheckCallRaiseChance ,street4CheckCallRaiseDone + ,street0Calls + ,street1Calls + ,street2Calls + ,street3Calls + ,street4Calls + ,street0Bets + ,street1Bets + ,street2Bets + ,street3Bets + ,street4Bets ) SELECT h.gametypeId ,hp.playerId @@ -3132,6 +3202,16 @@ class Sql: ,sum(CAST(street3CheckCallRaiseDone as integer)) ,sum(CAST(street4CheckCallRaiseChance as integer)) ,sum(CAST(street4CheckCallRaiseDone as integer)) + ,sum(CAST(street0Calls as integer)) + ,sum(CAST(street1Calls as integer)) + ,sum(CAST(street2Calls as integer)) + ,sum(CAST(street3Calls as integer)) + ,sum(CAST(street4Calls as integer)) + ,sum(CAST(street0Bets as integer)) + ,sum(CAST(street1Bets as integer)) + ,sum(CAST(street2Bets as integer)) + ,sum(CAST(street3Bets as integer)) + ,sum(CAST(street4Bets as integer)) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) @@ -3205,7 +3285,17 @@ class Sql: street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, - street4CheckCallRaiseDone) + street4CheckCallRaiseDone, + street0Calls, + street1Calls, + street2Calls, + street3Calls, + street4Calls, + street0Bets, + street1Bets, + street2Bets, + street3Bets, + street4Bets) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, @@ -3218,6 +3308,8 @@ class Sql: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, + %s, %s, %s, %s, %s, %s)""" self.query['update_hudcache'] = """ @@ -3276,7 +3368,17 @@ class Sql: street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s, street3CheckCallRaiseDone=street3CheckCallRaiseDone+%s, street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s, - street4CheckCallRaiseDone=street4CheckCallRaiseDone+%s + street4CheckCallRaiseDone=street4CheckCallRaiseDone+%s, + street0Calls=street0Calls+%s, + street1Calls=street1Calls+%s, + street2Calls=street2Calls+%s, + street3Calls=street3Calls+%s, + street4Calls=street4Calls+%s, + street0Bets=street0Bets+%s, + street1Bets=street1Bets+%s, + street2Bets=street2Bets+%s, + street3Bets=street3Bets+%s, + street4Bets=street4Bets+%s WHERE gametypeId+0=%s AND playerId=%s AND activeSeats=%s diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index be7e0485..616bdae4 100755 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -512,17 +512,17 @@ def agg_freq(stat_dict, player): """ Agression on the flop and all streets """ bet_raise = stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3'] + stat_dict[player]['aggr_4'] """ number post flop streets seen, this must be number of post-flop calls !! """ - post_saw = stat_dict[player]['saw_2'] + stat_dict[player]['saw_3'] + stat_dict[player]['saw_4'] + post_call = stat_dict[player]['call_2'] + stat_dict[player]['call_3'] + stat_dict[player]['call_4'] """ Number of post flop folds this info is not yet in the database """ post_fold = stat_dict[player]['f_freq_2'] + stat_dict[player]['f_freq_3'] + stat_dict[player]['f_freq_4'] - stat = float (bet_raise) / float(post_saw + post_fold) + stat = float (bet_raise) / float(post_call + post_fold + bet_raise) return (stat, '%3.1f' % (100*stat) + '%', 'afr=%3.1f' % (100*stat) + '%', 'agg_fr=%3.1f' % (100*stat) + '%', - '(%d/%d)' % (bet_raise, (post_saw + post_fold)), + '(%d/%d)' % (bet_raise, (post_call + post_fold + bet_raise)), 'Aggression Freq' ) except: @@ -541,15 +541,15 @@ def agg_fact(stat_dict, player): stat = 0.0 try: bet_raise = stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3'] + stat_dict[player]['aggr_4'] - post_saw = stat_dict[player]['saw_2'] + stat_dict[player]['saw_3'] + stat_dict[player]['saw_4'] + post_call = stat_dict[player]['call_2'] + stat_dict[player]['call_3'] + stat_dict[player]['call_4'] - stat = float (bet_raise) / float(post_saw-bet_raise) + stat = float (bet_raise) / float(post_call) return (stat, '%2.1f' % (stat) , 'afa=%2.1f' % (stat) , 'agg_fa=%2.1f' % (stat) , - '(%d/%d)' % (bet_raise, post_saw-bet_raise), + '(%d/%d)' % (bet_raise, post_call), 'Aggression Factor' ) except: