swdata/calc_avg_tr.py
2018-09-23 23:27:01 +08:00

25 lines
634 B
Python

from island.match import Match
from island.matches import Matches
import numpy as np
import csv
def calc(mode):
matches = Matches.from_profile_expr(lambda a: mode in a)
trs = 0
acts = 0
for m in matches.data:
maxr = int(m.query('game', 'created').first()['info']['game_end_at'])
for r in range(1, maxr+1):
rows = m.query('action', 'done').where(lambda x: x['rno'] == r).raw_data
for row in rows:
trs += row['tr']
acts += len(rows)
return trs, acts, trs / acts
if __name__ == '__main__':
print(calc('CLASSIC'))
print(calc('SURVIVE'))