From 9c5581caf0b72ed4f6dd9add312e7124baddd6cb Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Tue, 27 Jul 2010 22:27:18 +0100 Subject: [PATCH] rename stealattempt fields to raisefirstin and derive accordingly --- pyfpdb/Database.py | 8 +- pyfpdb/DerivedStats.py | 19 ++-- pyfpdb/GuiRingPlayerStats.py | 1 + pyfpdb/SQL.py | 194 +++++++++++++++++++++++++---------- 4 files changed, 154 insertions(+), 68 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 028097dd..b2350a07 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1651,8 +1651,8 @@ class Database: pdata[p]['foldToOtherRaisedStreet2'], pdata[p]['foldToOtherRaisedStreet3'], pdata[p]['foldToOtherRaisedStreet4'], - pdata[p]['stealAttemptChance'], - pdata[p]['stealAttempted'], + pdata[p]['raiseFirstInChance'], + pdata[p]['raisedFirstIn'], pdata[p]['foldBbToStealChance'], pdata[p]['foldedBbToSteal'], pdata[p]['foldSbToStealChance'], @@ -1732,8 +1732,8 @@ class Database: if pdata[p]['foldToOtherRaisedStreet4']: line[21] = 1 line[22] = pdata[p]['wonWhenSeenStreet1'] line[23] = pdata[p]['wonAtSD'] - if pdata[p]['stealAttemptChance']: line[24] = 1 - if pdata[p]['stealAttempted']: line[25] = 1 + if pdata[p]['raiseFirstInChance']: line[24] = 1 + if pdata[p]['raisedFirstIn']: line[25] = 1 if pdata[p]['foldBbToStealChance']: line[26] = 1 if pdata[p]['foldedBbToSteal']: line[27] = 1 if pdata[p]['foldSbToStealChance']: line[28] = 1 diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 7aab6c98..e92bfeaa 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -53,8 +53,8 @@ class DerivedStats(): self.handsplayers[player[1]]['street0_3BDone'] = False self.handsplayers[player[1]]['street0_4BChance'] = False self.handsplayers[player[1]]['street0_4BDone'] = False - self.handsplayers[player[1]]['stealAttemptChance'] = False - self.handsplayers[player[1]]['stealAttempted'] = False + self.handsplayers[player[1]]['raiseFirstInChance'] = False + self.handsplayers[player[1]]['raisedFirstIn'] = False self.handsplayers[player[1]]['foldBbToStealChance'] = False self.handsplayers[player[1]]['foldSbToStealChance'] = False self.handsplayers[player[1]]['foldedSbToSteal'] = False @@ -315,13 +315,14 @@ class DerivedStats(): self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street])) def calcSteals(self, hand): - """Fills stealAttempt(Chance|ed, fold(Bb|Sb)ToSteal(Chance|) + """Fills raiseFirstInChance|raisedFirstIn, fold(Bb|Sb)ToSteal(Chance|) - Steal attempt - open raise on positions 1 0 S - i.e. MP3, CO, BU, SB + Steal attempt - open raise on positions 1 0 S - i.e. 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 + raised = False steal_positions = (1, 0, 'S') if hand.gametype['base'] == 'stud': steal_positions = (2, 1, 0) @@ -341,11 +342,13 @@ class DerivedStats(): if steal_attempt and act != 'folds': break - if posn in steal_positions and not steal_attempt: - self.handsplayers[pname]['stealAttemptChance'] = True + if not steal_attempt and not raised: # if posn in steal_positions and not steal_attempt: + self.handsplayers[pname]['raiseFirstInChance'] = True if act in ('bets', 'raises'): - self.handsplayers[pname]['stealAttempted'] = True - steal_attempt = True + self.handsplayers[pname]['raisedFirstIn'] = True + raised = True + if posn in steal_positions: + steal_attempt = True if act == 'calls': break diff --git a/pyfpdb/GuiRingPlayerStats.py b/pyfpdb/GuiRingPlayerStats.py index f7d32355..765dda54 100644 --- a/pyfpdb/GuiRingPlayerStats.py +++ b/pyfpdb/GuiRingPlayerStats.py @@ -101,6 +101,7 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats): , ["aggfac", True, "AggFac", 1.0, "%2.2f", "str"] , ["aggfrq", True, "AggFreq", 1.0, "%3.1f", "str"] , ["conbet", True, "ContBet", 1.0, "%3.1f", "str"] + , ["rfi", True, "RFI", 1.0, "%3.1f", "str"] , ["steals", True, "Steals", 1.0, "%3.1f", "str"] , ["saw_f", True, "Saw_F", 1.0, "%3.1f", "str"] , ["sawsd", True, "SawSD", 1.0, "%3.1f", "str"] diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 59fa4378..fcebc5c9 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -598,8 +598,8 @@ class Sql: foldToOtherRaisedStreet3 BOOLEAN, foldToOtherRaisedStreet4 BOOLEAN, - stealAttemptChance BOOLEAN, - stealAttempted BOOLEAN, + raiseFirstInChance BOOLEAN, + raisedFirstIn BOOLEAN, foldBbToStealChance BOOLEAN, foldedBbToSteal BOOLEAN, foldSbToStealChance BOOLEAN, @@ -714,8 +714,8 @@ class Sql: foldToOtherRaisedStreet3 BOOLEAN, foldToOtherRaisedStreet4 BOOLEAN, - stealAttemptChance BOOLEAN, - stealAttempted BOOLEAN, + raiseFirstInChance BOOLEAN, + raisedFirstIn BOOLEAN, foldBbToStealChance BOOLEAN, foldedBbToSteal BOOLEAN, foldSbToStealChance BOOLEAN, @@ -829,8 +829,8 @@ class Sql: foldToOtherRaisedStreet3 INT, foldToOtherRaisedStreet4 INT, - stealAttemptChance INT, - stealAttempted INT, + raiseFirstInChance INT, + raisedFirstIn INT, foldBbToStealChance INT, foldedBbToSteal INT, foldSbToStealChance INT, @@ -1025,8 +1025,8 @@ class Sql: foldToOtherRaisedStreet3 INT, foldToOtherRaisedStreet4 INT, - stealAttemptChance INT, - stealAttempted INT, + raiseFirstInChance INT, + raisedFirstIn INT, foldBbToStealChance INT, foldedBbToSteal INT, foldSbToStealChance INT, @@ -1125,8 +1125,8 @@ class Sql: foldToOtherRaisedStreet3 INT, foldToOtherRaisedStreet4 INT, - stealAttemptChance INT, - stealAttempted INT, + raiseFirstInChance INT, + raisedFirstIn INT, foldBbToStealChance INT, foldedBbToSteal INT, foldSbToStealChance INT, @@ -1224,8 +1224,8 @@ class Sql: foldToOtherRaisedStreet3 INT, foldToOtherRaisedStreet4 INT, - stealAttemptChance INT, - stealAttempted INT, + raiseFirstInChance INT, + raisedFirstIn INT, foldBbToStealChance INT, foldedBbToSteal INT, foldSbToStealChance INT, @@ -1364,8 +1364,18 @@ class Sql: sum(hc.foldToOtherRaisedStreet4) AS f_freq_4, sum(hc.wonWhenSeenStreet1) AS w_w_s_1, sum(hc.wonAtSD) AS wmsd, - sum(hc.stealAttemptChance) AS steal_opp, - sum(hc.stealAttempted) AS steal, + sum(case hc.position + when 'S' then hc.raiseFirstInChance + when '0' then hc.raiseFirstInChance + when '1' then hc.raiseFirstInChance + else 0 + ) AS steal_opp, + sum(case hc.position + when 'S' then hc.raisedFirstIn + when '0' then hc.raisedFirstIn + when '1' then hc.raisedFirstIn + else 0 + ) AS steal, sum(hc.foldSbToStealChance) AS SBstolen, sum(hc.foldedSbToSteal) AS SBnotDef, sum(hc.foldBbToStealChance) AS BBstolen, @@ -1463,8 +1473,8 @@ class Sql: sum(hc.foldToOtherRaisedStreet4) AS f_freq_4, sum(hc.wonWhenSeenStreet1) AS w_w_s_1, sum(hc.wonAtSD) AS wmsd, - sum(hc.stealAttemptChance) AS steal_opp, - sum(hc.stealAttempted) AS steal, + sum(hc.raiseFirstInChance) AS steal_opp, + sum(hc.raisedFirstIn) AS steal, sum(hc.foldSbToStealChance) AS SBstolen, sum(hc.foldedSbToSteal) AS SBnotDef, sum(hc.foldBbToStealChance) AS BBstolen, @@ -1589,8 +1599,8 @@ class Sql: cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4, cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1, cast(hp2.wonAtSD as integer) AS wmsd, - cast(hp2.stealAttemptChance as integer) AS steal_opp, - cast(hp2.stealAttempted as integer) AS steal, + cast(hp2.raiseFirstInChance as integer) AS steal_opp, + cast(hp2.raisedFirstIn as integer) AS steal, cast(hp2.foldSbToStealChance as integer) AS SBstolen, cast(hp2.foldedSbToSteal as integer) AS SBnotDef, cast(hp2.foldBbToStealChance as integer) AS BBstolen, @@ -1691,8 +1701,8 @@ class Sql: cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4, cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1, cast(hp2.wonAtSD as integer) AS wmsd, - cast(hp2.stealAttemptChance as integer) AS steal_opp, - cast(hp2.stealAttempted as integer) AS steal, + cast(hp2.raiseFirstInChance as integer) AS steal_opp, + cast(hp2.raisedFirstIn as integer) AS steal, cast(hp2.foldSbToStealChance as integer) AS SBstolen, cast(hp2.foldedSbToSteal as integer) AS SBnotDef, cast(hp2.foldBbToStealChance as integer) AS BBstolen, @@ -1794,8 +1804,8 @@ class Sql: cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4, cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1, cast(hp2.wonAtSD as integer) AS wmsd, - cast(hp2.stealAttemptChance as integer) AS steal_opp, - cast(hp2.stealAttempted as integer) AS steal, + cast(hp2.raiseFirstInChance as integer) AS steal_opp, + cast(hp2.raisedFirstIn as integer) AS steal, cast(hp2.foldSbToStealChance as integer) AS SBstolen, cast(hp2.foldedSbToSteal as integer) AS SBnotDef, cast(hp2.foldBbToStealChance as integer) AS BBstolen, @@ -2026,11 +2036,35 @@ class Sql: ,case when sum(cast(hp.street0_3Bchance as integer)) = 0 then -999 else 100.0*sum(cast(hp.street0_3Bdone as integer))/sum(cast(hp.street0_3Bchance as integer)) end AS pf3 - ,case when sum(cast(hp.stealattemptchance as integer)) = 0 then -999 - else 100.0*sum(cast(hp.stealattempted as integer))/sum(cast(hp.stealattemptchance as integer)) + ,case when sum(cast(hp.raiseFirstInChance as integer)) = 0 then -999 + else 100.0 * sum(cast(hp.raisedFirstIn as integer)) / + sum(cast(hp.raiseFirstInChance as integer)) + end AS rfi + ,case when sum(case hp.position + when 'S' then cast(hp.raiseFirstInChance as integer) + when '0' then cast(hp.raiseFirstInChance as integer) + when '1' then cast(hp.raiseFirstInChance as integer) + else 0 + end + ) = 0 then -999 + else 100.0 * + sum(case hp.position + when 'S' then cast(hp.raisedFirstIn as integer) + when '0' then cast(hp.raisedFirstIn as integer) + when '1' then cast(hp.raisedFirstIn as integer) + else 0 + end + ) / + sum(case hp.position + when 'S' then cast(hp.raiseFirstInChance as integer) + when '0' then cast(hp.raiseFirstInChance as integer) + when '1' then cast(hp.raiseFirstInChance as integer) + else 0 + end + ) end AS steals - ,100.0*sum(cast(hp.street1Seen as integer))/count(1) AS saw_f - ,100.0*sum(cast(hp.sawShowdown as integer))/count(1) AS sawsd + ,100.0*sum(cast(hp.street1Seen as integer))/count(1) AS saw_f + ,100.0*sum(cast(hp.sawShowdown as integer))/count(1) AS sawsd ,case when sum(cast(hp.street1Seen as integer)) = 0 then -999 else 100.0*sum(cast(hp.sawShowdown as integer))/sum(cast(hp.street1Seen as integer)) end AS wtsdwsf @@ -2123,8 +2157,32 @@ class Sql: ,case when sum(cast(hp.street0_3Bchance as integer)) = 0 then -999 else 100.0*sum(cast(hp.street0_3Bdone as integer))/sum(cast(hp.street0_3Bchance as integer)) end AS pf3 - ,case when sum(cast(hp.stealattemptchance as integer)) = 0 then -999 - else 100.0*sum(cast(hp.stealattempted as integer))/sum(cast(hp.stealattemptchance as integer)) + ,case when sum(cast(hp.raiseFirstInChance as integer)) = 0 then -999 + else 100.0 * sum(cast(hp.raisedFirstIn as integer)) / + sum(cast(hp.raiseFirstInChance as integer)) + end AS rfi + ,case when sum(case hp.position + when 'S' then cast(hp.raiseFirstInChance as integer) + when '0' then cast(hp.raiseFirstInChance as integer) + when '1' then cast(hp.raiseFirstInChance as integer) + else 0 + end + ) = 0 then -999 + else 100.0 * + sum(case hp.position + when 'S' then cast(hp.raisedFirstIn as integer) + when '0' then cast(hp.raisedFirstIn as integer) + when '1' then cast(hp.raisedFirstIn as integer) + else 0 + end + ) / + sum(case hp.position + when 'S' then cast(hp.raiseFirstInChance as integer) + when '0' then cast(hp.raiseFirstInChance as integer) + when '1' then cast(hp.raiseFirstInChance as integer) + else 0 + end + ) end AS steals ,100.0*sum(cast(hp.street1Seen as integer))/count(1) AS saw_f ,100.0*sum(cast(hp.sawShowdown as integer))/count(1) AS sawsd @@ -2221,8 +2279,32 @@ class Sql: ,case when sum(cast(hp.street0_3Bchance as integer)) = 0 then -999 else 100.0*sum(cast(hp.street0_3Bdone as integer))/sum(cast(hp.street0_3Bchance as integer)) end AS pf3 - ,case when sum(cast(hp.stealattemptchance as integer)) = 0 then -999 - else 100.0*sum(cast(hp.stealattempted as integer))/sum(cast(hp.stealattemptchance as integer)) + ,case when sum(cast(hp.raiseFirstInChance as integer)) = 0 then -999 + else 100.0 * sum(cast(hp.raisedFirstIn as integer)) / + sum(cast(hp.raiseFirstInChance as integer)) + end AS rfi + ,case when sum(case hp.position + when 'S' then cast(hp.raiseFirstInChance as integer) + when '0' then cast(hp.raiseFirstInChance as integer) + when '1' then cast(hp.raiseFirstInChance as integer) + else 0 + end + ) = 0 then -999 + else 100.0 * + sum(case hp.position + when 'S' then cast(hp.raisedFirstIn as integer) + when '0' then cast(hp.raisedFirstIn as integer) + when '1' then cast(hp.raisedFirstIn as integer) + else 0 + end + ) / + sum(case hp.position + when 'S' then cast(hp.raiseFirstInChance as integer) + when '0' then cast(hp.raiseFirstInChance as integer) + when '1' then cast(hp.raiseFirstInChance as integer) + else 0 + end + ) end AS steals ,100.0*sum(cast(hp.street1Seen as integer))/count(1) AS saw_f ,100.0*sum(cast(hp.sawShowdown as integer))/count(1) AS sawsd @@ -2380,8 +2462,8 @@ class Sql: ,case when sum(street0_3Bchance) = 0 then '0' else format(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1) end AS pf3 - ,case when sum(stealattemptchance) = 0 then '-' - else format(100.0*sum(stealattempted)/sum(stealattemptchance),1) + ,case when sum(raiseFirstInChance) = 0 then '-' + else format(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1) end AS steals ,format(100.0*sum(street1Seen)/sum(HDs),1) AS saw_f ,format(100.0*sum(sawShowdown)/sum(HDs),1) AS sawsd @@ -2485,8 +2567,8 @@ class Sql: ,case when sum(street0_3Bchance) = 0 then '0' else to_char(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),'90D0') end AS pf3 - ,case when sum(stealattemptchance) = 0 then '-' - else to_char(100.0*sum(stealattempted)/sum(stealattemptchance),'90D0') + ,case when sum(raiseFirstInChance) = 0 then '-' + else to_char(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),'90D0') end AS steals ,to_char(100.0*sum(street1Seen)/sum(HDs),'90D0') AS saw_f ,to_char(100.0*sum(sawShowdown)/sum(HDs),'90D0') AS sawsd @@ -2608,8 +2690,8 @@ class Sql: ,case when sum(street0_3Bchance) = 0 then '0' else format(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1) end AS pf3 - ,case when sum(stealattemptchance) = 0 then '-' - else format(100.0*sum(stealattempted)/sum(stealattemptchance),1) + ,case when sum(raiseFirstInChance) = 0 then '-' + else format(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1) end AS steals ,format(100.0*sum(street1Seen)/sum(HDs),1) AS saw_f ,format(100.0*sum(sawShowdown)/sum(HDs),1) AS sawsd @@ -2742,8 +2824,8 @@ class Sql: ,case when sum(street0_3Bchance) = 0 then '0' else to_char(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),'90D0') end AS pf3 - ,case when sum(stealattemptchance) = 0 then '-' - else to_char(100.0*sum(stealattempted)/sum(stealattemptchance),'90D0') + ,case when sum(raiseFirstInChance) = 0 then '-' + else to_char(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),'90D0') end AS steals ,to_char(round(100.0*sum(street1Seen)/sum(HDs)),'90D0') AS saw_f ,to_char(round(100.0*sum(sawShowdown)/sum(HDs)),'90D0') AS sawsd @@ -2922,8 +3004,8 @@ class Sql: ,foldToOtherRaisedStreet2 ,foldToOtherRaisedStreet3 ,foldToOtherRaisedStreet4 - ,stealAttemptChance - ,stealAttempted + ,raiseFirstInChance + ,raisedFirstIn ,foldBbToStealChance ,foldedBbToSteal ,foldSbToStealChance @@ -3012,8 +3094,8 @@ class Sql: ,sum(foldToOtherRaisedStreet2) ,sum(foldToOtherRaisedStreet3) ,sum(foldToOtherRaisedStreet4) - ,sum(stealAttemptChance) - ,sum(stealAttempted) + ,sum(raiseFirstInChance) + ,sum(raisedFirstIn) ,sum(foldBbToStealChance) ,sum(foldedBbToSteal) ,sum(foldSbToStealChance) @@ -3103,8 +3185,8 @@ class Sql: ,foldToOtherRaisedStreet2 ,foldToOtherRaisedStreet3 ,foldToOtherRaisedStreet4 - ,stealAttemptChance - ,stealAttempted + ,raiseFirstInChance + ,raisedFirstIn ,foldBbToStealChance ,foldedBbToSteal ,foldSbToStealChance @@ -3193,8 +3275,8 @@ class Sql: ,sum(CAST(foldToOtherRaisedStreet2 as integer)) ,sum(CAST(foldToOtherRaisedStreet3 as integer)) ,sum(CAST(foldToOtherRaisedStreet4 as integer)) - ,sum(CAST(stealAttemptChance as integer)) - ,sum(CAST(stealAttempted as integer)) + ,sum(CAST(raisedFirstInChance as integer)) + ,sum(CAST(raisedFirstIn as integer)) ,sum(CAST(foldBbToStealChance as integer)) ,sum(CAST(foldedBbToSteal as integer)) ,sum(CAST(foldSbToStealChance as integer)) @@ -3284,8 +3366,8 @@ class Sql: ,foldToOtherRaisedStreet2 ,foldToOtherRaisedStreet3 ,foldToOtherRaisedStreet4 - ,stealAttemptChance - ,stealAttempted + ,raiseFirstInChance + ,raisedFirstIn ,foldBbToStealChance ,foldedBbToSteal ,foldSbToStealChance @@ -3374,8 +3456,8 @@ class Sql: ,sum(CAST(foldToOtherRaisedStreet2 as integer)) ,sum(CAST(foldToOtherRaisedStreet3 as integer)) ,sum(CAST(foldToOtherRaisedStreet4 as integer)) - ,sum(CAST(stealAttemptChance as integer)) - ,sum(CAST(stealAttempted as integer)) + ,sum(CAST(raiseFirstInChance as integer)) + ,sum(CAST(raisedFirstIn as integer)) ,sum(CAST(foldBbToStealChance as integer)) ,sum(CAST(foldedBbToSteal as integer)) ,sum(CAST(foldSbToStealChance as integer)) @@ -3465,8 +3547,8 @@ class Sql: foldToOtherRaisedStreet4, wonWhenSeenStreet1, wonAtSD, - stealAttemptChance, - stealAttempted, + raiseFirstInChance, + raisedFirstIn, foldBbToStealChance, foldedBbToSteal, foldSbToStealChance, @@ -3554,8 +3636,8 @@ class Sql: foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s, wonWhenSeenStreet1=wonWhenSeenStreet1+%s, wonAtSD=wonAtSD+%s, - stealAttemptChance=stealAttemptChance+%s, - stealAttempted=stealAttempted+%s, + raiseFirstInChance=raiseFirstInChance+%s, + raisedFirstIn=raisedFirstIn+%s, foldBbToStealChance=foldBbToStealChance+%s, foldedBbToSteal=foldedBbToSteal+%s, foldSbToStealChance=foldSbToStealChance+%s, @@ -3873,8 +3955,8 @@ class Sql: foldToOtherRaisedStreet2, foldToOtherRaisedStreet3, foldToOtherRaisedStreet4, - stealAttemptChance, - stealAttempted, + raiseFirstInChance, + raisedFirstIn, foldBbToStealChance, foldedBbToSteal, foldSbToStealChance,