diff options
author | Peter Ward <peteraward@gmail.com> | 2012-07-19 20:08:23 +1000 |
---|---|---|
committer | Peter Ward <peteraward@gmail.com> | 2012-07-19 20:08:23 +1000 |
commit | 93ba106c94b7a2d2109842432fed3dbe920c3558 (patch) | |
tree | 921f139e0db186f676cba9c3917489479c51ab88 /stats.py | |
parent | 7fb2789ea7b25a4825ff4b99a832758d3533ded5 (diff) |
Move everything into a package.
Diffstat (limited to 'stats.py')
-rw-r--r-- | stats.py | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/stats.py b/stats.py deleted file mode 100644 index aaacfcf..0000000 --- a/stats.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python - -import sys -from collections import defaultdict -from pngchart import SimpleLineChart -#from pygooglechart import SimpleLineChart -from colour import hash_colour - -WIDTH = 800 -HEIGHT = 300 -RESULTS_FILE = 'results.csv' - -def main(): - data = {} - order = [] - snakes = [] - for line in open(RESULTS_FILE): - game_id, name, length, life = line[:-1].split(',') - game_id = int(game_id) - length = int(length) - life = float(life) - - if name not in data: - snakes.append(name) - data[name] = {} - - if game_id not in order: - order.append(game_id) - - data[name][game_id] = (length, life) - - length_data = [] - time_data = [] - colours = [] - for name in snakes: - time_series = [] - length_series = [] - - for game_id in order: - length, time = data[name].get(game_id, (None, None)) - time_series.append(time) - length_series.append(length) - - colours.append('%02X%02X%02X' % hash_colour(name)) - - time_data.append(time_series) - length_data.append(length_series) - - for filename, data in (('length_chart.png', length_data), - ('time_chart.png', time_data)): - chart = SimpleLineChart(WIDTH, HEIGHT, colours=colours, legend=snakes) - for series in data: - chart.add_data(series) - print 'Updating', filename, '... ', - sys.stdout.flush() - chart.download(filename) - print 'done!' - -if __name__ == '__main__': - main() - |