From d4ce19940276471c8f536d3537e939d5f42a1d1f Mon Sep 17 00:00:00 2001 From: kangalioo Date: Tue, 12 Nov 2019 19:31:49 +0100 Subject: [PATCH] Replace manual combo track-keeping with xml --- data_generators.py | 22 +++++++++++++++++----- replays_analysis.py | 6 ------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/data_generators.py b/data_generators.py index 00ffc2a..d548b71 100644 --- a/data_generators.py +++ b/data_generators.py @@ -260,7 +260,8 @@ def gen_session_plays(xml): return (list(nums_sessions_with_x_plays.keys()), list(nums_sessions_with_x_plays.values())) -def gen_cb_probability(xml, analysis): +# Currently broken +"""def gen_cb_probability(xml, analysis): # {combo length: (base number, cb number) base, cbs = analysis.combo_occurences, analysis.cbs_on_combo_len @@ -268,7 +269,7 @@ def gen_cb_probability(xml, analysis): max_combo = base.index(0, 1) result = {i: int(cbs[i]/base[i]) for i in range(max_combo)[:10] if base[i] >= 0} x_list = range(max_combo) - return (x_list, [cbs[i]/base[i] for i in x_list]) + return (x_list, [cbs[i]/base[i] for i in x_list])""" def gen_plays_per_week(xml): datetimes = [parsedate(s.findtext("DateTime")) for s in iter_scores(xml)] @@ -339,6 +340,18 @@ def gen_session_rating_improvement(xml): return ((datetimes, lengths, sizes), ids) +# Returns tuple of `(max_combo_chart_element, max_combo_int)` +def find_longest_combo(xml): + max_combo_chart = None + max_combo = 0 + for chart in xml.iter("Chart"): + for score in iter_scores(chart): + combo = int(score.findtext("MaxCombo")) + if combo > max_combo: + max_combo = combo + max_combo_chart = chart + return max_combo_chart, max_combo + # Returns dict with pack names as keys and the respective "pack liking" # as value. The liking value is currently simply the amount of recent # plays in the pack. Recent = in the last `timespan_months` months @@ -419,16 +432,15 @@ def gen_text_general_info(xml, r): if r: # If ReplaysAnalysis is avilable total_notes_string = util.abbreviate(r.total_notes, min_precision=3) - chart = r.longest_combo[1] + chart, combo = find_longest_combo(xml) long_combo_chart = f'"{chart.get("Pack")} -> "{chart.get("Song")}"' - long_combo_str = f"{r.longest_combo[0]} on {long_combo_chart}" + long_combo_str = f"{combo} on {long_combo_chart}" chart = r.longest_mcombo[1] long_mcombo_chart = f'"{chart.get("Pack")} -> "{chart.get("Song")}"' long_mcombo_str = f"{r.longest_mcombo[0]} on {long_mcombo_chart}" else: total_notes_string = "[please load replay data]" - long_combo_str = "[please load replay data]" long_mcombo_str = "[please load replay data]" scores = list(iter_scores(xml)) diff --git a/replays_analysis.py b/replays_analysis.py index 4f73e94..b10698b 100644 --- a/replays_analysis.py +++ b/replays_analysis.py @@ -15,9 +15,6 @@ class ReplaysAnalysis: longest_combo = [0, None] # Combo variables are lists of `[combo length, chart]` longest_mcombo = [0, None] num_near_hits = 0 - - combo_occurences = [0] * 10000 - cbs_on_combo_len = [0] * 10000 # This function is responsible for replay analysis. Every chart that # uses replay data uses the data generated from this function. @@ -40,7 +37,6 @@ def do_combo_end(combo, longest): if replay is None: continue - r.combo_occurences[0] += 1 # I have no idea previous_time = 0 num_total = 0 num_manipulated = 0 @@ -65,12 +61,10 @@ def do_combo_end(combo, longest): if abs(offset) > 0.09: do_combo_end(combo, r.longest_combo) - r.cbs_on_combo_len[combo] += 1 combo = 0 if column < 4: r.cbs_per_column[column] += 1 else: combo += 1 - r.combo_occurences[combo] += 1 if abs(offset) > 0.0225: do_combo_end(mcombo, r.longest_mcombo)