コード例 #1
0
 def __init__(self, live_event):
     super(LiveMatch, self).__init__()
     self.live_event = live_event
     self.name = None  # sample: 'Federer R. - Nadal R.'
     self.href = None
     self.define_players_tried = False
     self.fill_details_tried = False
     self.is_special = False  # True if source self.name endswith ' (aces)' (betcity)
     self.left_service = None
     self.ingame = None  # sample: ('A', '40')
     self.worked_alerts = []
     self.srvw_stat = (
         None  # obj for players history for serve/receive (matchstat.py)
     )
     self.fst_last_res = None
     self.snd_last_res = None
     self.quad_stat = st.QuadServiceStat()
     self.set_opener_tracker = st.SetOpenerMatchTracker()
     self.kill_timer = None
     self.h2h_direct = None  # 1 dominate of first; -1 dominate of second
     self.decset_ratio_dif = 0.0
     self.decset_bonus_dif = 0.0
     self.hist_fst_srv_win = rl.SizedValue()
     self.hist_snd_srv_win = rl.SizedValue()
     self.hist_fst_rcv_win = rl.SizedValue()
     self.hist_snd_rcv_win = rl.SizedValue()
     self.features = []  # Features obj: fst_fatigue, snd_fatigue
     self.hot_nums = None  # uses for tie point numbering
     self.time = None  # uses in today match
     self.def_plr_seconds = 0.0
     self.check_unknown = False
     # cache values: LEFT or RIGHT if pre-estimated back side, False if reject pre-estimated
     #               None if cache value is absent
     self.cache_dict = defaultdict(lambda: None)
コード例 #2
0
 def avgset(self, isqual):
     """return SizedValue"""
     res_sumator = st.Sumator()
     for rnd in list(self.matches_from_rnd.keys()):
         is_best_of_five = self.best_of_five(rnd)
         if rnd.qualification() is isqual:
             for match in self.matches_from_rnd[rnd]:
                 if match.score is None or match.paired():
                     continue
                 setnum = match.score.sets_count(full=True)
                 if setnum == 0:
                     continue
                 stotals = [
                     min(13, match.score[i][0] + match.score[i][1])
                     for i in range(setnum)
                 ]
                 # skips if winner is very strong dominated:
                 if max(stotals) <= 7:
                     continue  # skip if dominated to zero (or to one) in each set
                 if not isqual:
                     if not is_best_of_five and stotals in ([8, 6], [6, 8]):
                         continue  # skip if dominated 6-2, 6-0
                     if is_best_of_five and stotals in (
                         [8, 6, 6],
                         [6, 8, 6],
                         [6, 6, 8],
                     ):
                         continue  # skip if dominated 6-2, 6-0, 6-0
                 for set_total in stotals:
                     res_sumator.hit(set_total)
     if not res_sumator:
         return rl.SizedValue()
     return rl.SizedValue(value=res_sumator.average(), size=res_sumator.size)
コード例 #3
0
def greater_sized_chance(cntr, front):
    less_count, greater_count = less_greater_counts(cntr, front)
    all_count = less_count + greater_count
    if all_count > 0:
        return rl.SizedValue(float(greater_count) / float(all_count), all_count)
    else:
        return rl.SizedValue()
コード例 #4
0
def sized_avg(cntr):
    """Вернем среднее значение ключей в виде SizedValue"""
    all_count, keys_sum = 0, 0
    if cntr is not None:
        for k, c in cntr.items():
            all_count += c
            keys_sum += k * c
    if all_count > 0:
        return rl.SizedValue(float(keys_sum) / float(all_count), all_count)
    else:
        return rl.SizedValue()
コード例 #5
0
 def plr_sv_feature(name):
     fst_name = f"fst_{name}"
     snd_name = f"snd_{name}"
     if fst_name in dct and snd_name in dct:
         fst_val = rl.SizedValue(*dct[fst_name])
         snd_val = rl.SizedValue(*dct[snd_name])
         self.features.append(
             feature.Feature(name=fst_name, value=fst_val, flip_value=snd_val)
         )
         self.features.append(
             feature.Feature(name=snd_name, value=snd_val, flip_value=fst_val)
         )
コード例 #6
0
 def player_load(prefix: str, player: tennis.Player):
     player.ident = dct.get(prefix + "_player_id")
     player.name = dct.get(prefix + "_player_name")
     player.rating = ratings.Rating(dct.get(prefix + "_player_rating"))
     ymd = dct.get(prefix + "_player_bdate")
     if ymd is not None:
         player.birth_date = datetime.date(ymd[0], ymd[1], ymd[2])
     setattr(
         self,
         "hist_" + prefix + "_srv_win",
         rl.SizedValue(*dct[prefix + "_hist_srv_win"]),
     )
     setattr(
         self,
         "hist_" + prefix + "_rcv_win",
         rl.SizedValue(*dct[prefix + "_hist_rcv_win"]),
     )
コード例 #7
0
def binary_operation(oper_fun, left_dict, right_dict):
    """только для словарей где значения типа SizedValue"""
    result = {}
    for key, left_sval in left_dict.items():
        if key not in right_dict:
            continue
        right_sval = right_dict[key]
        if (left_sval is None or left_sval.value is None or right_sval is None
                or right_sval.value is None):
            continue
        result[key] = rl.SizedValue(
            oper_fun(left_sval.value, right_sval.value),
            max(left_sval.size, right_sval.size),
        )
    return result
コード例 #8
0
def personal_value(sex, subname, player_id):
    """вернем SizedValue. subname тут не нужен (пусть будет 'decided') и
    только для совместимости с модулями mentality1b, tie_importance_stat"""
    if subname != "decided":
        return rl.SizedValue()
    return personal_value.obj.value(sex, subname, player_id)
コード例 #9
0
 def simple_sv_feature(name):
     if name in dct:
         sval_args = dct[name]
         if sval_args is not None:
             sval = rl.SizedValue(*sval_args)
             self.features.append(feature.RigidFeature(name=name, value=sval))