summaryrefslogtreecommitdiff
path: root/snake.py
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2009-10-28 17:40:37 +1100
committerPeter Ward <peteraward@gmail.com>2009-10-28 17:40:37 +1100
commit6941f7192fe34add95bd444491f399408eaac014 (patch)
tree5a53522eb82dfd18fc695c9b8729e5fe6db49f76 /snake.py
parent03d66dd939fea56ce807d58d65475b45e15523d6 (diff)
Added game id to allow stats.
Diffstat (limited to 'snake.py')
-rw-r--r--snake.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/snake.py b/snake.py
index 022f897..3a286e7 100644
--- a/snake.py
+++ b/snake.py
@@ -2,8 +2,10 @@
from __future__ import division
+import sys
import time
import string
+import random
from random import randint
from collections import deque
from copy import deepcopy
@@ -18,6 +20,8 @@ class SnakeEngine(object):
self.letters = list(string.lowercase)
self.letters.reverse()
+ self.game_id = random.randint(0, sys.maxint)
+
self.bots = {}
self.results = None
if results:
@@ -91,7 +95,8 @@ class SnakeEngine(object):
pass
else:
apple_score = len(bot[2])
- self.results.write('%s,%s,%s\n' % (name, apple_score, time_score))
+ self.results.write('%s,%s,%s,%s\n' % \
+ (self.game_id, name, apple_score, time_score))
self.results.flush()
def update_snakes(self, directions_id=id(directions)):