From 3d82fd4f6a3042c14e27367bd5b58fb4a5c9a2db Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sat, 9 Aug 2008 18:53:07 +0100 Subject: [PATCH] git20 - made differently arranged array for actiontypes, used that to calculate 3B/4B percentage --- docs/known-bugs-and-planned-features.txt | 18 +++++----- pyfpdb/fpdb.py | 2 +- pyfpdb/fpdb_parse_logic.py | 11 +++--- pyfpdb/fpdb_simple.py | 43 ++++++++++++++++++------ 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index 44220752..3c0186ab 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -9,18 +9,22 @@ add instructions how to reimport split python requirements, get deep links for windows DL for everything GUI license info -calculate 3B/4B percentage add fpdb version string into db to detect outdated db format and importer bugs update regression testing to take into account everything new, make sure it passes all tests +implement error file in importer + +next +==== +ST, CB, 2B, 3B, fold to these +optionally show single postflop agg/fold rate +auto-import +use different colours according to classification. +add stud, razz and tourney back to imp/tv but with less seperate codepathes +table with data for graphs for SD/F, W$wSF, W$@SD before beta =========== -optionally show single postflop agg/fold rate change definition of bet to exclude bring in? -auto-import -implement error file in importer -change to use different colours according to classification. -add stud, razz and tourney back to imp/tv but with less seperate codepathes in tv, select from hud table using named fields rather than the current * remove remains of mysql/myisam support. tourney bug: sometimes truncuates position on store -> possibly indicates much bigger problem @@ -35,8 +39,6 @@ make bulk importer display a grand total in the GUI change save_to_db into one method and probably move into parse_logic Any comment or print with "todo" in it in the sourcecode except what is marked todo in the menu make a quick benchmark of mysql and postgresql: import of my whole db, some tableviewer refreshes with and without updated file -db+imp+tv steal blind from btn, co, lmp. fold SB/BB/BI to steal -db+imp+tv cb/2nd/3rd barrel, fold to them. Make tab and enter work as sensible in GUIs and implement Ctrl+Q, Ctrl+X and Alt+F4 for close. use profile file for bulk import and table viewer settings and pathes handle errors properly, in particular wrt to SQL rollback. diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index cf9b99ae..9f6e7c10 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -343,7 +343,7 @@ 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, git19") + self.window.set_title("Free Poker DB - version: pre-alpha, git20") self.window.set_border_width(1) self.window.set_size_request(950,400) self.window.set_resizable(True) diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index c024e7c7..646081f2 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -27,8 +27,7 @@ def mainParser(db, cursor, site, category, hand): lineTypes=[] #char, valid values: header, name, cards, action, win, rake, ignore lineStreets=[] #char, valid values: (predeal, preflop, flop, turn, river) - cardValues, cardSuits, boardValues, boardSuits=[],[],[],[] - antes, actionTypes, actionAmounts, actionNos, seatLines, winnings, rakes=[], [],[],[],[],[],[] + cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[], [],[],[],[],[],[],[],[],[],[],[] #part 1: read hand no and check for duplicate siteHandNo=fpdb_simple.parseSiteHandNo(hand[0]) @@ -60,8 +59,8 @@ def mainParser(db, cursor, site, category, hand): playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID) startCashes=fpdb_simple.parseCashes(seatLines, site) - fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, actionAmounts, actionNos) - + fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, actionAmounts, actionNos, actionTypeByNo) + #3b read positions if (category=="holdem" or category=="omahahi" or category=="omahahilo"): positions = fpdb_simple.parsePositions (hand, names) @@ -71,7 +70,7 @@ def mainParser(db, cursor, site, category, hand): if (lineTypes[i]=="cards"): fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits) elif (lineTypes[i]=="action"): - fpdb_simple.parseActionLine (site, hand[i], lineStreets[i], names, actionTypes, actionAmounts, actionNos) + fpdb_simple.parseActionLine (site, hand[i], lineStreets[i], playerIDs, names, actionTypes, actionAmounts, actionNos, actionTypeByNo) elif (lineTypes[i]=="win"): fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney) elif (lineTypes[i]=="rake"): @@ -102,7 +101,7 @@ def mainParser(db, cursor, site, category, hand): totalWinnings=0 for i in range(len(winnings)): totalWinnings+=winnings[i] - hudImportData=fpdb_simple.calculateHudImport(playerIDs, category, actionTypes, winnings, totalWinnings) + hudImportData=fpdb_simple.calculateHudImport(playerIDs, category, actionTypes, actionTypeByNo, winnings, totalWinnings) if isTourney: raise fpdb_simple.FpdbError ("tourneys are currently broken") diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 49e35853..a7610a8c 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -199,7 +199,7 @@ def convertCardValuesBoard(arr): #end def convertCardValuesBoard #this creates the 2D/3D arrays. manipulates the passed arrays instead of returning. -def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, action_amounts, actionNos): +def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, action_amounts, actionNos, actionTypeByNo): for i in range(seats):#create second dimension arrays tmp=[] card_values.append(tmp) @@ -212,7 +212,7 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake if (category=="holdem" or category=="omahahi" or category=="omahahilo"): streetCount=4 else: - streetCount=8 + streetCount=5 for i in range(streetCount): #build the first dimension array, for streets tmp=[] @@ -221,6 +221,8 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake action_amounts.append(tmp) tmp=[] actionNos.append(tmp) + tmp=[] + actionTypeByNo.append(tmp) for j in range (seats): #second dimension arrays: players tmp=[] action_types[i].append(tmp) @@ -562,7 +564,7 @@ def parseActionAmount(line, atype, site): #doesnt return anything, simply changes the passed arrays action_types and # action_amounts. For stud this expects numeric streets (3-7), for # holdem/omaha it expects predeal, preflop, flop, turn or river -def parseActionLine(site, line, street, names, action_types, action_amounts, actionNos): +def parseActionLine(site, line, street, playerIDs, names, action_types, action_amounts, actionNos, actionTypeByNo): #this only applies to stud if (street<3): text="invalid street ("+str(street)+") for line: "+line @@ -590,6 +592,8 @@ def parseActionLine(site, line, street, names, action_types, action_amounts, act action_types[street][playerno].append(atype) action_amounts[street][playerno].append(amount) actionNos[street][playerno].append(nextActionNo) + tmp=(playerIDs[playerno], atype) + actionTypeByNo[street].append(tmp) #end def parseActionLine #returns the action type code (see table design) of the given action line @@ -1221,7 +1225,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, winnings, totalWinnings): +def calculateHudImport(player_ids, category, action_types, actionTypeByNo, 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=[] @@ -1244,6 +1248,12 @@ def calculateHudImport(player_ids, category, action_types, winnings, totalWinnin wonWhenSeenFlop=[] wonAtSD=[] + firstPfRaise=-1 + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][1]=="bet": + firstPfRaise=i + break + for player in range (len(player_ids)): #set default values myVPIP=False @@ -1266,20 +1276,31 @@ def calculateHudImport(player_ids, category, action_types, winnings, totalWinnin myWonWhenSeenFlop=0.0 myWonAtSD=0.0 - #calculate preflop values + #calculate VPIP and PFR street=0 heroPfRaiseCount=0 for count in range (len(action_types[street][player])):#finally individual actions currentAction=action_types[street][player][count] if currentAction=="bet": - heroPfRaiseCount+=1 + myPFR=True if (currentAction=="bet" or currentAction=="call"): myVPIP=True - if heroPfRaiseCount>=1: - myPFR=True - if heroPfRaiseCount>=2: - myPF3B4B=True - + + #PF3B4BChance and PF3B4B + pfFold=-1 + pfRaise=-1 + if firstPfRaise!=-1: + for i in range(len(actionTypeByNo[0])): + if actionTypeByNo[0][i][0]==player_ids[player]: + if actionTypeByNo[0][i][1]=="bet" and pfRaise==-1 and i>firstPfRaise: + pfRaise=i + if actionTypeByNo[0][i][1]=="fold" and pfFold==-1: + pfFold=i + if pfFold==-1 or pfFold>firstPfRaise: + myPF3B4BChance=True + if pfRaise>firstPfRaise: + myPF3B4B=True + #calculate saw* values if (len(action_types[1][player])>0): mySawFlop=True