From 33e085cf8809990b9ad59371db316d646d73ceb4 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Thu, 7 Aug 2008 16:08:23 +0100 Subject: [PATCH] git17 - added fields to db+imp+tv: Won $ when seen flop and Won $ at Showdown. Seem to work fine, will verify properly later. REIMPORT is necessary after this update. cleaned table design a bit more removed actionCount from print_hand - this is useless. need to update regression-test/*.expected.txt accordingly --- docs/known-bugs-and-planned-features.txt | 5 +- docs/tabledesign.html | 68 ++++++++------------- pyfpdb/fpdb.py | 4 +- pyfpdb/fpdb_db.py | 4 +- pyfpdb/fpdb_parse_logic.py | 5 +- pyfpdb/fpdb_simple.py | 30 +++++++-- pyfpdb/table_viewer.py | 4 +- regression-test/PrintPlayerHudData.py | 6 ++ regression-test/ftp.6367428246.expected.txt | 2 + regression-test/ftp.6929537410.expected.txt | 2 + regression-test/ftp.6929553738.expected.txt | 2 + regression-test/print_hand.py | 2 +- 12 files changed, 77 insertions(+), 57 deletions(-) diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index d0d8d8fe..582cad9c 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -2,17 +2,16 @@ todolist (db=database, imp=importer, tv=tableviewer) before alpha ============ -verify PrintPlayerFlags for one player on at least 10 hands fix default pathes up to sensible ones catch index error, type error, file not found error update install instructions, include how to adapt default config and where to put it split python requirements, get deep links for windows DL for everything GUI license info -db+imp+tv W$SD (won $ when seeing showdown - partial win counts partially here) -db+imp+tv WwSF (Won when seen flop - partial taken into account) change action_no to be total for this street rather than just for one player. change .expected.txt files accordingly. calculate 3B/4B percentage (depends on above, currently its useless) +update regression testing to take into account everything new +add fpdb version string into db to detect outdated db format. before beta =========== diff --git a/docs/tabledesign.html b/docs/tabledesign.html index 497d7fa4..5ad16bdc 100644 --- a/docs/tabledesign.html +++ b/docs/tabledesign.html @@ -269,52 +269,25 @@ gametypes

- -

small_blind

- - -

int

- - -


-

+

small_blind

+

int

+


+ + +

big_blind

+

int

+


- -

big_blind

- - -

int

- - -


-

- +

small_bet

+

int

+


- -

small_bet

- - -

int

- - -


-

- - - - -

big_bet

- - -

int

- - -


-

- +

big_bet

+

int

+



@@ -746,7 +719,7 @@ far less relevant.

id

bigint

-

+


gametypeId

@@ -853,6 +826,17 @@ far less relevant.

int

number of hands where someone else raised River and the player folded

+ +

wonWhenSeenFlop

+

float

+

How many hands the player won after seeing the flop - this can be a "partial win" if the pot is split.
+ To be completely clear, this stores a hand count, NOT a money amount.

+ + +

wonAtSD

+

float

+

As wonPostFlop, but for showdown.

+

Table hands_actions

diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index b3730545..25d35251 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -343,9 +343,9 @@ blabla""") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: pre-alpha, git16") + self.window.set_title("Free Poker DB - version: pre-alpha, git17") self.window.set_border_width(1) - self.window.set_size_request(750,400) + self.window.set_size_request(800,400) self.window.set_resizable(True) self.menu_items = ( diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index 1cd3e4cc..7e6f5970 100755 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -261,7 +261,9 @@ class fpdb_db: otherRaisedTurn INT, otherRaisedTurnFold INT, otherRaisedRiver INT, - otherRaisedRiverFold INT)""") + otherRaisedRiverFold INT, + wonWhenSeenFlop FLOAT, + wonAtSD FLOAT)""") self.cursor.execute("INSERT INTO sites VALUES (DEFAULT, \"Full Tilt Poker\", 'USD');") self.cursor.execute("INSERT INTO sites VALUES (DEFAULT, \"PokerStars\", 'USD');") diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index b7aad5d5..1842d924 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -113,7 +113,10 @@ def mainParser(db, cursor, site, category, hand): limit_type=cursor.fetchone()[0] #todo: remove this unnecessary database access fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts) - hudImportData=fpdb_simple.calculateHudImport(playerIDs, category, actionTypes) + totalWinnings=0 + for i in range(len(winnings)): + totalWinnings+=winnings[i] + hudImportData=fpdb_simple.calculateHudImport(playerIDs, category, actionTypes, winnings, totalWinnings) if isTourney: payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 4249c86f..79c4cb3f 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -1206,7 +1206,7 @@ def store_hands_players_stud_tourney(cursor, hands_id, player_ids, start_cashes, return result #end def store_hands_players_stud_tourney -def calculateHudImport(player_ids, category, action_types): +def calculateHudImport(player_ids, category, action_types, winnings, totalWinnings): """calculates data for the HUD during import. IMPORTANT: if you change this method make sure to also change the following storage method and table_viewer.prepare_data if necessary""" #setup subarrays of the result dictionary. VPIP=[] @@ -1226,6 +1226,9 @@ def calculateHudImport(player_ids, category, action_types): otherRaisedTurnFold=[] otherRaisedRiver=[] otherRaisedRiverFold=[] + wonWhenSeenFlop=[] + wonAtSD=[] + for player in range (len(player_ids)): #set default values myVPIP=False @@ -1245,6 +1248,8 @@ def calculateHudImport(player_ids, category, action_types): myOtherRaisedTurnFold=False myOtherRaisedRiver=False myOtherRaisedRiverFold=False + myWonWhenSeenFlop=0.0 + myWonAtSD=0.0 #calculate preflop values street=0 @@ -1325,7 +1330,14 @@ def calculateHudImport(player_ids, category, action_types): for countOtherFold in range (len(action_types[street][player])): if action_types[street][player][countOtherFold]=="fold": myOtherRaisedRiverFold=True - + + if winnings[player]!=0: + if mySawFlop: + myWonWhenSeenFlop=winnings[player]/float(totalWinnings) + #print "myWonWhenSeenFlop:",myWonWhenSeenFlop + if mySawShowdown: + myWonAtSD=myWonWhenSeenFlop + #add each value to the appropriate array VPIP.append(myVPIP) PFR.append(myPFR) @@ -1344,6 +1356,8 @@ def calculateHudImport(player_ids, category, action_types): otherRaisedTurnFold.append(myOtherRaisedTurnFold) otherRaisedRiver.append(myOtherRaisedRiver) otherRaisedRiverFold.append(myOtherRaisedRiverFold) + wonWhenSeenFlop.append(myWonWhenSeenFlop) + wonAtSD.append(myWonAtSD) #add each array to the to-be-returned dictionary result={'VPIP':VPIP} @@ -1363,6 +1377,8 @@ def calculateHudImport(player_ids, category, action_types): result['raisedRiver']=raisedRiver result['otherRaisedRiver']=otherRaisedRiver result['otherRaisedRiverFold']=otherRaisedRiverFold + result['wonWhenSeenFlop']=wonWhenSeenFlop + result['wonAtSD']=wonAtSD return result #end def calculateHudImport @@ -1413,17 +1429,19 @@ def storeHudData(cursor, category, gametypeId, playerIds, hudImportData): if hudImportData['otherRaisedTurnFold'][player]: row[19]+=1 if hudImportData['otherRaisedRiver'][player]: row[20]+=1 if hudImportData['otherRaisedRiverFold'][player]: row[21]+=1 + if hudImportData['wonWhenSeenFlop'][player]!=0.0: row[22]+=hudImportData['wonWhenSeenFlop'][player] + if hudImportData['wonAtSD'][player]!=0.0: row[23]+=hudImportData['wonAtSD'][player] if doInsert: #print "playerid before insert:",row[2] cursor.execute("""INSERT INTO HudDataHoldemOmaha - (gametypeId, playerId, activeSeats, HDs, VPIP, PFR, PF3B4BChance, PF3B4B, sawFlop, sawTurn, sawRiver, sawShowdown, raisedFlop, raisedTurn, raisedRiver, otherRaisedFlop, otherRaisedFlopFold, otherRaisedTurn, otherRaisedTurnFold, otherRaisedRiver, otherRaisedRiverFold) - VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21])) + (gametypeId, playerId, activeSeats, HDs, VPIP, PFR, PF3B4BChance, PF3B4B, sawFlop, sawTurn, sawRiver, sawShowdown, raisedFlop, raisedTurn, raisedRiver, otherRaisedFlop, otherRaisedFlopFold, otherRaisedTurn, otherRaisedTurnFold, otherRaisedRiver, otherRaisedRiverFold, wonWhenSeenFlop, wonAtSD) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21], row[22], row[23])) else: #print "storing updated hud data line" cursor.execute("""UPDATE HudDataHoldemOmaha - SET HDs=%s, VPIP=%s, PFR=%s, PF3B4BChance=%s, PF3B4B=%s, sawFlop=%s, sawTurn=%s, sawRiver=%s, sawShowdown=%s, raisedFlop=%s, raisedTurn=%s, raisedRiver=%s, otherRaisedFlop=%s, otherRaisedFlopFold=%s, otherRaisedTurn=%s, otherRaisedTurnFold=%s, otherRaisedRiver=%s, otherRaisedRiverFold=%s - WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s""", (row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21], row[1], row[2], row[3])) + SET HDs=%s, VPIP=%s, PFR=%s, PF3B4BChance=%s, PF3B4B=%s, sawFlop=%s, sawTurn=%s, sawRiver=%s, sawShowdown=%s, raisedFlop=%s, raisedTurn=%s, raisedRiver=%s, otherRaisedFlop=%s, otherRaisedFlopFold=%s, otherRaisedTurn=%s, otherRaisedTurnFold=%s, otherRaisedRiver=%s, otherRaisedRiverFold=%s, wonWhenSeenFlop=%s, wonAtSD=%s + WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s""", (row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21], row[22], row[23], row[1], row[2], row[3])) else: raise FpdbError("todo") #end def storeHudData diff --git a/pyfpdb/table_viewer.py b/pyfpdb/table_viewer.py index d50d0397..87ce855c 100755 --- a/pyfpdb/table_viewer.py +++ b/pyfpdb/table_viewer.py @@ -59,7 +59,7 @@ class table_viewer (threading.Thread): arr=[] #first prepare the header row if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"): - tmp=("Name", "Hands", "VPIP", "PFR", "PF3B4B", "AF", "FF", "AT", "FT", "AR", "FR", "SD/F") + tmp=("Name", "Hands", "VPIP", "PFR", "PF3B4B", "AF", "FF", "AT", "FT", "AR", "FR", "SD/F", "W$wSF", "W$@SD") else: raise fpdb_simple.FpdbError("reimplement stud") tmp=("Name", "Hands", "VPI3", "A3", "3B4B_3" "A4", "F4", "A5", "F5", "A6", "F6", "A7", "F7", "SD/4") @@ -112,6 +112,8 @@ class table_viewer (threading.Thread): tmp.append(self.hudDivide(row[15],row[11])+" ("+str(row[11])+")") #AR tmp.append(self.hudDivide(row[21],row[20])+" ("+str(row[20])+")") #FR tmp.append(self.hudDivide(row[12],row[9])+" ("+str(row[9])+")") #SD/F + tmp.append(self.hudDivide(row[22],row[9])+" ("+str(row[9])+")") #W$wSF + tmp.append(self.hudDivide(row[23],row[12])+" ("+str(row[12])+")") #W$@SD arr.append(tmp) return arr diff --git a/regression-test/PrintPlayerHudData.py b/regression-test/PrintPlayerHudData.py index 1c3f4de9..99be5a4e 100755 --- a/regression-test/PrintPlayerHudData.py +++ b/regression-test/PrintPlayerHudData.py @@ -93,6 +93,12 @@ print "otherRaisedTurn:",fields[2] print "otherRaisedTurnFold:",fields[3] print "otherRaisedRiver:",fields[4] print "otherRaisedRiverFold:",fields[5] +print "" + +cursor.execute ("SELECT wonWhenSeenFlop, wonAtSD FROM HudDataHoldemOmaha WHERE id=%s", (hudDataId,)) +fields=cursor.fetchone() +print "wonWhenSeenFlop:",fields[0] +print "wonAtSD:",fields[1] cursor.close() diff --git a/regression-test/ftp.6367428246.expected.txt b/regression-test/ftp.6367428246.expected.txt index 01ca224a..2e88061c 100644 --- a/regression-test/ftp.6367428246.expected.txt +++ b/regression-test/ftp.6367428246.expected.txt @@ -1,3 +1,5 @@ +This file is outdated! + Connected to MySQL on localhost. Print Hand Utility options.site: Full Tilt Poker site_id: 1 diff --git a/regression-test/ftp.6929537410.expected.txt b/regression-test/ftp.6929537410.expected.txt index 448ab95e..6d558420 100644 --- a/regression-test/ftp.6929537410.expected.txt +++ b/regression-test/ftp.6929537410.expected.txt @@ -1,3 +1,5 @@ +This file is outdated! + Connected to MySQL on localhost. Print Hand Utility options.site: Full Tilt Poker site_id: 1 From Table hands diff --git a/regression-test/ftp.6929553738.expected.txt b/regression-test/ftp.6929553738.expected.txt index 0999a08d..b758cbfc 100644 --- a/regression-test/ftp.6929553738.expected.txt +++ b/regression-test/ftp.6929553738.expected.txt @@ -1,3 +1,5 @@ +This file is outdated! + Connected to MySQL on localhost. Print Hand Utility options.site: Full Tilt Poker site_id: 1 From Table hands diff --git a/regression-test/print_hand.py b/regression-test/print_hand.py index 1ccb3a15..b558ed96 100755 --- a/regression-test/print_hand.py +++ b/regression-test/print_hand.py @@ -159,7 +159,7 @@ for i in range (len(hands_players)): hands_actions=cursor.fetchall() for j in range (len(hands_actions)): line=hands_actions[j][2:] - printstr="player_name:"+player_names[i]+" actionCount:"+str(j) + printstr="player_name:"+player_names[i] printstr+=" street:"+ful.street_int2String(category, line[0])+" streetActionNo:"+str(line[1])+" action:"+line[2] printstr+=" amount:"+str(line[3]) print printstr