p78 - implemented stud HudCache generation and storing

This commit is contained in:
steffen123 2008-09-02 01:00:43 +01:00
parent 4976dc742c
commit 2c251d94f2
5 changed files with 107 additions and 95 deletions

View File

@ -10,8 +10,6 @@ find correct sf logo link
windows integrated installer windows integrated installer
update install-in-gentoo on website update install-in-gentoo on website
update ebuild and ubuntu guide for HUD_config.xml update ebuild and ubuntu guide for HUD_config.xml
implement stud HudCache
implement storeHudCache for stud base
store raw hand in db and write reimport function using the raw hand field store raw hand in db and write reimport function using the raw hand field
ftp: read maxSeats ftp: read maxSeats
@ -25,6 +23,7 @@ printhand each and the 2/3 relevant printplayerflags respectively on ps-lhe-ring
alpha4 (release 8Sep?) alpha4 (release 8Sep?)
====== ======
change to savannah? change to savannah?
implement steal and positions in stud
anonymiser script to generate testdata without making a dozen find&replace all... remember to replace hand no with running no anonymiser script to generate testdata without making a dozen find&replace all... remember to replace hand no with running no
Everything that didn't make it into alpha3 Everything that didn't make it into alpha3
Import draw (maybe without HudCache for a start) Import draw (maybe without HudCache for a start)

View File

@ -407,7 +407,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 = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event) self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy) self.window.connect("destroy", self.destroy)
self.window.set_title("Free Poker DB - version: alpha2+, p76") self.window.set_title("Free Poker DB - version: alpha2+, p78")
self.window.set_border_width(1) self.window.set_border_width(1)
self.window.set_size_request(1020,400) self.window.set_size_request(1020,400)
self.window.set_resizable(True) self.window.set_resizable(True)
@ -421,18 +421,18 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
("/Main/_Quit", "<control>Q", self.quit, 0, None ), ("/Main/_Quit", "<control>Q", self.quit, 0, None ),
("/_Import", None, None, 0, "<Branch>" ), ("/_Import", None, None, 0, "<Branch>" ),
("/Import/_Bulk Import", "<control>B", self.tab_bulk_import, 0, None ), ("/Import/_Bulk Import", "<control>B", self.tab_bulk_import, 0, None ),
( "/Import/_Auto Import (todo)", "<control>A", self.tab_auto_import, 0, None ), ("/Import/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
("/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ), ("/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ),
("/_Viewers", None, None, 0, "<Branch>" ), ("/_Viewers", None, None, 0, "<Branch>" ),
("/_Viewers/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
("/Viewers/_Graphs (todo)", None, self.not_implemented, 0, None ), ("/Viewers/_Graphs (todo)", None, self.not_implemented, 0, None ),
( "/Viewers/H_and Replayer (todo)", None, self.not_implemented, 0, None ), ("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ),
("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ), ("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ),
("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ), ("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ),
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ), ("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ), ("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
("/Viewers/Poker_table Viewer", "<control>T", self.tab_table_viewer, 0, None ), ("/Viewers/Poker_table Viewer", "<control>T", self.tab_table_viewer, 0, None ),
#( "/Viewers/Tourney Replayer #( "/Viewers/Tourney Replayer
#( "/H_UD", None, None, 0, "<Branch>" ),
( "/_Database", None, None, 0, "<Branch>" ), ( "/_Database", None, None, 0, "<Branch>" ),
( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ), ( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ),
( "/Database/Create or Delete _User (todo)", None, self.dia_create_del_user, 0, None ), ( "/Database/Create or Delete _User (todo)", None, self.dia_create_del_user, 0, None ),

View File

@ -118,10 +118,9 @@ def mainParser(db, cursor, site, category, hand):
totalWinnings+=winnings[i] totalWinnings+=winnings[i]
if base=="hold": if base=="hold":
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions) hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions)
else: else:
print "todo: stud HudCache" hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, actionTypeByNo, winnings, totalWinnings, None)
hudImportData=None
if isTourney: if isTourney:
ranks=[] ranks=[]

