2010-07-08 20:01:03 +02:00
|
|
|
#!/usr/bin/env python
|
2010-06-13 07:40:59 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-08-19 00:53:25 +02:00
|
|
|
|
|
|
|
"""Manage collecting and formatting of stats and tooltips.
|
|
|
|
"""
|
2010-07-04 03:05:16 +02:00
|
|
|
# Copyright 2008-2010, Ray E. Barker
|
2008-08-19 00:53:25 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
########################################################################
|
2008-08-20 21:29:08 +02:00
|
|
|
|
|
|
|
# How to write a new stat:
|
2009-07-24 00:15:02 +02:00
|
|
|
# 0 Do not use a name like "xyz_2". Names ending in _ and a single digit are
|
|
|
|
# used to indicate the number of decimal places the user wants to see in the Hud.
|
2008-08-20 21:29:08 +02:00
|
|
|
# 1 You can see a listing of all the raw stats (e.g., from the HudCache table)
|
|
|
|
# by running Database.py as a stand along program. You need to combine
|
|
|
|
# those raw stats to get stats to present to the HUD. If you need more
|
|
|
|
# information than is in the HudCache table, then you have to write SQL.
|
|
|
|
# 2 The raw stats seen when you run Database.py are available in the Stats.py
|
|
|
|
# in the stat_dict dict. For example the number of vpips would be
|
|
|
|
# stat_dict[player]['vpip']. So the % vpip is
|
|
|
|
# float(stat_dict[player]['vpip'])/float(stat_dict[player]['n']). You can see how the
|
|
|
|
# keys of stat_dict relate to the column names in HudCache by inspecting
|
|
|
|
# the proper section of the SQL.py module.
|
2009-04-27 22:29:02 +02:00
|
|
|
# The stat_dict keys should be in lower case, i.e. vpip not VPIP, since
|
|
|
|
# postgres returns the column names in lower case.
|
2008-08-20 21:29:08 +02:00
|
|
|
# 3 You have to write a small function for each stat you want to add. See
|
|
|
|
# the vpip() function for example. This function has to be protected from
|
|
|
|
# exceptions, using something like the try:/except: paragraphs in vpip.
|
|
|
|
# 4 The name of the function has to be the same as the of the stat used
|
|
|
|
# in the config file.
|
|
|
|
# 5 The stat functions have a peculiar return value, which is outlined in
|
|
|
|
# the do_stat function. This format is useful for tool tips and maybe
|
|
|
|
# other stuff.
|
|
|
|
# 6 For each stat you make add a line to the __main__ function to test it.
|
|
|
|
|
2010-09-23 08:31:16 +02:00
|
|
|
import L10n
|
|
|
|
_ = L10n.get_translation()
|
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
# Standard Library modules
|
2010-08-04 23:23:28 +02:00
|
|
|
import sys
|
2008-08-19 00:53:25 +02:00
|
|
|
|
|
|
|
# pyGTK modules
|
|
|
|
import pygtk
|
|
|
|
import gtk
|
2009-07-24 00:15:02 +02:00
|
|
|
import re
|
2008-08-19 00:53:25 +02:00
|
|
|
|
|
|
|
# FreePokerTools modules
|
|
|
|
import Configuration
|
|
|
|
import Database
|
2010-05-17 19:23:17 +02:00
|
|
|
import Charset
|
2008-08-19 00:53:25 +02:00
|
|
|
|
2010-08-04 23:23:28 +02:00
|
|
|
import logging
|
|
|
|
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
|
|
|
log = logging.getLogger("db")
|
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
|
|
|
|
re_Places = re.compile("_[0-9]$")
|
|
|
|
|
2010-01-19 18:25:36 +01:00
|
|
|
# String manipulation
|
|
|
|
import codecs
|
|
|
|
encoder = codecs.lookup(Configuration.LOCALE_ENCODING)
|
2009-07-24 00:15:02 +02:00
|
|
|
|
2010-08-30 11:35:49 +02:00
|
|
|
|
|
|
|
# Since tuples are immutable, we have to create a new one when
|
|
|
|
# overriding any decimal placements. Copy old ones and recreate the
|
|
|
|
# second value in tuple to specified format-
|
|
|
|
def __stat_override(decimals, stat_vals):
|
|
|
|
s = '%.*f' % (decimals, 100.0*stat_vals[0])
|
|
|
|
res = (stat_vals[0], s, stat_vals[2],
|
|
|
|
stat_vals[3], stat_vals[4], stat_vals[5])
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
def do_tip(widget, tip):
|
2010-05-17 19:23:17 +02:00
|
|
|
_tip = Charset.to_utf8(tip)
|
2010-01-19 18:25:36 +01:00
|
|
|
widget.set_tooltip_text(_tip)
|
2008-08-19 00:53:25 +02:00
|
|
|
|
2010-08-22 12:09:26 +02:00
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
def do_stat(stat_dict, player = 24, stat = 'vpip'):
|
2010-08-30 11:35:49 +02:00
|
|
|
statname = stat
|
2009-07-24 00:15:02 +02:00
|
|
|
match = re_Places.search(stat)
|
2010-08-30 11:35:49 +02:00
|
|
|
if match: # override if necessary
|
|
|
|
statname = stat[0:-2]
|
|
|
|
|
|
|
|
result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': statname, 'player': player})
|
2010-08-22 12:09:26 +02:00
|
|
|
|
|
|
|
# If decimal places have been defined, override result[1]
|
2010-08-22 13:12:29 +02:00
|
|
|
# NOTE: decimal place override ALWAYS assumes the raw result is a
|
|
|
|
# fraction (x/100); manual decimal places really only make sense for
|
|
|
|
# percentage values. Also, profit/100 hands (bb/BB) already default
|
|
|
|
# to three decimal places anyhow, so they are unlikely override
|
|
|
|
# candidates.
|
2010-08-22 12:09:26 +02:00
|
|
|
if match:
|
2009-07-24 00:15:02 +02:00
|
|
|
places = int(stat[-1:])
|
2010-08-30 11:35:49 +02:00
|
|
|
result = __stat_override(places, result)
|
2009-07-24 00:15:02 +02:00
|
|
|
return result
|
2008-10-31 19:34:41 +01:00
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
# OK, for reference the tuple returned by the stat is:
|
|
|
|
# 0 - The stat, raw, no formating, eg 0.33333333
|
2010-08-22 12:09:26 +02:00
|
|
|
# 1 - formatted stat with appropriate precision, eg. 33; shown in HUD
|
2008-08-19 00:53:25 +02:00
|
|
|
# 2 - formatted stat with appropriate precision, punctuation and a hint, eg v=33%
|
|
|
|
# 3 - same as #2 except name of stat instead of hint, eg vpip=33%
|
|
|
|
# 4 - the calculation that got the stat, eg 9/27
|
|
|
|
# 5 - the name of the stat, useful for a tooltip, eg vpip
|
|
|
|
|
|
|
|
###########################################
|
|
|
|
# functions that return individual stats
|
2008-10-31 19:34:41 +01:00
|
|
|
|
2009-02-26 15:27:59 +01:00
|
|
|
def totalprofit(stat_dict, player):
|
2009-10-24 13:41:51 +02:00
|
|
|
""" Total Profit."""
|
2009-02-26 15:27:59 +01:00
|
|
|
if stat_dict[player]['net'] != 0:
|
|
|
|
stat = float(stat_dict[player]['net']) / 100
|
2010-08-17 19:50:22 +02:00
|
|
|
return (stat, '$%.2f' % stat, 'tp=$%.2f' % stat, 'totalprofit=$%.2f' % stat, str(stat), _('Total Profit'))
|
|
|
|
return ('0', '$0.00', 'tp=0', 'totalprofit=0', '0', _('Total Profit'))
|
2009-02-26 15:27:59 +01:00
|
|
|
|
2008-10-31 19:34:41 +01:00
|
|
|
def playername(stat_dict, player):
|
2008-12-02 01:15:50 +01:00
|
|
|
""" Player Name."""
|
2008-10-31 19:34:41 +01:00
|
|
|
return (stat_dict[player]['screen_name'],
|
|
|
|
stat_dict[player]['screen_name'],
|
|
|
|
stat_dict[player]['screen_name'],
|
|
|
|
stat_dict[player]['screen_name'],
|
|
|
|
stat_dict[player]['screen_name'],
|
|
|
|
stat_dict[player]['screen_name'])
|
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
def vpip(stat_dict, player):
|
2010-06-13 07:40:59 +02:00
|
|
|
""" Voluntarily put $ in the pot pre-flop."""
|
2008-08-19 00:53:25 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['vpip'])/float(stat_dict[player]['n'])
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'v=%3.1f%%' % (100.0*stat),
|
|
|
|
'vpip=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['vpip'], stat_dict[player]['n']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Voluntarily Put In Pot Pre-Flop%')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
2010-05-24 08:26:19 +02:00
|
|
|
except: return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'v=NA',
|
|
|
|
'vpip=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Voluntarily Put In Pot Pre-Flop%')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def pfr(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Preflop (3rd street) raise."""
|
2008-08-19 00:53:25 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['pfr'])/float(stat_dict[player]['n'])
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'p=%3.1f%%' % (100.0*stat),
|
|
|
|
'pfr=%3.1f%%' % (100.0*stat),
|
2008-08-19 00:53:25 +02:00
|
|
|
'(%d/%d)' % (stat_dict[player]['pfr'], stat_dict[player]['n']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Pre-Flop Raise %')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
except:
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'p=NA',
|
|
|
|
'pfr=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Pre-Flop Raise %')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def wtsd(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Went to SD when saw flop/4th."""
|
2008-08-19 00:53:25 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['sd'])/float(stat_dict[player]['saw_f'])
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'w=%3.1f%%' % (100.0*stat),
|
|
|
|
'wtsd=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['sd'], stat_dict[player]['saw_f']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% went to showdown')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
except:
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'w=NA',
|
|
|
|
'wtsd=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% went to showdown')
|
2008-08-20 21:29:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def wmsd(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Won $ at showdown."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['wmsd'])/float(stat_dict[player]['sd'])
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'w=%3.1f%%' % (100.0*stat),
|
|
|
|
'wmsd=%3.1f%%' % (100.0*stat),
|
2008-12-02 01:15:50 +01:00
|
|
|
'(%5.1f/%d)' % (float(stat_dict[player]['wmsd']), stat_dict[player]['sd']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% won money at showdown')
|
2008-08-20 21:29:08 +02:00
|
|
|
)
|
|
|
|
except:
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'w=NA',
|
|
|
|
'wmsd=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% won money at showdown')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
|
2010-08-31 10:40:21 +02:00
|
|
|
# Money is stored as pennies, so there is an implicit 100-multiplier
|
|
|
|
# already in place
|
2009-07-24 00:15:02 +02:00
|
|
|
def profit100(stat_dict, player):
|
2010-08-04 23:23:28 +02:00
|
|
|
""" Profit won per 100 hands."""
|
2009-01-03 19:00:44 +01:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['net'])/float(stat_dict[player]['n'])
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-31 10:40:21 +02:00
|
|
|
'%.2f' % (stat),
|
|
|
|
'p=%.2f' % (stat),
|
|
|
|
'p/100=%.2f' % (stat),
|
2009-01-03 19:00:44 +01:00
|
|
|
'%d/%d' % (stat_dict[player]['net'], stat_dict[player]['n']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('profit/100hands')
|
2009-01-03 19:00:44 +01:00
|
|
|
)
|
|
|
|
except:
|
2010-08-17 19:50:22 +02:00
|
|
|
print _("exception calcing p/100: 100 * %d / %d") % (stat_dict[player]['net'], stat_dict[player]['n'])
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'p=NA',
|
|
|
|
'p/100=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('profit/100hands')
|
2009-01-03 19:00:44 +01:00
|
|
|
)
|
|
|
|
|
2010-08-04 23:23:28 +02:00
|
|
|
def bbper100(stat_dict, player):
|
|
|
|
""" big blinds won per 100 hands."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = 100.0 * float(stat_dict[player]['net']) / float(stat_dict[player]['bigblind'])
|
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%5.3f' % (stat),
|
|
|
|
'bb100=%5.3f' % (stat),
|
|
|
|
'bb100=%5.3f' % (stat),
|
|
|
|
'(%d,%d)' % (100*stat_dict[player]['net'],stat_dict[player]['bigblind']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('big blinds/100 hands')
|
2010-08-04 23:23:28 +02:00
|
|
|
)
|
|
|
|
except:
|
|
|
|
log.info("exception calcing bb/100: "+str(stat_dict[player]))
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'bb100=NA',
|
|
|
|
'bb100=NA',
|
|
|
|
'(--)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('big blinds/100 hands')
|
2010-08-04 23:23:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def BBper100(stat_dict, player):
|
|
|
|
""" Big Bets won per 100 hands."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = 50 * float(stat_dict[player]['net']) / float(stat_dict[player]['bigblind'])
|
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%5.3f' % (stat),
|
|
|
|
'BB100=%5.3f' % (stat),
|
|
|
|
'BB100=%5.3f' % (stat),
|
|
|
|
'(%d,%d)' % (100*stat_dict[player]['net'],2*stat_dict[player]['bigblind']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Big Bets/100 hands')
|
2010-08-04 23:23:28 +02:00
|
|
|
)
|
|
|
|
except:
|
2010-08-17 19:50:22 +02:00
|
|
|
log.info(_("exception calcing BB/100: ")+str(stat_dict[player]))
|
2010-08-04 23:23:28 +02:00
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'BB100=NA',
|
|
|
|
'BB100=NA',
|
|
|
|
'(--)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Big Bets/100 hands')
|
2010-08-04 23:23:28 +02:00
|
|
|
)
|
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
def saw_f(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Saw flop/4th."""
|
2008-08-19 00:53:25 +02:00
|
|
|
try:
|
|
|
|
num = float(stat_dict[player]['saw_f'])
|
|
|
|
den = float(stat_dict[player]['n'])
|
|
|
|
stat = num/den
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'sf=%3.1f%%' % (100.0*stat),
|
|
|
|
'saw_f=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['saw_f'], stat_dict[player]['n']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Flop Seen %')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
except:
|
|
|
|
stat = 0.0
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'sf=NA',
|
|
|
|
'saw_f=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Flop Seen %')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def n(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Number of hands played."""
|
2008-08-19 00:53:25 +02:00
|
|
|
try:
|
2010-02-07 13:23:29 +01:00
|
|
|
# If sample is large enough, use X.Yk notation instead
|
|
|
|
_n = stat_dict[player]['n']
|
|
|
|
fmt = '%d' % _n
|
2010-02-15 00:29:20 +01:00
|
|
|
if _n >= 10000:
|
2010-02-07 13:23:29 +01:00
|
|
|
k = _n / 1000
|
|
|
|
c = _n % 1000
|
|
|
|
_c = float(c) / 100.0
|
|
|
|
d = int(round(_c))
|
|
|
|
if d == 10:
|
|
|
|
k += 1
|
|
|
|
d = 0
|
|
|
|
fmt = '%d.%dk' % (k, d)
|
2010-05-24 08:26:19 +02:00
|
|
|
return (stat_dict[player]['n'],
|
2010-02-07 13:23:29 +01:00
|
|
|
'%s' % fmt,
|
2010-05-24 08:26:19 +02:00
|
|
|
'n=%d' % (stat_dict[player]['n']),
|
|
|
|
'n=%d' % (stat_dict[player]['n']),
|
2008-08-19 00:53:25 +02:00
|
|
|
'(%d)' % (stat_dict[player]['n']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('number hands seen')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
except:
|
2010-08-22 12:57:01 +02:00
|
|
|
# Number of hands shouldn't ever be "NA"; zeroes are better here
|
2010-05-24 08:26:19 +02:00
|
|
|
return (0,
|
|
|
|
'%d' % (0),
|
|
|
|
'n=%d' % (0),
|
|
|
|
'n=%d' % (0),
|
2008-09-15 22:31:55 +02:00
|
|
|
'(%d)' % (0),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('number hands seen')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def fold_f(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Folded flop/4th."""
|
2008-08-19 00:53:25 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2010-05-13 05:57:59 +02:00
|
|
|
stat = float(stat_dict[player]['fold_2'])/float(stat_dict[player]['saw_f'])
|
2008-08-19 00:53:25 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'ff=%3.1f%%' % (100.0*stat),
|
|
|
|
'fold_f=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['fold_2'], stat_dict[player]['saw_f']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('folded flop/4th')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'ff=NA',
|
|
|
|
'fold_f=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('folded flop/4th')
|
2008-08-19 00:53:25 +02:00
|
|
|
)
|
|
|
|
|
2008-08-20 21:29:08 +02:00
|
|
|
def steal(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Steal %."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['steal'])/float(stat_dict[player]['steal_opp'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'st=%3.1f%%' % (100.0*stat),
|
|
|
|
'steal=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['steal'], stat_dict[player]['steal_opp']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% steal attempted')
|
2008-08-20 21:29:08 +02:00
|
|
|
)
|
|
|
|
except:
|
2008-12-22 00:42:21 +01:00
|
|
|
return (stat, 'NA', 'st=NA', 'steal=NA', '(0/0)', '% steal attempted')
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2011-02-12 14:11:41 +01:00
|
|
|
def s_steal(stat_dict, player):
|
|
|
|
""" Success Steal %."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['suc_st'])/float(stat_dict[player]['steal'])
|
|
|
|
return (stat,
|
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
's_st=%3.1f%%' % (100.0*stat),
|
|
|
|
's_steal=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['suc_st'], stat_dict[player]['steal']),
|
|
|
|
_('% success steal')
|
|
|
|
)
|
|
|
|
except:
|
|
|
|
return (stat, 'NA', 'st=NA', 's_steal=NA', '(0/0)', '% success steal')
|
|
|
|
|
2008-08-20 21:29:08 +02:00
|
|
|
def f_SB_steal(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Folded SB to steal."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2009-04-27 22:29:02 +02:00
|
|
|
stat = float(stat_dict[player]['sbnotdef'])/float(stat_dict[player]['sbstolen'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'fSB=%3.1f%%' % (100.0*stat),
|
|
|
|
'fSB_s=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['sbnotdef'], stat_dict[player]['sbstolen']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% folded SB to steal'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2008-12-02 16:14:38 +01:00
|
|
|
'NA',
|
|
|
|
'fSB=NA',
|
|
|
|
'fSB_s=NA',
|
2008-12-22 00:42:21 +01:00
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% folded SB to steal'))
|
2008-08-19 00:53:25 +02:00
|
|
|
|
2008-08-20 21:29:08 +02:00
|
|
|
def f_BB_steal(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Folded BB to steal."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2009-04-27 22:29:02 +02:00
|
|
|
stat = float(stat_dict[player]['bbnotdef'])/float(stat_dict[player]['bbstolen'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'fBB=%3.1f%%' % (100.0*stat),
|
|
|
|
'fBB_s=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['bbnotdef'], stat_dict[player]['bbstolen']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% folded BB to steal'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2008-12-02 16:14:38 +01:00
|
|
|
'NA',
|
|
|
|
'fBB=NA',
|
|
|
|
'fBB_s=NA',
|
2008-12-22 00:42:21 +01:00
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% folded BB to steal'))
|
2010-07-17 00:15:27 +02:00
|
|
|
|
|
|
|
def f_steal(stat_dict, player):
|
|
|
|
""" Folded blind to steal."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
folded_blind = stat_dict[player]['sbnotdef'] + stat_dict[player]['bbnotdef']
|
|
|
|
blind_stolen = stat_dict[player]['sbstolen'] + stat_dict[player]['bbstolen']
|
|
|
|
|
|
|
|
stat = float(folded_blind)/float(blind_stolen)
|
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'fB=%3.1f%%' % (100.0*stat),
|
|
|
|
'fB_s=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (folded_blind, blind_stolen),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% folded blind to steal'))
|
2010-07-17 00:15:27 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
|
|
|
'NA',
|
|
|
|
'fB=NA',
|
|
|
|
'fB_s=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% folded blind to steal'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def three_B(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Three bet preflop/3rd."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2011-02-08 23:02:16 +01:00
|
|
|
stat = float(stat_dict[player]['tb_0'])/float(stat_dict[player]['tb_opp_0'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'3B=%3.1f%%' % (100.0*stat),
|
|
|
|
'3B_pf=%3.1f%%' % (100.0*stat),
|
2011-02-08 23:02:16 +01:00
|
|
|
'(%d/%d)' % (stat_dict[player]['tb_0'], stat_dict[player]['tb_opp_0']),
|
|
|
|
_('% 3 Bet preflop/3rd'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'3B=NA',
|
|
|
|
'3B_pf=NA',
|
|
|
|
'(0/0)',
|
2011-02-03 05:04:12 +01:00
|
|
|
_('% 3 Bet preflop/3rd'))
|
|
|
|
|
|
|
|
def four_B(stat_dict, player):
|
|
|
|
""" Four bet preflop/4rd."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
2011-02-08 23:02:16 +01:00
|
|
|
stat = float(stat_dict[player]['fb_0'])/float(stat_dict[player]['fb_opp_0'])
|
2011-02-03 05:04:12 +01:00
|
|
|
return (stat,
|
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'4B=%3.1f%%' % (100.0*stat),
|
2011-02-12 14:11:41 +01:00
|
|
|
'4B=%3.1f%%' % (100.0*stat),
|
2011-02-08 23:02:16 +01:00
|
|
|
'(%d/%d)' % (stat_dict[player]['fb_0'], stat_dict[player]['fb_opp_0']),
|
2011-02-03 05:04:12 +01:00
|
|
|
_('% 4 Bet preflop/4rd'))
|
|
|
|
except:
|
|
|
|
return (stat,
|
|
|
|
'NA',
|
|
|
|
'4B=NA',
|
2011-02-12 14:11:41 +01:00
|
|
|
'4B=NA',
|
2011-02-03 05:04:12 +01:00
|
|
|
'(0/0)',
|
|
|
|
_('% 4 Bet preflop/4rd'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2011-02-12 14:11:41 +01:00
|
|
|
def cfour_B(stat_dict, player):
|
|
|
|
""" Cold Four bet preflop/4rd."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['cfb_0'])/float(stat_dict[player]['cfb_opp_0'])
|
|
|
|
return (stat,
|
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'C4B=%3.1f%%' % (100.0*stat),
|
|
|
|
'C4B_pf=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['cfb_0'], stat_dict[player]['cfb_opp_0']),
|
|
|
|
_('% Cold 4 Bet preflop/4rd'))
|
|
|
|
except:
|
|
|
|
return (stat,
|
|
|
|
'NA',
|
|
|
|
'C4B=NA',
|
|
|
|
'C4B_pf=NA',
|
|
|
|
'(0/0)',
|
|
|
|
_('% Cold 4 Bet preflop/4rd'))
|
|
|
|
|
|
|
|
def squeeze(stat_dict, player):
|
|
|
|
""" Squeeze bet preflop."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float(stat_dict[player]['sqz_0'])/float(stat_dict[player]['sqz_opp_0'])
|
|
|
|
return (stat,
|
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'SQZ=%3.1f%%' % (100.0*stat),
|
|
|
|
'SQZ_pf=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['sqz_0'], stat_dict[player]['sqz_opp_0']),
|
|
|
|
_('% Squeeze preflop'))
|
|
|
|
except:
|
|
|
|
return (stat,
|
|
|
|
'NA',
|
|
|
|
'SQZ=NA',
|
|
|
|
'SQZ_pf=NA',
|
|
|
|
'(0/0)',
|
|
|
|
_('% Squeeze preflop'))
|
|
|
|
|
|
|
|
|
2011-02-02 03:35:38 +01:00
|
|
|
def f_3bet(stat_dict, player):
|
|
|
|
""" Fold to 3bet preflop. """
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
2011-02-03 05:04:12 +01:00
|
|
|
stat = float(stat_dict[player]['f3b_0'])/float(stat_dict[player]['f3b_opp_0'])
|
2011-02-02 03:35:38 +01:00
|
|
|
return (stat,
|
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'F3B=%3.1f%%' % (100.0*stat),
|
|
|
|
'F3B_pf=%3.1f%%' % (100.0*stat),
|
2011-02-03 05:04:12 +01:00
|
|
|
'(%d/%d)' % (stat_dict[player]['f3b_0'], stat_dict[player]['f3b_opp_0']),
|
2011-02-02 03:35:38 +01:00
|
|
|
_('% Fold to 3 Bet preflop'))
|
|
|
|
except:
|
|
|
|
return (stat,
|
|
|
|
'NA',
|
|
|
|
'F3B=NA',
|
|
|
|
'F3B_pf=NA',
|
|
|
|
'(0/0)',
|
|
|
|
_('% Fold to 3 Bet preflop'))
|
|
|
|
|
|
|
|
def f_4bet(stat_dict, player):
|
|
|
|
""" Fold to 4bet preflop. """
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
2011-02-03 05:04:12 +01:00
|
|
|
stat = float(stat_dict[player]['f4b_0'])/float(stat_dict[player]['f4b_opp_0'])
|
2011-02-02 03:35:38 +01:00
|
|
|
return (stat,
|
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'F4B=%3.1f%%' % (100.0*stat),
|
|
|
|
'F4B_pf=%3.1f%%' % (100.0*stat),
|
2011-02-03 05:04:12 +01:00
|
|
|
'(%d/%d)' % (stat_dict[player]['f4b_0'], stat_dict[player]['f4b_opp_0']),
|
2011-02-02 03:35:38 +01:00
|
|
|
_('% Fold to 4 Bet preflop'))
|
|
|
|
except:
|
|
|
|
return (stat,
|
|
|
|
'NA',
|
|
|
|
'F4B=NA',
|
|
|
|
'F4B_pf=NA',
|
|
|
|
'(0/0)',
|
|
|
|
_('% Fold to 4 Bet preflop'))
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-08-20 21:29:08 +02:00
|
|
|
def WMsF(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Won $ when saw flop/4th."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['w_w_s_1'])/float(stat_dict[player]['saw_1'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'wf=%3.1f%%' % (100.0*stat),
|
|
|
|
'w_w_f=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['w_w_s_1'], stat_dict[player]['saw_f']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% won$/saw flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'wf=NA',
|
|
|
|
'w_w_f=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% won$/saw flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def a_freq1(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Flop/4th aggression frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['aggr_1'])/float(stat_dict[player]['saw_f'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'a1=%3.1f%%' % (100.0*stat),
|
|
|
|
'a_fq_1=%3.1f%%' % (100.0*stat),
|
2008-08-20 21:29:08 +02:00
|
|
|
'(%d/%d)' % (stat_dict[player]['aggr_1'], stat_dict[player]['saw_f']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'a1=NA',
|
|
|
|
'a_fq_1=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def a_freq2(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Turn/5th aggression frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['aggr_2'])/float(stat_dict[player]['saw_2'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'a2=%3.1f%%' % (100.0*stat),
|
|
|
|
'a_fq_2=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['aggr_2'], stat_dict[player]['saw_2']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq turn/5th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'a2=NA',
|
|
|
|
'a_fq_2=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq turn/5th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def a_freq3(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" River/6th aggression frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['aggr_3'])/float(stat_dict[player]['saw_3'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'a3=%3.1f%%' % (100.0*stat),
|
|
|
|
'a_fq_3=%3.1f%%' % (100.0*stat),
|
2008-11-06 00:14:46 +01:00
|
|
|
'(%d/%d)' % (stat_dict[player]['aggr_3'], stat_dict[player]['saw_3']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq river/6th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'a3=NA',
|
|
|
|
'a_fq_3=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq river/6th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def a_freq4(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" 7th street aggression frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['aggr_4'])/float(stat_dict[player]['saw_4'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'a4=%3.1f%%' % (100.0*stat),
|
|
|
|
'a_fq_4=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['aggr_4'], stat_dict[player]['saw_4']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq 7th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'a4=NA',
|
|
|
|
'a_fq_4=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq 7th'))
|
2008-12-02 01:15:50 +01:00
|
|
|
|
|
|
|
def a_freq_123(stat_dict, player):
|
|
|
|
""" Post-Flop aggression frequency."""
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
stat = float( stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3']
|
|
|
|
) / float( stat_dict[player]['saw_1'] + stat_dict[player]['saw_2'] + stat_dict[player]['saw_3']);
|
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'afq=%3.1f%%' % (100.0*stat),
|
|
|
|
'postf_aggfq=%3.1f%%' % (100.0*stat),
|
2008-12-02 01:15:50 +01:00
|
|
|
'(%d/%d)' % ( stat_dict[player]['aggr_1']
|
|
|
|
+ stat_dict[player]['aggr_2']
|
|
|
|
+ stat_dict[player]['aggr_3']
|
|
|
|
, stat_dict[player]['saw_1']
|
|
|
|
+ stat_dict[player]['saw_2']
|
|
|
|
+ stat_dict[player]['saw_3']
|
|
|
|
),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Post-Flop Aggression Freq'))
|
2008-12-02 01:15:50 +01:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'a3=NA',
|
|
|
|
'a_fq_3=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Post-Flop Aggression Freq'))
|
2010-06-09 20:28:15 +02:00
|
|
|
|
|
|
|
def agg_freq(stat_dict, player):
|
|
|
|
""" Post-Flop aggression frequency."""
|
|
|
|
""" Aggression frequency % = (times bet or raised post-flop) * 100 / (times bet, raised, called, or folded post-flop) """
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
""" Agression on the flop and all streets """
|
|
|
|
bet_raise = stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3'] + stat_dict[player]['aggr_4']
|
|
|
|
""" number post flop streets seen, this must be number of post-flop calls !! """
|
2010-06-20 09:58:34 +02:00
|
|
|
post_call = stat_dict[player]['call_1'] + stat_dict[player]['call_2'] + stat_dict[player]['call_3'] + stat_dict[player]['call_4']
|
2010-06-09 20:28:15 +02:00
|
|
|
""" Number of post flop folds this info is not yet in the database """
|
2010-06-20 09:58:34 +02:00
|
|
|
post_fold = stat_dict[player]['f_freq_1'] + stat_dict[player]['f_freq_2'] + stat_dict[player]['f_freq_3'] + stat_dict[player]['f_freq_4']
|
2010-06-09 20:28:15 +02:00
|
|
|
|
2010-06-10 21:00:30 +02:00
|
|
|
stat = float (bet_raise) / float(post_call + post_fold + bet_raise)
|
2010-06-09 20:28:15 +02:00
|
|
|
|
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'afr=%3.1f%%' % (100.0*stat),
|
|
|
|
'agg_fr=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (bet_raise, (post_call + post_fold + bet_raise)),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq'))
|
2010-06-09 20:28:15 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'af=NA',
|
|
|
|
'agg_f=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Freq'))
|
2010-06-09 20:28:15 +02:00
|
|
|
|
|
|
|
def agg_fact(stat_dict, player):
|
|
|
|
""" Post-Flop aggression frequency."""
|
|
|
|
""" Aggression factor = (times bet or raised post-flop) / (times called post-flop) """
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
2010-06-11 20:33:08 +02:00
|
|
|
bet_raise = stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3'] + stat_dict[player]['aggr_4']
|
|
|
|
post_call = stat_dict[player]['call_1'] + stat_dict[player]['call_2'] + stat_dict[player]['call_3'] + stat_dict[player]['call_4']
|
2010-06-09 20:28:15 +02:00
|
|
|
|
2010-06-13 12:16:26 +02:00
|
|
|
if post_call > 0:
|
|
|
|
stat = float (bet_raise) / float(post_call)
|
|
|
|
else:
|
2010-06-20 09:58:34 +02:00
|
|
|
stat = float (bet_raise)
|
2010-06-09 20:28:15 +02:00
|
|
|
return (stat,
|
2010-06-11 20:33:08 +02:00
|
|
|
'%2.2f' % (stat) ,
|
|
|
|
'afa=%2.2f' % (stat) ,
|
|
|
|
'agg_fa=%2.2f' % (stat) ,
|
2010-06-10 21:00:30 +02:00
|
|
|
'(%d/%d)' % (bet_raise, post_call),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Factor'))
|
2010-06-09 20:28:15 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'afa=NA',
|
|
|
|
'agg_fa=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('Aggression Factor'))
|
2010-06-09 20:28:15 +02:00
|
|
|
|
|
|
|
def cbet(stat_dict, player):
|
|
|
|
|
2010-08-02 23:50:19 +02:00
|
|
|
""" Total continuation bet."""
|
|
|
|
""" Continuation bet % = (times made a continuation bet on any street) * 100 / (number of opportunities to make a continuation bet on any street) """
|
2010-06-09 20:28:15 +02:00
|
|
|
|
|
|
|
stat = 0.0
|
|
|
|
try:
|
|
|
|
cbets = stat_dict[player]['cb_1']+stat_dict[player]['cb_2']+stat_dict[player]['cb_3']+stat_dict[player]['cb_4']
|
|
|
|
oppt = stat_dict[player]['cb_opp_1']+stat_dict[player]['cb_opp_2']+stat_dict[player]['cb_opp_3']+stat_dict[player]['cb_opp_4']
|
|
|
|
stat = float(cbets)/float(oppt)
|
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'cbet=%3.1f%%' % (100.0*stat),
|
|
|
|
'cbet=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (cbets, oppt),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet '))
|
2010-06-09 20:28:15 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'cbet=NA',
|
|
|
|
'cbet=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet '))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def cb1(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Flop continuation bet."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2009-04-27 22:29:02 +02:00
|
|
|
stat = float(stat_dict[player]['cb_1'])/float(stat_dict[player]['cb_opp_1'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'cb1=%3.1f%%' % (100.0*stat),
|
|
|
|
'cb_1=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['cb_1'], stat_dict[player]['cb_opp_1']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'cb1=NA',
|
|
|
|
'cb_1=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def cb2(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Turn continuation bet."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2009-04-27 22:29:02 +02:00
|
|
|
stat = float(stat_dict[player]['cb_2'])/float(stat_dict[player]['cb_opp_2'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'cb2=%3.1f%%' % (100.0*stat),
|
|
|
|
'cb_2=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['cb_2'], stat_dict[player]['cb_opp_2']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet turn/5th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'cb2=NA',
|
|
|
|
'cb_2=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet turn/5th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def cb3(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" River continuation bet."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2009-04-27 22:29:02 +02:00
|
|
|
stat = float(stat_dict[player]['cb_3'])/float(stat_dict[player]['cb_opp_3'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'cb3=%3.1f%%' % (100.0*stat),
|
|
|
|
'cb_3=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['cb_3'], stat_dict[player]['cb_opp_3']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet river/6th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'cb3=NA',
|
|
|
|
'cb_3=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet river/6th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def cb4(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" 7th street continuation bet."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2009-04-27 22:29:02 +02:00
|
|
|
stat = float(stat_dict[player]['cb_4'])/float(stat_dict[player]['cb_opp_4'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'cb4=%3.1f%%' % (100.0*stat),
|
|
|
|
'cb_4=%3.1f%%' % (100.0*stat),
|
2009-04-27 22:29:02 +02:00
|
|
|
'(%d/%d)' % (stat_dict[player]['cb_4'], stat_dict[player]['cb_opp_4']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet 7th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'cb4=NA',
|
|
|
|
'cb_4=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% continuation bet 7th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def ffreq1(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Flop/4th fold frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['f_freq_1'])/float(stat_dict[player]['was_raised_1'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'ff1=%3.1f%%' % (100.0*stat),
|
|
|
|
'ff_1=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['f_freq_1'], stat_dict[player]['was_raised_1']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-05 10:07:37 +02:00
|
|
|
'NA',
|
|
|
|
'ff1=NA',
|
|
|
|
'ff_1=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency flop/4th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def ffreq2(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" Turn/5th fold frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['f_freq_2'])/float(stat_dict[player]['was_raised_2'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'ff2=%3.1f%%' % (100.0*stat),
|
|
|
|
'ff_2=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['f_freq_2'], stat_dict[player]['was_raised_2']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency turn/5th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'ff2=NA',
|
|
|
|
'ff_2=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency turn/5th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def ffreq3(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" River/6th fold frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['f_freq_3'])/float(stat_dict[player]['was_raised_3'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'ff3=%3.1f%%' % (100.0*stat),
|
|
|
|
'ff_3=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['f_freq_3'], stat_dict[player]['was_raised_3']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency river/6th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'ff3=NA',
|
|
|
|
'ff_3=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency river/6th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2009-07-24 00:15:02 +02:00
|
|
|
def ffreq4(stat_dict, player):
|
2008-09-15 22:31:55 +02:00
|
|
|
""" 7th fold frequency."""
|
2008-08-20 21:29:08 +02:00
|
|
|
stat = 0.0
|
|
|
|
try:
|
2008-08-22 22:10:32 +02:00
|
|
|
stat = float(stat_dict[player]['f_freq_4'])/float(stat_dict[player]['was_raised_4'])
|
2008-08-20 21:29:08 +02:00
|
|
|
return (stat,
|
2010-08-22 12:09:26 +02:00
|
|
|
'%3.1f' % (100.0*stat),
|
|
|
|
'ff4=%3.1f%%' % (100.0*stat),
|
|
|
|
'ff_4=%3.1f%%' % (100.0*stat),
|
|
|
|
'(%d/%d)' % (stat_dict[player]['f_freq_4'], stat_dict[player]['was_raised_4']),
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency 7th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
except:
|
|
|
|
return (stat,
|
2010-08-22 12:57:01 +02:00
|
|
|
'NA',
|
|
|
|
'ff4=NA',
|
|
|
|
'ff_4=NA',
|
|
|
|
'(0/0)',
|
2010-08-17 19:50:22 +02:00
|
|
|
_('% fold frequency 7th'))
|
2008-08-20 21:29:08 +02:00
|
|
|
|
|
|
|
if __name__== "__main__":
|
2010-08-04 23:23:28 +02:00
|
|
|
statlist = dir()
|
|
|
|
misslist = [ "Configuration", "Database", "Charset", "codecs", "encoder"
|
|
|
|
, "do_stat", "do_tip", "GInitiallyUnowned", "gtk", "pygtk"
|
2010-08-22 12:09:26 +02:00
|
|
|
, "re", "re_Places"
|
2010-08-04 23:23:28 +02:00
|
|
|
]
|
|
|
|
statlist = [ x for x in statlist if x not in dir(sys) ]
|
|
|
|
statlist = [ x for x in statlist if x not in dir(codecs) ]
|
|
|
|
statlist = [ x for x in statlist if x not in misslist ]
|
|
|
|
#print "statlist is", statlist
|
|
|
|
|
2008-08-19 00:53:25 +02:00
|
|
|
c = Configuration.Config()
|
2010-07-16 21:33:36 +02:00
|
|
|
#TODO: restore the below code. somehow it creates a version 119 DB but commenting this out makes it print a stat list
|
2010-08-04 23:23:28 +02:00
|
|
|
db_connection = Database.Database(c)
|
|
|
|
h = db_connection.get_last_hand()
|
|
|
|
stat_dict = db_connection.get_stats_from_hand(h, "ring")
|
2008-08-19 00:53:25 +02:00
|
|
|
|
2010-08-04 23:23:28 +02:00
|
|
|
for player in stat_dict.keys():
|
2010-08-17 19:50:22 +02:00
|
|
|
print (_("Example stats, player = %s hand = %s:") % (player, h))
|
2010-08-04 23:23:28 +02:00
|
|
|
for attr in statlist:
|
|
|
|
print " ", do_stat(stat_dict, player=player, stat=attr)
|
|
|
|
break
|
2010-07-16 21:33:36 +02:00
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'vpip')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'pfr')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'wtsd')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'profit100')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'saw_f')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'n')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'fold_f')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'wmsd')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'steal')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_SB_steal')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_BB_steal')
|
2010-07-17 00:15:27 +02:00
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_steal')
|
2010-07-16 21:33:36 +02:00
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'three_B')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'WMsF')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq1')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq2')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq3')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq4')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_123')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb1')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb2')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb3')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb4')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq1')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq2')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq3')
|
|
|
|
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq4')
|
|
|
|
#print "\n"
|
2008-08-20 21:29:08 +02:00
|
|
|
|
2010-08-17 19:50:22 +02:00
|
|
|
print _("\n\nLegal stats:")
|
|
|
|
print _("(add _0 to name to display with 0 decimal places, _1 to display with 1, etc)\n")
|
2010-08-04 23:23:28 +02:00
|
|
|
for attr in statlist:
|
2008-12-02 01:15:50 +01:00
|
|
|
print "%-14s %s" % (attr, eval("%s.__doc__" % (attr)))
|
2008-09-15 22:31:55 +02:00
|
|
|
# print " <pu_stat pu_stat_name = \"%s\"> </pu_stat>" % (attr)
|
2009-10-24 13:41:51 +02:00
|
|
|
print
|
2008-09-15 22:31:55 +02:00
|
|
|
|
2010-07-16 21:33:36 +02:00
|
|
|
#db_connection.close_connection
|
2008-08-19 00:53:25 +02:00
|
|
|
|