Merge branch 'master' of git://git.assembla.com/mctfpdb
This commit is contained in:
commit
d42739a958
|
@ -209,11 +209,10 @@ class Everleaf(HandHistoryConverter):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
c = Configuration.Config()
|
c = Configuration.Config()
|
||||||
if sys.argv[0] == '':
|
if len(sys.argv) == 1:
|
||||||
testfile = "regression-test-files/everleaf/Speed_Kuala_full.txt"
|
testfile = "regression-test-files/everleaf/Speed_Kuala_full.txt"
|
||||||
else:
|
else:
|
||||||
testfile = sys.argv[1]
|
testfile = sys.argv[1]
|
||||||
print "Converting: ", testfile
|
|
||||||
e = Everleaf(c, testfile)
|
e = Everleaf(c, testfile)
|
||||||
e.processFile()
|
e.processFile()
|
||||||
print str(e)
|
print str(e)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import codecs
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import operator
|
import operator
|
||||||
from time import time
|
from time import time
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
class Hand:
|
class Hand:
|
||||||
# def __init__(self, sitename, gametype, sb, bb, string):
|
# def __init__(self, sitename, gametype, sb, bb, string):
|
||||||
|
@ -38,7 +39,7 @@ class Hand:
|
||||||
self.gametype = gametype
|
self.gametype = gametype
|
||||||
self.string = string
|
self.string = string
|
||||||
|
|
||||||
self.streetList = ['BLINDS','PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
self.streetList = ['PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
||||||
|
|
||||||
self.handid = 0
|
self.handid = 0
|
||||||
self.sb = gametype[3]
|
self.sb = gametype[3]
|
||||||
|
@ -78,6 +79,8 @@ class Hand:
|
||||||
# dict from player names to lists of hole cards
|
# dict from player names to lists of hole cards
|
||||||
self.holecards = {}
|
self.holecards = {}
|
||||||
|
|
||||||
|
self.stacks = {}
|
||||||
|
|
||||||
# dict from player names to amounts collected
|
# dict from player names to amounts collected
|
||||||
self.collected = {}
|
self.collected = {}
|
||||||
|
|
||||||
|
@ -106,6 +109,7 @@ chips (string) the chips the player has at the start of the hand (can be None)
|
||||||
If a player has None chips he won't be added."""
|
If a player has None chips he won't be added."""
|
||||||
if chips is not None:
|
if chips is not None:
|
||||||
self.players.append([seat, name, chips])
|
self.players.append([seat, name, chips])
|
||||||
|
self.stacks[name] = Decimal(chips)
|
||||||
self.holecards[name] = set()
|
self.holecards[name] = set()
|
||||||
for street in self.streetList:
|
for street in self.streetList:
|
||||||
self.bets[street][name] = []
|
self.bets[street][name] = []
|
||||||
|
@ -176,7 +180,9 @@ Card ranks will be uppercased
|
||||||
# if player is None, it's a missing small blind.
|
# if player is None, it's a missing small blind.
|
||||||
if player is not None:
|
if player is not None:
|
||||||
self.bets['PREFLOP'][player].append(Decimal(amount))
|
self.bets['PREFLOP'][player].append(Decimal(amount))
|
||||||
self.actions['PREFLOP'] += [(player, 'posts', blindtype, amount)]
|
self.stacks[player] -= Decimal(amount)
|
||||||
|
print "DEBUG %s stack %s" % (player, self.stacks[player])
|
||||||
|
self.actions['PREFLOP'] += [(player, 'posts', blindtype, amount, self.stacks[player]==0)]
|
||||||
if blindtype == 'big blind':
|
if blindtype == 'big blind':
|
||||||
self.lastBet['PREFLOP'] = Decimal(amount)
|
self.lastBet['PREFLOP'] = Decimal(amount)
|
||||||
elif blindtype == 'small & big blinds':
|
elif blindtype == 'small & big blinds':
|
||||||
|
@ -191,7 +197,9 @@ Card ranks will be uppercased
|
||||||
if amount is not None:
|
if amount is not None:
|
||||||
self.bets[street][player].append(Decimal(amount))
|
self.bets[street][player].append(Decimal(amount))
|
||||||
#self.lastBet[street] = Decimal(amount)
|
#self.lastBet[street] = Decimal(amount)
|
||||||
self.actions[street] += [(player, 'calls', amount)]
|
self.stacks[player] -= Decimal(amount)
|
||||||
|
self.actions[street] += [(player, 'calls', amount, self.stacks[player]==0)]
|
||||||
|
|
||||||
|
|
||||||
def addRaiseTo(self, street, player, amountTo):
|
def addRaiseTo(self, street, player, amountTo):
|
||||||
"""\
|
"""\
|
||||||
|
@ -208,14 +216,20 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.lastBet[street] = Decimal(amountTo)
|
self.lastBet[street] = Decimal(amountTo)
|
||||||
amountBy = Decimal(amountTo) - amountToCall
|
amountBy = Decimal(amountTo) - amountToCall
|
||||||
self.bets[street][player].append(amountBy+amountToCall)
|
self.bets[street][player].append(amountBy+amountToCall)
|
||||||
self.actions[street] += [(player, 'raises', amountBy, amountTo, amountToCall)]
|
self.stacks[player] -= (Decimal(amountBy)+Decimal(amountToCall))
|
||||||
|
print "DEBUG %s stack %s" % (player, self.stacks[player])
|
||||||
|
self.actions[street] += [(player, 'raises', amountBy, amountTo, amountToCall, self.stacks[player]==0)]
|
||||||
|
|
||||||
|
|
||||||
def addBet(self, street, player, amount):
|
def addBet(self, street, player, amount):
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
self.bets[street][player].append(Decimal(amount))
|
self.bets[street][player].append(Decimal(amount))
|
||||||
self.actions[street] += [(player, 'bets', amount)]
|
self.stacks[player] -= Decimal(amount)
|
||||||
|
print "DEBUG %s stack %s" % (player, self.stacks[player])
|
||||||
|
self.actions[street] += [(player, 'bets', amount, self.stacks[player]==0)]
|
||||||
self.lastBet[street] = Decimal(amount)
|
self.lastBet[street] = Decimal(amount)
|
||||||
|
|
||||||
|
|
||||||
def addFold(self, street, player):
|
def addFold(self, street, player):
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
self.folded.add(player)
|
self.folded.add(player)
|
||||||
|
@ -246,9 +260,10 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.totalpot += reduce(operator.add, self.bets[street][player], 0)
|
self.totalpot += reduce(operator.add, self.bets[street][player], 0)
|
||||||
|
|
||||||
print "conventional totalpot:", self.totalpot
|
print "conventional totalpot:", self.totalpot
|
||||||
|
|
||||||
|
|
||||||
self.totalpot = 0
|
self.totalpot = 0
|
||||||
|
|
||||||
print self.actions
|
|
||||||
for street in self.actions:
|
for street in self.actions:
|
||||||
uncalled = 0
|
uncalled = 0
|
||||||
calls = [0]
|
calls = [0]
|
||||||
|
@ -278,6 +293,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.totalpot -= (uncalled - max(calls))
|
self.totalpot -= (uncalled - max(calls))
|
||||||
print "new totalpot:", self.totalpot
|
print "new totalpot:", self.totalpot
|
||||||
|
|
||||||
|
|
||||||
if self.totalcollected is None:
|
if self.totalcollected is None:
|
||||||
self.totalcollected = 0;
|
self.totalcollected = 0;
|
||||||
for amount in self.collected.values():
|
for amount in self.collected.values():
|
||||||
|
@ -417,15 +433,15 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
|
|
||||||
def printActionLine(self, act, fh):
|
def printActionLine(self, act, fh):
|
||||||
if act[1] == 'folds':
|
if act[1] == 'folds':
|
||||||
print >>fh, _("%s: folds" %(act[0]))
|
print >>fh, _("%s: folds " %(act[0]))
|
||||||
elif act[1] == 'checks':
|
elif act[1] == 'checks':
|
||||||
print >>fh, _("%s: checks" %(act[0]))
|
print >>fh, _("%s: checks " %(act[0]))
|
||||||
if act[1] == 'calls':
|
if act[1] == 'calls':
|
||||||
print >>fh, _("%s: calls $%s" %(act[0], act[2]))
|
print >>fh, _("%s: calls $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
||||||
if act[1] == 'bets':
|
if act[1] == 'bets':
|
||||||
print >>fh, _("%s: bets $%s" %(act[0], act[2]))
|
print >>fh, _("%s: bets $%s%s" %(act[0], act[2], ' and is all-in' if act[3] else ''))
|
||||||
if act[1] == 'raises':
|
if act[1] == 'raises':
|
||||||
print >>fh, _("%s: raises $%s to $%s" %(act[0], act[2], act[3]))
|
print >>fh, _("%s: raises $%s to $%s%s" %(act[0], act[2], act[3], ' and is all-in' if act[5] else ''))
|
||||||
|
|
||||||
# going to use pokereval to figure out hands at some point.
|
# going to use pokereval to figure out hands at some point.
|
||||||
# these functions are copied from pokergame.py
|
# these functions are copied from pokergame.py
|
||||||
|
|
|
@ -115,13 +115,15 @@ class HandHistoryConverter:
|
||||||
print "\nInput:\n"+hand.string
|
print "\nInput:\n"+hand.string
|
||||||
self.readHandInfo(hand)
|
self.readHandInfo(hand)
|
||||||
self.readPlayerStacks(hand)
|
self.readPlayerStacks(hand)
|
||||||
|
print "DEBUG", hand.stacks
|
||||||
self.markStreets(hand)
|
self.markStreets(hand)
|
||||||
self.readBlinds(hand)
|
self.readBlinds(hand)
|
||||||
self.readHeroCards(hand) # want to generalise to draw games
|
self.readHeroCards(hand) # want to generalise to draw games
|
||||||
self.readCommunityCards(hand) # read community cards
|
self.readCommunityCards(hand) # read community cards
|
||||||
self.readShowdownActions(hand)
|
self.readShowdownActions(hand)
|
||||||
# Read action (Note: no guarantee this is in hand order.
|
|
||||||
for street in hand.streets.groupdict():
|
# Read actions in street order
|
||||||
|
for street in hand.streetList: # go through them in order
|
||||||
if hand.streets.group(street) is not None:
|
if hand.streets.group(street) is not None:
|
||||||
self.readAction(hand, street)
|
self.readAction(hand, street)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user