View File

@ -27,9 +27,9 @@ def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats) hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids, hands_players_ids=fpdb_simple.store_hands_players_stud(cursor, hands_id, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes) start_cashes, antes, card_values, card_suits, winnings, rakes, seatNos)
fpdb_simple.storeHudCache(cursor, category, gametype_id, player_ids, hudImportData) fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos) fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos)
return hands_id return hands_id
@ -44,7 +44,7 @@ def ring_holdem_omaha(cursor, base, category, site_hand_no, gametype_id, hand_st
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos) hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos)
fpdb_simple.storeHudCache(cursor, category, gametype_id, player_ids, hudImportData) fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits) fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
@ -65,7 +65,7 @@ def tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knoc
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids) hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids)
fpdb_simple.storeHudCache(cursor, category, gametype_id, player_ids, hudImportData) fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits) fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
@ -90,7 +90,7 @@ def tourney_stud(cursor, base, category, site_tourney_no, buyin, fee, knockout,
hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, player_ids, hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(cursor, hands_id, player_ids,
start_cashes, antes, card_values, card_suits, winnings, rakes, tourneys_players_ids) start_cashes, antes, card_values, card_suits, winnings, rakes, tourneys_players_ids)
fpdb_simple.storeHudData(cursor, category, player_ids, hudImportData) fpdb_simple.storeHudData(cursor, base, category, player_ids, hudImportData)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts) fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts)
return hands_id return hands_id

View File

