From 62527ef65ec78124f97426ba1e7f44fafe1be134 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Thu, 29 Oct 2009 21:12:18 +1100 Subject: Record simulation time instead of real time. --- snake.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'snake.py') diff --git a/snake.py b/snake.py index 95ddd16..0429040 100644 --- a/snake.py +++ b/snake.py @@ -38,7 +38,7 @@ class SnakeEngine(object): return x, y def new_game(self, rows, columns, n_apples): - self.start_time = time.time() + self.game_ticks = 0 self.game_id = random.randint(0, sys.maxint) self.letters = list(string.lowercase) @@ -77,7 +77,7 @@ class SnakeEngine(object): def remove_bot(self, letter): letter = letter.lower() - time_score = time.time() - self.start_time + time_score = self.game_ticks for row in self.board: for x, cell in enumerate(row): @@ -104,6 +104,8 @@ class SnakeEngine(object): assert id(directions) == directions_id, \ "The common.directions dictionary has been modified since startup..." + self.game_ticks += 1 + for letter, (bot, colour, path) in self.bots.items(): board = deepcopy(self.board) try: -- cgit v1.2.3