diff options
author | SpitfireX <timm.weber@me.com> | 2015-08-10 23:32:15 +0200 |
---|---|---|
committer | SpitfireX <timm.weber@me.com> | 2015-08-10 23:32:15 +0200 |
commit | a4219f004cea5392fa5e9356ee9f42bc877c8224 (patch) | |
tree | f0f9f9af0557e6b9fc84bb6fe92fe68f5bddd6ec /stats.py | |
parent | 0b38518540aef32e5420aed456acfa7402200215 (diff) |
Added basic statistics
- added a new stats module
- added mass and position tracking to the current cell logic
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 |