Skip to content

Commit

Permalink
Replace manual combo track-keeping with xml
Browse files Browse the repository at this point in the history
  • Loading branch information
kangalio committed Nov 12, 2019
1 parent 6abe415 commit d4ce199
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 17 additions & 5 deletions data_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,16 @@ 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
# Find first combo that was never reached (0), starting with combo 1
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)]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 0 additions & 6 deletions replays_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit d4ce199

Please sign in to comment.