Added new showdownStrings dictionary in the Hand module as well as the appropriate regex in re_ShownCards for capturing the text discrption of showdown hands. FTP and Stars only for now. Once evaluating hand strings is added to Stove, this will be used as a back up for games Poker-eval does not fully support such as Razz and Badugi

This commit is contained in:
Chaz Littlejohn 2011-04-04 19:57:54 +00:00
parent c518c482ac
commit 5f9d402701
3 changed files with 20 additions and 9 deletions

View File

@ -170,7 +170,7 @@ class Fulltilt(HandHistoryConverter):
self.re_ShowdownAction = re.compile(r"^%s shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %(PLAYERS)s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \([%(LS)s]?(?P<POT>[%(NUM)s]+)\)(, mucked| with.*)?" % self.substitutions, re.MULTILINE)
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(?P<ACT>showed|mucked) \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(?P<ACT>showed|mucked) \[(?P<CARDS>.*)\](( and won \(.*\) with | and lost with | \- )(?P<STRING>.*))?" % player_re, re.MULTILINE)
def readSupportedGames(self):
return [["ring", "hold", "nl"],
@ -525,10 +525,11 @@ class Fulltilt(HandHistoryConverter):
def readShownCards(self,hand):
for m in self.re_ShownCards.finditer(hand.handText):
if m.group('CARDS') is not None:
string = m.group('STRING')
if m.group('ACT'):
hand.addShownCards(cards=m.group('CARDS').split(' '), player=m.group('PNAME'), shown = False, mucked = True)
hand.addShownCards(cards=m.group('CARDS').split(' '), player=m.group('PNAME'), shown = False, mucked = True, string = string)
else:
hand.addShownCards(cards=m.group('CARDS').split(' '), player=m.group('PNAME'), shown = True, mucked = False)
hand.addShownCards(cards=m.group('CARDS').split(' '), player=m.group('PNAME'), shown = True, mucked = False, string = string)
def guessMaxSeats(self, hand):
"""Return a guess at max_seats when not specified in HH."""

View File

@ -113,6 +113,7 @@ class Hand(object):
self.board = {} # dict from street names to community cards
self.holecards = {}
self.discards = {}
self.showdownStrings = {}
for street in self.allStreets:
self.streets[street] = "" # portions of the handText, filled by markStreets()
self.actions[street] = []
@ -711,7 +712,7 @@ Add a raise on [street] by [player] to [amountTo]
self.collectees[player] += Decimal(pot)
def addShownCards(self, cards, player, holeandboard=None, shown=True, mucked=False):
def addShownCards(self, cards, player, holeandboard=None, shown=True, mucked=False, string=None):
"""\
For when a player shows cards for any reason (for showdown or out of choice).
Card ranks will be uppercased
@ -719,6 +720,8 @@ Card ranks will be uppercased
log.debug(_("addShownCards %s hole=%s all=%s") % (player, cards, holeandboard))
if cards is not None:
self.addHoleCards(cards,player,shown, mucked)
if string is not None:
self.showdownStrings[player] = string
elif holeandboard is not None:
holeandboard = set([self.card(c) for c in holeandboard])
board = set([c for s in self.board.values() for c in s])
@ -913,7 +916,7 @@ class HoldemOmahaHand(Hand):
pass
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False, string=None):
if player == self.hero: # we have hero's cards just update shown/mucked
if shown: self.shown.add(player)
if mucked: self.mucked.add(player)
@ -926,6 +929,8 @@ class HoldemOmahaHand(Hand):
diff = filter( lambda x: x not in self.board['FLOP']+self.board['TURN']+self.board['RIVER'], cards )
if len(diff) == 2 and self.gametype['category'] in ('holdem'):
self.addHoleCards('PREFLOP', player, open=[], closed=diff, shown=shown, mucked=mucked, dealt=dealt)
if string is not None:
self.showdownStrings[player] = string
def getStreetTotals(self):
# street1Pot INT, /* pot size at flop/street4 */
@ -1201,13 +1206,15 @@ class DrawHand(Hand):
elif builtFrom == "DB":
self.select("dummy") # Will need a handId
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False, string=None):
if player == self.hero: # we have hero's cards just update shown/mucked
if shown: self.shown.add(player)
if mucked: self.mucked.add(player)
else:
# TODO: Probably better to find the last street with action and add the hole cards to that street
self.addHoleCards('DRAWTHREE', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)
if string is not None:
self.showdownStrings[player] = string
def discardDrawHoleCards(self, cards, player, street):
@ -1379,7 +1386,7 @@ class StudHand(Hand):
elif builtFrom == "DB":
self.select("dummy") # Will need a handId
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False, string=None):
if player == self.hero: # we have hero's cards just update shown/mucked
if shown: self.shown.add(player)
if mucked: self.mucked.add(player)
@ -1390,6 +1397,8 @@ class StudHand(Hand):
self.addHoleCards('SIXTH', player, open=[cards[5]], closed=cards[2:5], shown=shown, mucked=mucked)
if len(cards) > 6:
self.addHoleCards('SEVENTH', player, open=[], closed=[cards[6]], shown=shown, mucked=mucked)
if string is not None:
self.showdownStrings[player] = string
def addPlayerCards(self, player, street, open=[], closed=[]):

View File

@ -157,7 +157,7 @@ class PokerStars(HandHistoryConverter):
% short_subst, re.MULTILINE|re.VERBOSE)
re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % short_subst['PLYR'], re.MULTILINE)
re_sitsOut = re.compile("^%s sits out" % short_subst['PLYR'], re.MULTILINE)
re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s (\(.*\) )?(?P<SHOWED>showed|mucked) \[(?P<CARDS>.*)\].*" % short_subst['PLYR'], re.MULTILINE)
re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s (\(.*\) )?(?P<SHOWED>showed|mucked) \[(?P<CARDS>.*)\]( and won \([.\d]+\) with (?P<STRING>.*))?" % short_subst['PLYR'], re.MULTILINE)
re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): %(PLYR)s (\(button\) |\(small blind\) |\(big blind\) |\(button\) \(small blind\) |\(button\) \(big blind\) )?(collected|showed \[.*\] and won) \(%(CUR)s(?P<POT>[.\d]+)\)(, mucked| with.*|)" % short_subst, re.MULTILINE)
def compilePlayerRegexs(self, hand):
@ -462,13 +462,14 @@ class PokerStars(HandHistoryConverter):
if m.group('CARDS') is not None:
cards = m.group('CARDS')
cards = cards.split(' ') # needs to be a list, not a set--stud needs the order
string = m.group('STRING')
(shown, mucked) = (False, False)
if m.group('SHOWED') == "showed": shown = True
elif m.group('SHOWED') == "mucked": mucked = True
#print "DEBUG: hand.addShownCards(%s, %s, %s, %s)" %(cards, m.group('PNAME'), shown, mucked)
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked)
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked, string=string)
if __name__ == "__main__":
parser = OptionParser()