Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions src/analyzer/txtanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def _analyzePostflop(self, lines):
elif(self.pokerNetwork == PokerNetwork.IPOKER):
pfActionRegex = r"(.*): (Fold|Call|Bet|Check|Raise|Allin)( \(NF\))?( Allin )?( .([0-9\.]*))?"
cardRegex = r"\*\*\* (FLOP|TURN|RIVER) \*\*\* \[(.{2,3})( (.{2,3}) (.{2,3}))?\]"
elif(self.pokerNetwork == PokerNetwork.HEM2):
pfActionRegex = r"(.*) (folds|calls|checks|raises|bets)( \[([0-9\.]*)\])?"
cardRegex = r"\*\* Dealing (Flop|Turn|River) \*\* \[ (..)(, (..), (..))? \]"


for line in lines:
Expand Down Expand Up @@ -130,7 +133,7 @@ def _parseCardFormat(self,card):
def _analyzePreflop(self, pfLines):

blindRegex = r"(.*) posts (small|big) blind"

getBlindsFromPreflop = False

if(self.pokerNetwork == PokerNetwork.PARTY):
pfActionRegex = r"(.*) (folds|calls|checks|raises|is all-In)( \[.([0-9\.]*) .+\])?"
Expand All @@ -146,6 +149,11 @@ def _analyzePreflop(self, pfLines):
blindRegex = r"(.*): Post (SB|BB) .*"
dealtToRegex = r"Dealt to (.*) \[(..) (..)\]"
pfActionRegex = r"(.*): (Fold|Call|Check|Raise|Allin)( \(NF\))?( Allin)?( .([0-9\.]*))?"
elif(self.pokerNetwork == PokerNetwork.HEM2):
blindRegex = r"(.*) posts (small|big) blind \[([0-9\.]*)\]"
dealtToRegex = r"Dealt to (.*) \[ (..) (..) \]"
pfActionRegex = r"(.*) (folds|calls|checks|raises)( \[([0-9\.]*)\])?"
getBlindsFromPreflop = True


for line in pfLines:
Expand All @@ -155,9 +163,13 @@ def _analyzePreflop(self, pfLines):
player = self._correctPlayerName(player)
if(searchObj.group(2) == "small" or searchObj.group(2) == "SB"):
self.pfActions.append((player,"S"))
if getBlindsFromPreflop == True:
self.sb = searchObj.group(3)
else:
self.pfActions.append((player,"B"))

if getBlindsFromPreflop == True:
self.bb = searchObj.group(3)

searchObj = re.search(dealtToRegex, line)
if(searchObj):
self.hero = searchObj.group(1)
Expand Down Expand Up @@ -186,6 +198,8 @@ def _analyzeSeats(self, lines):
seatRegex = r"Seat [0-9]+: (.*) \(.([0-9\.]*) in chips\)"
elif(self.pokerNetwork == PokerNetwork.IPOKER):
seatRegex = r"Seat [0-9]+: (.*) \(.([0-9\.]*) in chips\)( DEALER)?"
elif(self.pokerNetwork == PokerNetwork.HEM2):
seatRegex = r"Seat [0-9]+: (.*) \( ([0-9\.]*) \) (.*)"

for line in lines:
searchObj = re.search(seatRegex, line)
Expand All @@ -204,6 +218,7 @@ def _analyzeHeader(self, lines):
sbPos = 1
bbPos = 2
gameTypePos = 3
getBlindsFromPreflop = False

if(self.pokerNetwork == PokerNetwork.PARTY):
gameIdRegex = r"Game ([0-9]*) \*\*\*\*\*"
Expand All @@ -225,7 +240,14 @@ def _analyzeHeader(self, lines):
sbPos = 2
bbPos = 3
gameTypePos = 1

elif(self.pokerNetwork == PokerNetwork.HEM2):
gameIdRegex = r"Game ([0-9]*) \*\*\*\*\*"
blindRegex = r"Hand (.*) Texas (.*) - (.*)"
sbPos = 2
bbPos = 3
gameTypePos = 1
getBlindsFromPreflop = True

searchObj = re.search(gameIdRegex, lines[gameIdLine])
if(searchObj):
self.handId = searchObj.group(1)
Expand All @@ -234,8 +256,9 @@ def _analyzeHeader(self, lines):

searchObj = re.search(blindRegex, lines[blindIdLine])
if(searchObj):
self.sb = searchObj.group(sbPos)
self.bb = searchObj.group(bbPos)
if getBlindsFromPreflop == False:
self.sb = searchObj.group(sbPos)
self.bb = searchObj.group(bbPos)
if(searchObj.group(gameTypePos) in ("No Limit", "NL")):
self.gameType = "NL"
elif(searchObj.group(gameTypePos) in ("Pot Limit", "PL")):
Expand All @@ -256,6 +279,9 @@ def findPokerNetwork(self):

if(headerLine.find('888poker') != -1):
self.pokerNetwork = PokerNetwork.POKER888
elif(headerLine.find('***** Hand History for Game 1111111111 *****') != -1):
self.pokerNetwork = PokerNetwork.HEM2
# Following pattern seems bad and should be changed as it conflicts with generic HH format from HEM2 above
elif(headerLine.find('***** Hand History') != -1):
self.pokerNetwork = PokerNetwork.PARTY
elif(headerLine.find('PokerStars') != -1):
Expand Down Expand Up @@ -304,8 +330,11 @@ def analyze(self):
postflopLineSep = "*** SUMMARY ***"
seatLineSep = " posts "
nrHeaderLines = 2


elif(self.pokerNetwork == PokerNetwork.HEM2):
preflopLineSep = "** Dealing Flop **"
postflopLineSep = " shows "
seatLineSep = " posts "
nrHeaderLines = 3

#read header lines
for i in range(nrHeaderLines):
Expand Down Expand Up @@ -344,7 +373,8 @@ class PokerNetwork():
POKER888 = 2
PARTY = 3
IPOKER = 4
UNKNOWN = 5
HEM2 = 5
UNKNOWN = 6



Expand Down