@ -1201,7 +1201,7 @@ def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, sta
#end def store_hands_players_holdem_omaha #end def store_hands_players_holdem_omaha
def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes, def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes,
card_values, card_suits, winnings, rakes): card_values, card_suits, winnings, rakes, seatNos):
#stores hands_players rows for stud/razz games. returns an array of the resulting IDs #stores hands_players rows for stud/razz games. returns an array of the resulting IDs
result=[] result=[]
for i in range (len(player_ids)): for i in range (len(player_ids)):
@ -1210,14 +1210,14 @@ def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes,
card1Value, card1Suit, card2Value, card2Suit, card1Value, card1Suit, card2Value, card2Suit,
card3Value, card3Suit, card4Value, card4Suit, card3Value, card3Suit, card4Value, card4Suit,
card5Value, card5Suit, card6Value, card6Suit, card5Value, card5Suit, card6Value, card6Suit,
card7Value, card7Suit, winnings, rake) card7Value, card7Suit, winnings, rake, seatNo)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s)""", %s, %s, %s, %s)""",
(hands_id, player_ids[i], start_cashes[i], antes[i], (hands_id, player_ids[i], start_cashes[i], antes[i],
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3],
card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5], card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5],
card_values[i][6], card_suits[i][6], winnings[i], rakes[i])) card_values[i][6], card_suits[i][6], winnings[i], rakes[i], seatNos[i]))
cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i])) cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i]))
result.append(cursor.fetchall()[0][0]) result.append(cursor.fetchall()[0][0])
return result return result
@ -1278,7 +1278,7 @@ def store_hands_players_stud_tourney(cursor, hands_id, player_ids, start_cashes,
return result return result
#end def store_hands_players_stud_tourney #end def store_hands_players_stud_tourney
def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, winnings, totalWinnings, positions): def generateHudCacheData(player_ids, base, 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""" """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. #setup subarrays of the result dictionary.
street0VPI=[] street0VPI=[]
@ -1333,6 +1333,7 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
buttonId=-1 buttonId=-1
sbId=-1 sbId=-1
bbId=-1 bbId=-1
if base=="hold":
for player in range(len(positions)): for player in range(len(positions)):
if positions==1: if positions==1:
cutoffId=player_ids[player] cutoffId=player_ids[player]
@ -1400,6 +1401,7 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
myStreet0_3B4BDone=True myStreet0_3B4BDone=True
#steal calculations #steal calculations
if base=="hold":
if len(player_ids)>=5: #no point otherwise if len(player_ids)>=5: #no point otherwise
if positions[player]==1: if positions[player]==1:
if firstPfRaiserId==player_ids[player]: if firstPfRaiserId==player_ids[player]:
@ -1523,6 +1525,7 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
wonAtSD.append(myWonAtSD) wonAtSD.append(myWonAtSD)
stealAttemptChance.append(myStealAttemptChance) stealAttemptChance.append(myStealAttemptChance)
stealAttempted.append(myStealAttempted) stealAttempted.append(myStealAttempted)
if base=="hold":
pos=positions[player] pos=positions[player]
if pos=='B': if pos=='B':
hudDataPositions.append('B') hudDataPositions.append('B')
@ -1538,6 +1541,9 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
hudDataPositions.append('L') hudDataPositions.append('L')
else: else:
raise FpdbError("invalid position") raise FpdbError("invalid position")
elif base=="stud":
#todo: stud positions and steals
pass
#add each array to the to-be-returned dictionary #add each array to the to-be-returned dictionary
result={'street0VPI':street0VPI} result={'street0VPI':street0VPI}
@ -1578,6 +1584,7 @@ def generateHudCacheData(player_ids, category, action_types, actionTypeByNo, win
myFoldSbToStealChance=False myFoldSbToStealChance=False
myFoldedSbToSteal=False myFoldedSbToSteal=False
if base=="hold":
if someoneStole and (positions[player]=='B' or positions[player]=='S') and firstPfRaiserId!=player_ids[player]: if someoneStole and (positions[player]=='B' or positions[player]=='S') and firstPfRaiserId!=player_ids[player]:
street=0 street=0
for count in range (len(action_types[street][player])):#individual actions for count in range (len(action_types[street][player])):#individual actions
@ -1797,10 +1804,14 @@ def generateFoldToCB(street, playerIDs, didStreetCB, streetCBDone, foldToStreetC
foldToStreetCBDone[player]=True foldToStreetCBDone[player]=True
#end def generateFoldToCB #end def generateFoldToCB
def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData): def storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData):
if (category=="holdem" or category=="omahahi" or category=="omahahilo"): # if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
for player in range (len(playerIds)): for player in range (len(playerIds)):
if base=="hold":
cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s", (gametypeId, playerIds[player], len(playerIds), hudImportData['position'][player])) cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s", (gametypeId, playerIds[player], len(playerIds), hudImportData['position'][player]))
else:
cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s", (gametypeId, playerIds[player], len(playerIds)))
row=cursor.fetchone() row=cursor.fetchone()
#print "gametypeId:", gametypeId, "playerIds[player]",playerIds[player], "len(playerIds):",len(playerIds), "row:",row #print "gametypeId:", gametypeId, "playerIds[player]",playerIds[player], "len(playerIds):",len(playerIds), "row:",row
@ -1826,7 +1837,10 @@ def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData):
newrow.append(row[i]) newrow.append(row[i])
row=newrow row=newrow
if base=="hold":
row[4]=hudImportData['position'][player] row[4]=hudImportData['position'][player]
else:
row[4]=0
row[5]=1 #tourneysGametypeId row[5]=1 #tourneysGametypeId
row[6]+=1 #HDs row[6]+=1 #HDs
if hudImportData['street0VPI'][player]: row[7]+=1 if hudImportData['street0VPI'][player]: row[7]+=1
@ -1938,8 +1952,8 @@ def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData):
row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50], row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50],
row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60], row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60],
row[1], row[2], row[3], row[4], row[5])) row[1], row[2], row[3], row[4], row[5]))
else: # else:
print "todo: implement storeHudCache for stud base" # print "todo: implement storeHudCache for stud base"
#end def storeHudCache #end def storeHudCache
def store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, startTime): def store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, startTime):