diff options
author | Peter Ward <peteraward@gmail.com> | 2009-10-29 21:12:18 +1100 |
---|---|---|
committer | Peter Ward <peteraward@gmail.com> | 2009-10-29 21:12:18 +1100 |
commit | 62527ef65ec78124f97426ba1e7f44fafe1be134 (patch) | |
tree | 53e2651ac49ca127a5f6217c6bf0411b23618584 | |
parent | 9d65a3fdc49858895dcefecd7b53534c297a25c4 (diff) |
Record simulation time instead of real time.
-rw-r--r-- | snake.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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: |