[NEWIMPORT] Copy Grigorij's code from Alchemy
Copied some of Grigorij's code verbatim for calculating additional stats, still needs adapting. Also reorder some functions so the corresponding files are more mergeable in future.
This commit is contained in:
parent
355225fc25
commit
6e9153c25c
|
@ -262,13 +262,58 @@ class DerivedStats():
|
||||||
for (i, street) in enumerate(hand.actionStreets[1:]):
|
for (i, street) in enumerate(hand.actionStreets[1:]):
|
||||||
self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street]))
|
self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street]))
|
||||||
|
|
||||||
def calcCBets(self, hand):
|
def calcSteals(self, hand):
|
||||||
# Continuation Bet chance, action:
|
"""Fills stealAttempt(Chance|ed, fold(Bb|Sb)ToSteal(Chance|)
|
||||||
# Had the last bet (initiative) on previous street, got called, close street action
|
|
||||||
# Then no bets before the player with initiatives first action on current street
|
|
||||||
# ie. if player on street-1 had initiative
|
|
||||||
# and no donkbets occurred
|
|
||||||
|
|
||||||
|
Steal attemp - open raise on positions 2 1 0 S - i.e. MP3, CO, BU, SB
|
||||||
|
Fold to steal - folding blind after steal attemp wo any other callers or raisers
|
||||||
|
"""
|
||||||
|
if self.gametype_dict['base'] != 'hold':
|
||||||
|
# FIXME: add support for other games //grindi
|
||||||
|
return
|
||||||
|
steal_attemp = False
|
||||||
|
for action in hand.actions[hand.actionStreets[1]]:
|
||||||
|
hp, act = self.handplayers_by_name[action[0]], action[1]
|
||||||
|
#print action[0], hp.position, steal_attemp, act
|
||||||
|
if hp.position == 'B':
|
||||||
|
hp.foldBbToStealChance = steal_attemp
|
||||||
|
hp.foldBbToSteal = hp.foldBbToStealChance and act == 'folds'
|
||||||
|
break
|
||||||
|
elif hp.position == 'S':
|
||||||
|
hp.foldSbToStealChance = steal_attemp
|
||||||
|
hp.foldSbToSteal = hp.foldSbToStealChance and act == 'folds'
|
||||||
|
|
||||||
|
if steal_attemp and act != 'folds':
|
||||||
|
break
|
||||||
|
|
||||||
|
if hp.position in ('2', '1', '0', 'S') and not steal_attemp:
|
||||||
|
hp.stealAttemptChance = True
|
||||||
|
if act in ('bets', 'raises'):
|
||||||
|
hp.stealAttempted = True
|
||||||
|
steal_attemp = True
|
||||||
|
|
||||||
|
def calc34BetStreet0(self, hand):
|
||||||
|
"""Fills street0_(3|4)B(Chance|Done), other(3|4)BStreet0"""
|
||||||
|
bet_level = 1 # bet_level after 3-bet is equal to 3
|
||||||
|
for action in hand.actions[hand.actionStreets[1]]:
|
||||||
|
# FIXME: fill other(3|4)BStreet0 - i have no idea what does it mean
|
||||||
|
hp, aggr = self.handplayers_by_name[action[0]], action[1] in ('raises', 'bets')
|
||||||
|
hp.street0_3BChance = bet_level == 2
|
||||||
|
hp.street0_4BChance = bet_level == 3
|
||||||
|
hp.street0_3BDone = aggr and (hp.street0_3BChance)
|
||||||
|
hp.street0_4BDone = aggr and (hp.street0_4BChance)
|
||||||
|
if aggr:
|
||||||
|
bet_level += 1
|
||||||
|
|
||||||
|
|
||||||
|
def calcCBets(self, hand):
|
||||||
|
"""Fill streetXCBChance, streetXCBDone, foldToStreetXCBDone, foldToStreetXCBChance
|
||||||
|
|
||||||
|
Continuation Bet chance, action:
|
||||||
|
Had the last bet (initiative) on previous street, got called, close street action
|
||||||
|
Then no bets before the player with initiatives first action on current street
|
||||||
|
ie. if player on street-1 had initiative and no donkbets occurred
|
||||||
|
"""
|
||||||
# XXX: enumerate(list, start=x) is python 2.6 syntax; 'start'
|
# XXX: enumerate(list, start=x) is python 2.6 syntax; 'start'
|
||||||
# came there
|
# came there
|
||||||
#for i, street in enumerate(hand.actionStreets[2:], start=1):
|
#for i, street in enumerate(hand.actionStreets[2:], start=1):
|
||||||
|
@ -280,6 +325,29 @@ class DerivedStats():
|
||||||
if chance == True:
|
if chance == True:
|
||||||
self.handsplayers[name]['street%dCBDone' % (i+1)] = self.betStreet(hand.actionStreets[i+2], name)
|
self.handsplayers[name]['street%dCBDone' % (i+1)] = self.betStreet(hand.actionStreets[i+2], name)
|
||||||
|
|
||||||
|
def calcCheckCallRaise(self, hand):
|
||||||
|
"""Fill streetXCheckCallRaiseChance, streetXCheckCallRaiseDone
|
||||||
|
|
||||||
|
streetXCheckCallRaiseChance = got raise/bet after check
|
||||||
|
streetXCheckCallRaiseDone = checked. got raise/bet. didn't fold
|
||||||
|
|
||||||
|
CG: CheckCall would be a much better name for this.
|
||||||
|
"""
|
||||||
|
for i, street in enumerate(hand.actionStreets[2:], start=1):
|
||||||
|
actions = hand.actions[hand.actionStreets[i]]
|
||||||
|
checkers = set()
|
||||||
|
initial_raiser = None
|
||||||
|
for action in actions:
|
||||||
|
pname, act = action[0], action[1]
|
||||||
|
if act in ('bets', 'raises') and initial_raiser is None:
|
||||||
|
initial_raiser = pname
|
||||||
|
elif act == 'check' and initial_raiser is None:
|
||||||
|
checkers.add(pname)
|
||||||
|
elif initial_raiser is not None and pname in checkers:
|
||||||
|
hp = self.handplayers_by_name[pname]
|
||||||
|
setattr(hp, 'street%dCheckCallRaiseChance' % i, True)
|
||||||
|
setattr(hp, 'street%dCheckCallRaiseDone' % i, act!='folds')
|
||||||
|
|
||||||
def seen(self, hand, i):
|
def seen(self, hand, i):
|
||||||
pas = set()
|
pas = set()
|
||||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||||
|
@ -333,6 +401,27 @@ class DerivedStats():
|
||||||
players.add(action[0])
|
players.add(action[0])
|
||||||
return players
|
return players
|
||||||
|
|
||||||
|
|
||||||
|
def firstsBetOrRaiser(self, actions):
|
||||||
|
"""Returns player name that placed the first bet or raise.
|
||||||
|
|
||||||
|
None if there were no bets or raises on that street
|
||||||
|
"""
|
||||||
|
for act in actions:
|
||||||
|
if act[1] in ('bets', 'raises'):
|
||||||
|
return act[0]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def lastBetOrRaiser(self, street):
|
||||||
|
"""Returns player name that placed the last bet or raise for that street.
|
||||||
|
None if there were no bets or raises on that street"""
|
||||||
|
lastbet = None
|
||||||
|
for act in self.hand.actions[street]:
|
||||||
|
if act[1] in ('bets', 'raises'):
|
||||||
|
lastbet = act[0]
|
||||||
|
return lastbet
|
||||||
|
|
||||||
|
|
||||||
def noBetsBefore(self, street, player):
|
def noBetsBefore(self, street, player):
|
||||||
"""Returns true if there were no bets before the specified players turn, false otherwise"""
|
"""Returns true if there were no bets before the specified players turn, false otherwise"""
|
||||||
betOrRaise = False
|
betOrRaise = False
|
||||||
|
@ -345,6 +434,7 @@ class DerivedStats():
|
||||||
break
|
break
|
||||||
return betOrRaise
|
return betOrRaise
|
||||||
|
|
||||||
|
|
||||||
def betStreet(self, street, player):
|
def betStreet(self, street, player):
|
||||||
"""Returns true if player bet/raised the street as their first action"""
|
"""Returns true if player bet/raised the street as their first action"""
|
||||||
betOrRaise = False
|
betOrRaise = False
|
||||||
|
@ -353,14 +443,4 @@ class DerivedStats():
|
||||||
betOrRaise = True
|
betOrRaise = True
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return betOrRaise
|
|
||||||
|
|
||||||
|
|
||||||
def lastBetOrRaiser(self, street):
|
|
||||||
"""Returns player name that placed the last bet or raise for that street.
|
|
||||||
None if there were no bets or raises on that street"""
|
|
||||||
lastbet = None
|
|
||||||
for act in self.hand.actions[street]:
|
|
||||||
if act[1] in ('bets', 'raises'):
|
|
||||||
lastbet = act[0]
|
|
||||||
return lastbet
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user