git28 - added test hands for steal and cb

uncommented db version checking - it works
started implementing storing steals
filling steal attempts and attempt chances fields now, but not verified correctness nor am i displaying it
This commit is contained in:
steffen123
2008-08-13 03:07:44 +01:00
parent 436bfc26f2
commit 6d7bdc347c
11 changed files with 205 additions and 44 deletions
+1 -1
View File
@@ -347,7 +347,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
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: alpha1, git27")
self.window.set_title("Free Poker DB - version: alpha1+, git28")
self.window.set_border_width(1)
self.window.set_size_request(950,400)
self.window.set_resizable(True)
+8 -8
View File
@@ -44,13 +44,13 @@ class fpdb_db:
else:
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
self.cursor=self.db.cursor()
#try:
# self.cursor.execute("SELECT * FROM settings")
# settings=self.cursor.fetchone()
# if settings[0]!=21:
# print "outdated database version - please recreate tables"
#except:# _mysql_exceptions.ProgrammingError:
# print "failed to read settings table - please recreate tables"
try:
self.cursor.execute("SELECT * FROM settings")
settings=self.cursor.fetchone()
if settings[0]!=28:
print "outdated database version - please recreate tables"
except:# _mysql_exceptions.ProgrammingError:
print "failed to read settings table - please recreate tables"
#end def connect
def create_table(self, string):
@@ -281,7 +281,7 @@ class fpdb_db:
foldSbToStealChance INT,
foldedSbToSteal INT)""")
self.cursor.execute("INSERT INTO settings VALUES (21);")
self.cursor.execute("INSERT INTO settings VALUES (28);")
self.cursor.execute("INSERT INTO sites VALUES (DEFAULT, \"Full Tilt Poker\", 'USD');")
self.cursor.execute("INSERT INTO sites VALUES (DEFAULT, \"PokerStars\", 'USD');")
self.db.commit()
+1 -1
View File
@@ -101,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, actionTypeByNo, winnings, totalWinnings)
hudImportData=fpdb_simple.generateHudData(playerIDs, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions)
if isTourney:
raise fpdb_simple.FpdbError ("tourneys are currently broken")
+57 -3
View File
@@ -1225,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, actionTypeByNo, winnings, totalWinnings):
def generateHudData(player_ids, category, action_types, actionTypeByNo, winnings, totalWinnings, positions):
"""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=[]
@@ -1254,12 +1254,41 @@ def calculateHudImport(player_ids, category, action_types, actionTypeByNo, winni
foldSbToStealChance=[]
foldedSbToSteal=[]
firstPfRaise=-1
firstPfRaiseByNo=-1
firstPfRaiserId=-1
firstPfRaiserNo=-1
firstPfCallByNo=-1
firstPfCallerId=-1
for i in range(len(actionTypeByNo[0])):
if actionTypeByNo[0][i][1]=="bet":
firstPfRaise=i
firstPfRaiseByNo=i
firstPfRaiserId=actionTypeByNo[0][i][0]
for j in range(len(player_ids)):
if player_ids[j]==firstPfRaiserId:
firstPfRaiserNo=j
break
break
for i in range(len(actionTypeByNo[0])):
if actionTypeByNo[0][i][1]=="call":
firstPfCallByNo=i
firstPfCallerId=actionTypeByNo[0][i][0]
break
cutoffId=-1
buttonId=-1
sbId=-1
bbId=-1
for player in range(len(positions)):
if positions==1:
cutoffId=player_ids[player]
if positions==0:
buttonId=player_ids[player]
if positions=='S':
sbId=player_ids[player]
if positions=='B':
bbId=player_ids[player]
#run a loop for each player preparing the actual values that will be commited to SQL
for player in range (len(player_ids)):
#set default values
myVPIP=False
@@ -1313,6 +1342,31 @@ def calculateHudImport(player_ids, category, action_types, actionTypeByNo, winni
if pfRaise>firstPfRaise:
myPF3B4B=True
#myStealAttemptChance myStealAttempted myFoldBbToStealChance myFoldedBbToSteal myFoldSbToStealChance myFoldedSbToSteal
#steal calculations
if len(player_ids)>=5: #no point otherwise
if positions[player]==1:
if firstPfRaiserId==player_ids[player]:
myStealAttemptChance=True
myStealAttempted=True
elif firstPfRaiserId==buttonId or firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1:
myStealAttemptChance=True
if positions[player]==0:
if firstPfRaiserId==player_ids[player]:
myStealAttemptChance=True
myStealAttempted=True
elif firstPfRaiserId==sbId or firstPfRaiserId==bbId or firstPfRaiserId==-1:
myStealAttemptChance=True
if positions[player]==S:
if firstPfRaiserId==player_ids[player]:
myStealAttemptChance=True
myStealAttempted=True
elif firstPfRaiserId==bbId or firstPfRaiserId==-1:
myStealAttemptChance=True
if positions[player]==B:
pass
#calculate saw* values
if (len(action_types[1][player])>0):
mySawFlop=True