summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oldbot.py1
-rwxr-xr-xpyglet_snake.py18
-rw-r--r--snake.py1
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, \