git20 - made differently arranged array for actiontypes, used that to calculate 3B/4B percentage

This commit is contained in:
steffen123
2008-08-09 18:53:07 +01:00
parent 0e84dceb1f
commit 3d82fd4f6a
4 changed files with 48 additions and 26 deletions
+1 -1
View File
@@ -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)
+5 -6
View File
@@ -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")
+32 -11
View File
@@ -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