diff options
author | Florian Jung <flo@windfisch.org> | 2015-08-11 01:59:26 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-08-11 01:59:26 +0200 |
commit | 9b2078f8db3132754390db4905ac13009046f8bf (patch) | |
tree | 24dd749f004df7be65787ecfd0744743d944dc47 /stats.py | |
parent | 910d17644cd8c0b2e7c6285b27aeb97253be492d (diff) | |
parent | 06ec1ca17d38ebb8b1a901b938f5f812e494e26e (diff) |
Merge branch 'master' of github.com:Windfisch/agario-frickel
Diffstat (limited to 'stats.py')
-rw-r--r-- | stats.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/stats.py b/stats.py new file mode 100644 index 0000000..f850339 --- /dev/null +++ b/stats.py @@ -0,0 +1,36 @@ +import time + +class Stats: + def __init__(self): + self.min_mass = 0 + self.max_mass = 0 + self.current_mass = 0 + + self.mass_history = [] + self.pos_history = [] + self.cell_aggressivity = {} + self.cell_split_frequency = {} + self.cell_defensiveness = {} + + def log_mass(self, mass): + self.mass_history.append((time.time(), mass)) + self.current_mass = mass + if mass > self.max_mass: + self.max_mass = mass + if mass < self.min_mass: + self.min_mass = mass + + def log_pos(self, pos): + self.pos_history.append((time.time(), (pos[0], pos[1]))) + + def update_cell_aggressivity(self, cell, value): + self.cell_aggressivity[cell] = value + + def update_cell_split_frequency(self, cell, value): + self.cell_split_frequency[cell] = value + + def update_cell_defensiveness(self, cell, value): + self.cell_defensiveness[cell] = value + + def get_last_steps(self, list, steps = 10): + return list[-steps:]
\ No newline at end of file |