diff options
-rw-r--r-- | oldbot.py | 1 | ||||
-rwxr-xr-x | pyglet_snake.py | 18 | ||||
-rw-r--r-- | snake.py | 1 |
3 files changed, 12 insertions, 8 deletions
@@ -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() @@ -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, \ |