Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jejellyroll-fr committed Oct 22, 2023
2 parents f998947 + a925f76 commit 3de2e24
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 96 deletions.
2 changes: 2 additions & 0 deletions Card.py
Expand Up @@ -57,8 +57,10 @@
'5_omahahi': ('hold', 'omaha', 'h', {'PREFLOP': 0, 'FLOP': 1, 'TURN': 2, 'RIVER': 3}, 'RIVER', [(0, 5)]),
'6_omahahi': ('hold', 'omaha', 'h', {'PREFLOP': 0, 'FLOP': 1, 'TURN': 2, 'RIVER': 3}, 'RIVER', [(0, 6)]),
'5_omaha8': ('hold', 'omaha8', 's', {'PREFLOP': 0, 'FLOP': 1, 'TURN': 2, 'RIVER': 3}, 'RIVER', [(0, 5)]),
'6_omaha8': ('hold', 'omaha8', 's', {'PREFLOP': 0, 'FLOP': 1, 'TURN': 2, 'RIVER': 3}, 'RIVER', [(0, 6)]),
'cour_hi': ('hold', 'omaha', 'h', {'PREFLOP': 0, 'FLOP': 1, 'TURN': 2, 'RIVER': 3}, 'RIVER', [(0, 5)]),
'cour_hilo': ('hold', 'omaha8', 's', {'PREFLOP': 0, 'FLOP': 1, 'TURN': 2, 'RIVER': 3}, 'RIVER', [(0, 5)]),
'aof_omaha': ('hold', 'omaha', 'h', {'FLOP': 0, 'TURN': 1, 'RIVER': 2}, 'RIVER', [(0, 4)]),
'5_studhi': ('stud', 'holdem', 'h', {'SECOND': 0, 'THIRD': 1, 'FOURTH': 2, 'FIFTH': 3}, 'FIFTH',
[(0, 2), (0, 3), (0, 4), (0, 5)]),
'razz': ('stud', None, 'l', {'THIRD': 0, 'FOURTH': 1, 'FIFTH': 2, 'SIXTH': 3, 'SEVENTH': 4}, 'SEVENTH',
Expand Down
42 changes: 25 additions & 17 deletions DerivedStats.py
Expand Up @@ -428,13 +428,17 @@ def assembleHandsStove(self, hand):
maxcards = (base!='hold' and len(cards)>=5)
if notnull and (postflop or maxcards):
for hl, side in hiLoKey[hilo]:
value, rank = pokereval.best(side, cards, bcards)
rankId = Card.hands[rank[0]][0]
if rank!=None and rank[0] != 'Nothing':
_cards = ''.join([pokereval.card2string(i)[0] for i in rank[1:]])
else:
_cards = None
self.handsstove.append( [hand.dbid_hands, hand.dbid_pids[pname], streetId, boardId, hl, rankId, value, _cards, 0] )
try:
value, rank = pokereval.best(side, cards, bcards)
rankId = Card.hands[rank[0]][0]
if rank!=None and rank[0] != 'Nothing':
_cards = ''.join([pokereval.card2string(i)[0] for i in rank[1:]])
else:
_cards = None
self.handsstove.append( [hand.dbid_hands, hand.dbid_pids[pname], streetId, boardId, hl, rankId, value, _cards, 0] )
except RuntimeError:
log.error("assembleHandsStove: error determining value and rank for hand %s %s" % (hand.handid, hand.in_path))
self.handsstove.append( [hand.dbid_hands, hand.dbid_pids[pname], streetId, boardId, 'n', 1, 0, None, 0] )
else:
self.handsstove.append( [hand.dbid_hands, hand.dbid_pids[pname], streetId, boardId, 'n', 1, 0, None, 0] )
else:
Expand Down Expand Up @@ -470,14 +474,18 @@ def getAllInEV(self, hand, evalgame, holeplayers, boards, streets, holecards):
if len(players) == len(valid) and (board['allin'] or hand.publicDB):
if board['allin'] and not startstreet: startstreet = street
if len(valid) > 1:
evs = pokereval.poker_eval(
game = evalgame,
iterations = Card.iter[streetId],
pockets = [holecards[p]['hole'] for p in valid],
dead = deadcards,
board = [str(b) for b in board['board'][n]] + (5 - len(board['board'][n])) * ['__']
)
equities = [e['ev'] for e in evs['eval']]
try:
evs = pokereval.poker_eval(
game = evalgame,
iterations = Card.iter[streetId],
pockets = [holecards[p]['hole'] for p in valid],
dead = deadcards,
board = [str(b) for b in board['board'][n]] + (5 - len(board['board'][n])) * ['__']
)
equities = [e['ev'] for e in evs['eval']]
except RuntimeError:
log.error("getAllInEV: error running poker_eval for hand %s %s" % (hand.handid, hand.in_path))
equities = [1000]
else:
equities = [1000]
remainder = old_div((1000 - sum(equities)), Decimal(len(equities)))
Expand Down Expand Up @@ -1287,8 +1295,8 @@ def foldTofirstsBetOrRaiser(self, actions, street, aggressor):
players[act[0]] = False
if act[1] == 'raises' or act[1] == 'completes':
break
elif act[1]!='discards':
i+=1
elif act[1] not in ('discards', 'stands pat'):
i += 1
return players

def lastBetOrRaiser(self, actions, street):
Expand Down
13 changes: 11 additions & 2 deletions Hand.py
Expand Up @@ -718,7 +718,9 @@ def addBlind(self, player, blindtype, amount):

street = 'BLAH'

if self.gametype['base'] == 'hold':
if self.gametype['category'] == 'aof_omaha':
street = 'FLOP'
elif self.gametype['base'] == 'hold':
street = 'PREFLOP'
elif self.gametype['base'] == 'draw':
street = 'DEAL'
Expand Down Expand Up @@ -1123,6 +1125,11 @@ def __init__(self, config, hhc, sitename, gametype, handText, builtFrom = "HHC",
self.discardStreets = ['PREFLOP']
self.communityStreets = ['FLOP', 'TURN', 'RIVER']
self.actionStreets = ['BLINDSANTES','PREFLOP','FLOP','TURN','RIVER']
if gametype['category']=='aof_omaha':
self.allStreets = ['BLINDSANTES','FLOP','TURN','RIVER']
self.holeStreets = ['FLOP']
self.communityStreets = ['FLOP', 'TURN', 'RIVER']
self.actionStreets = ['BLINDSANTES','FLOP','TURN','RIVER']
Hand.__init__(self, self.config, sitename, gametype, handText, builtFrom = "HHC")
self.sb = gametype['sb']
self.bb = gametype['bb']
Expand Down Expand Up @@ -1183,7 +1190,9 @@ def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False, st
if shown: self.shown.add(player)
if mucked: self.mucked.add(player)
else:
if len(cards) in (2, 3, 4, 6) or self.gametype['category'] in ('5_omahahi', '5_omaha8', 'cour_hi', 'cour_hilo', 'fusion'): # avoid adding board by mistake (Everleaf problem)
if self.gametype['category'] == 'aof_omaha':
self.addHoleCards('FLOP', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)
elif len(cards) in (2, 3, 4, 6) or self.gametype['category'] in ('5_omahahi', '5_omaha8', 'cour_hi', 'cour_hilo', 'fusion'): # avoid adding board by mistake (Everleaf problem)
self.addHoleCards('PREFLOP', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)

elif len(cards) == 5: # cards holds a winning hand, not hole cards
Expand Down
104 changes: 65 additions & 39 deletions KingsClubToFpdb.py
Expand Up @@ -84,25 +84,27 @@ class KingsClub(HandHistoryConverter):
'Limit':'fl'
}
games = { # base, category
'Holdem' : ('hold','holdem'),
'Omaha' : ('hold','omahahi'),
'Omaha Hi-Lo' : ('hold','omahahilo'),
'Big O' : ('hold', '5_omaha8'),
'Omaha 5 Card' : ('hold', '5_omahahi'),
'Omaha 6 Card' : ('hold', '6_omahahi'),
'Razz' : ('stud','razz'),
'Seven Card Stud' : ('stud','studhi'),
'Seven Card Stud Hi-Lo' : ('stud','studhilo'),
'Badugi' : ('draw','badugi'),
'2-7 Triple Draw' : ('draw','27_3draw'),
'2-7 Single Draw' : ('draw','27_1draw'),
'5 Card Draw' : ('draw','fivedraw'),
'A-5 Triple Draw' : ('draw','a5_3draw'),
'A-5 Single Draw' : ('draw','a5_1draw'),
'2-7 Razz' : ('stud','27_razz'),
'Badacey' : ('draw','badacey'),
'Badeucey' : ('draw','badeucey'),
'2-7 Drawmaha' : ('draw','drawmaha')
'Holdem': ('hold', 'holdem'),
'Omaha': ('hold', 'omahahi'),
'Omaha Hi-Lo': ('hold', 'omahahilo'),
'Big O': ('hold', '5_omaha8'),
'Omaha 5 Card': ('hold', '5_omahahi'),
'Omaha 6 Card': ('hold', '6_omahahi'),
'Short Deck Holdem': ('hold', '6_holdem'),
'Razz': ('stud', 'razz'),
'Seven Card Stud': ('stud', 'studhi'),
'Seven Card Stud Hi-Lo': ('stud', 'studhilo'),
'Badugi': ('draw', 'badugi'),
'2-7 Triple Draw': ('draw', '27_3draw'),
'2-7 Single Draw': ('draw', '27_1draw'),
'5 Card Draw': ('draw', 'fivedraw'),
'A-5 Triple Draw': ('draw', 'a5_3draw'),
'A-5 Single Draw': ('draw', 'a5_1draw'),
'2-7 Razz': ('stud', '27_razz'),
'Badacey': ('draw', 'badacey'),
'Badeucey': ('draw', 'badeucey'),
'2-7 Drawmaha': ('draw', 'drawmaha'),
'Captain': ('draw', 'drawmaha')
}
mixes = {
'HORSE': 'horse',
Expand All @@ -122,7 +124,7 @@ class KingsClub(HandHistoryConverter):
re_GameInfo = re.compile(u"""
\#(?P<HID>[0-9]+):\s+
(?P<LIMIT>No\sLimit|Limit|Pot\sLimit)\s
(?P<GAME>Holdem|Razz|Seven\sCard\sStud|Seven\sCard\sStud\sHi\-Lo|Omaha|Omaha\s(5|6)\sCard|Omaha\sHi\-Lo|Badugi|2\-7\sTriple\sDraw|2\-7\sSingle\sDraw|5\sCard\sDraw|Big\sO|2\-7\sRazz|Badacey|Badeucey|A\-5\sTriple\sDraw|A\-5\sSingle\sDraw|2\-7\sDrawmaha)\s
(?P<GAME>Holdem|Short\sDeck\sHoldem|Razz|Seven\sCard\sStud|Seven\sCard\sStud\sHi\-Lo|Omaha|Omaha\s(5|6)\sCard|Omaha\sHi\-Lo|Badugi|2\-7\sTriple\sDraw|2\-7\sSingle\sDraw|5\sCard\sDraw|Big\sO|2\-7\sRazz|Badacey|Badeucey|A\-5\sTriple\sDraw|A\-5\sSingle\sDraw|2\-7\sDrawmaha|Captain)\s
\-\s(?P<SB>[,.0-9]+)/(?P<BB>[,.0-9]+)
""" % substitutions, re.MULTILINE|re.VERBOSE)

Expand Down Expand Up @@ -191,6 +193,7 @@ class KingsClub(HandHistoryConverter):

re_Rake = re.compile(r"^Rake\s(?P<RAKE>[,.0-9]+)$", re.MULTILINE)
re_Split = re.compile(r"\*\*\* BOARD 1 - FLOP \*\*\*")
re_Table = re.compile(r"^\s?Table\s(ID\s)?\'(?P<TABLE>.+?)\'\s", re.MULTILINE|re.VERBOSE)

def compilePlayerRegexs(self, hand):
players = set([player[1] for player in hand.players])
Expand Down Expand Up @@ -260,6 +263,10 @@ def determineGameType(self, handText):
else:
info['split'] = False

m3 = self.re_Table.search(handText)
if m3 and 'AOF' in m3.group('TABLE'):
info['category'] = 'aof_omaha'

if info['limitType'] == 'fl' and info['bb'] is not None:
if info['type'] == 'ring':
try:
Expand All @@ -279,8 +286,8 @@ def determineGameType(self, handText):

def readHandInfo(self, hand):
#First check if partial
if hand.handText.count('*** SUMMARY ***')!=1:
raise FpdbHandPartial(("Hand is not cleanly split into pre and post Summary"))
if hand.handText.count('*** SUMMARY *') != 1:
raise FpdbHandPartial("Hand is not cleanly split into pre and post Summary")

info = {}
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
Expand Down Expand Up @@ -332,7 +339,7 @@ def readButton(self, hand):
log.info('readButton: ' + ('not found'))

def readPlayerStacks(self, hand):
pre, post = hand.handText.split('*** SUMMARY ***')
pre, post = hand.handText.split('*** SUMMARY *')
m = self.re_PlayerInfo.finditer(pre)
for a in m:
hand.addPlayer(
Expand Down Expand Up @@ -388,11 +395,20 @@ def markStreets(self, hand):
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", post,re.DOTALL)

elif hand.gametype['base'] in ("stud"):
m = re.search(r"(?P<THIRD>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
r"(\*\*\* 3RD STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
r"(\*\*\* 4TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
r"(\*\*\* 5TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
r"(\*\*\* 6TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
arr = hand.handText.split('*** 3RD STREET ***')
if self.re_BringIn.search(arr[0]):
m = re.search(r"(?P<THIRD>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
r"(\*\*\* 3RD STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
r"(\*\*\* 4TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
r"(\*\*\* 5TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
r"(\*\*\* 6TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.handText, re.DOTALL)
else:
m = re.search(r"(?P<ANTES>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
r"(\*\*\* 3RD STREET \*\*\*(?P<THIRD>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
r"(\*\*\* 4TH STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
r"(\*\*\* 5TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
r"(\*\*\* 6TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?"
r"(\*\*\* 7TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.handText, re.DOTALL)
elif hand.gametype['base'] in ("draw"):
if hand.gametype['category'] in ('27_1draw', 'fivedraw'):
m = re.search(r"(?P<PREDEAL>.+(?=\*\*\* 1ST BETTING ROUND \*\*\*)|.+)"
Expand All @@ -417,10 +433,10 @@ def markStreets(self, hand):
hand.streets.update({'FLOP1': m1.group('FLOP1'),'FLOP2': m1.group('FLOP2')})
if hand.streets.get('TURN') is None:
hand.streets.update({'TURN1': m1.group('TURN1'),'TURN2': m1.group('TURN2')})
hand.streets.update({'RIVER1': m1.group('RIVER1'),'RIVER2': m1.group('RIVER2')})
hand.streets.update({'RIVER1': m1.group('RIVER1'), 'RIVER2': m1.group('RIVER2')})
else:
m2 = re.search(
r"(\*\*\* RIVER \*\*\* \[(?P<FLOP>\S\S \S\S \S\S) (?P<TURN>\S\S)] (?P<RIVER>\[\S\S\].+(?=\*\*\* SUMMARY \*\*\*)|.+))", post,re.DOTALL)
m2 = re.search(
r"(\*\*\* RIVER \*\*\* \[(?P<FLOP>\S\S \S\S \S\S) (?P<TURN>\S\S)] (?P<RIVER>\[\S\S\].+(?=\*\*\* SUMMARY \*\s?\*\*)|.+))", post, re.DOTALL)
if m2:
if hand.streets.get('FLOP') is None:
hand.streets.update({'FLOP': m2.group('FLOP')})
Expand Down Expand Up @@ -449,19 +465,28 @@ def readSTP(self, hand):
hand.addSTP(m.group('AMOUNT'))

def readAntes(self, hand):
log.debug(("reading antes"))
log.debug("reading antes")
m = self.re_Antes.finditer(hand.handText)
pnames = set([])
for player in m:
#~ logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
hand.addAnte(
player.group('PNAME'),
str(Decimal(self.clearMoneyString(player.group('ANTE')))*100) if hand.tourNo is not None else self.clearMoneyString(player.group('ANTE'))
)
if player.group('PNAME') in pnames and hand.gametype['category'] == '6_holdem':
hand.addBlind(
player.group('PNAME'),
'button blind',
str(Decimal(self.clearMoneyString(player.group('ANTE')))*100) if hand.tourNo is not None else self.clearMoneyString(player.group('ANTE'))
)
else:
hand.addAnte(
player.group('PNAME'),
str(Decimal(self.clearMoneyString(player.group('ANTE')))*100) if hand.tourNo is not None else self.clearMoneyString(player.group('ANTE'))
)
pnames.add(player.group('PNAME'))

def readBringIn(self, hand):
m = self.re_BringIn.search(hand.handText,re.DOTALL)
if m:
#~ logging.debug("readBringIn: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
# ~ logging.debug("readBringIn: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
hand.addBringIn(
m.group('PNAME'),
str(Decimal(self.clearMoneyString(m.group('BRINGIN')))*100) if hand.tourNo is not None else self.clearMoneyString(m.group('BRINGIN'))
Expand Down Expand Up @@ -505,8 +530,9 @@ def readHoleCards(self, hand):
# else:
newcards = [x for x in found.group('NEWCARDS').split(' ') if x != 'X']
if len(newcards)>0:
hand.hero = found.group('PNAME')
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
hand.hero = found.group('PNAME')
_street = 'FLOP' if hand.gametype['category'] == 'aof_omaha' else street
hand.addHoleCards(_street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)

for street, text in list(hand.streets.items()):
if not text or street in ('PREFLOP', 'DEAL'): continue # already done these
Expand Down
5 changes: 4 additions & 1 deletion PacificPokerToFpdb.py
Expand Up @@ -242,6 +242,8 @@ def readHandInfo(self, hand):
datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "ET", "UTC")
hand.newFormat = datetime.datetime.strptime('20220908000000', '%Y%m%d%H%M%S') # this is a guess
hand.newFormat = HandHistoryConverter.changeTimezone(hand.newFormat, "ET", "UTC")
if key == 'HID':
hand.handid = info[key]
if key == 'TOURNO' and info['TOURNO'] != None:
Expand Down Expand Up @@ -351,7 +353,8 @@ def readBringIn(self, hand):
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))

def readBlinds(self, hand):
hand.setUncalledBets(True)
if hand.startTime < hand.newFormat:
hand.setUncalledBets(True)
liveBlind, hand.allInBlind = True, False
for a in self.re_PostSB.finditer(hand.handText):
if a.group('PNAME') in hand.stacks:
Expand Down

0 comments on commit 3de2e24

Please sign in to comment.