From 855bdb25b92d36a5aa3b4430a9ef9d6956be8622 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Fri, 2 Oct 2009 14:47:31 +1000 Subject: Commit. --- oldbot.py | 1 + pyglet_snake.py | 18 ++++++++++-------- snake.py | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/oldbot.py b/oldbot.py index e27ed39..3bd3038 100644 --- a/oldbot.py +++ b/oldbot.py @@ -3,6 +3,7 @@ import subprocess class BotWrapper(object): def __init__(self, process): self.process = process + self.__name__ = process def __call__(self, board, (x, y)): height = len(board) diff --git a/pyglet_snake.py b/pyglet_snake.py index 10e4a3d..79ae047 100755 --- a/pyglet_snake.py +++ b/pyglet_snake.py @@ -108,14 +108,16 @@ class PygletSnakeEngine(SnakeEngine, pyglet.window.Window): pyglet.app.run() if __name__ == '__main__': - from bots import * + from bots import random_bounds_bot, random_square_bot from oldbot import BotWrapper - - game = PygletSnakeEngine(25, 25, 50) - game.add_bot(right_bot) - game.add_bot(random_bot) - game.add_bot(random_bounds_bot) - game.add_bot(random_square_bot) - game.add_bot(BotWrapper('oldbots/peter.py')) + from peter_bot import peter_bot + + game = PygletSnakeEngine(25, 25, 50, results=True) +# game.add_bot(random_bounds_bot) +# game.add_bot(random_square_bot) + for i in xrange(0): + game.add_bot(BotWrapper('oldbots/peter.py')) + for i in xrange(1): + game.add_bot(peter_bot) game.run() diff --git a/snake.py b/snake.py index 1edcc49..022f897 100644 --- a/snake.py +++ b/snake.py @@ -92,6 +92,7 @@ class SnakeEngine(object): else: apple_score = len(bot[2]) self.results.write('%s,%s,%s\n' % (name, apple_score, time_score)) + self.results.flush() def update_snakes(self, directions_id=id(directions)): assert id(directions) == directions_id, \ -- cgit v1.2.3