summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconsole_snake.py13
-rwxr-xr-xpygame_snake.py23
-rwxr-xr-xpyglet_snake.py12
3 files changed, 21 insertions, 27 deletions
diff --git a/console_snake.py b/console_snake.py
index 3c40b24..1db5e38 100755
--- a/console_snake.py
+++ b/console_snake.py
@@ -58,15 +58,14 @@ class ConsoleSnakeEngine(SnakeEngine):
self.update_snakes()
def main(*args):
- from bots import *
+ import sys
from processbot import BotWrapper
- game = ConsoleSnakeEngine(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('bots/peter.py'))
+ rows, columns, apples = map(int, sys.argv[1:4])
+ game = ConsoleSnakeEngine(rows, columns, apples)
+ for filename in sys.argv[4:]:
+ bot = BotWrapper(filename)
+ game.add_bot(bot)
game.run()
if __name__ == '__main__':
diff --git a/pygame_snake.py b/pygame_snake.py
index 6ee0eeb..cf07297 100755
--- a/pygame_snake.py
+++ b/pygame_snake.py
@@ -2,12 +2,14 @@
from __future__ import division
+import os
import time
import pygame
pygame.init()
from pygame.locals import *
+from common import *
from snake import SnakeEngine
class Sprites(object):
@@ -137,22 +139,15 @@ class PygameSnakeEngine(SnakeEngine):
time.sleep(2)
if __name__ == '__main__':
- from bots import *
+ import sys
from processbot import BotWrapper
- ROWS = 25
- COLUMNS = 25
- APPLES = 50
- game = PygameSnakeEngine(ROWS, COLUMNS, APPLES, results=True)
-
- while True:
- 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('bots/peter.py'))
- game.run()
- game.new_game(ROWS, COLUMNS, APPLES)
+ rows, columns, apples = map(int, sys.argv[1:4])
+ game = PygameSnakeEngine(rows, columns, apples)
+ for filename in sys.argv[4:]:
+ bot = BotWrapper(filename)
+ game.add_bot(bot)
+ game.run()
# Early window close, late process cleanup.
pygame.display.quit()
diff --git a/pyglet_snake.py b/pyglet_snake.py
index 2ef11a8..3d3cfc1 100755
--- a/pyglet_snake.py
+++ b/pyglet_snake.py
@@ -108,13 +108,13 @@ class PygletSnakeEngine(SnakeEngine, pyglet.window.Window):
pyglet.app.run()
if __name__ == '__main__':
- from bots import random_bounds_bot, random_square_bot
+ import sys
from processbot import BotWrapper
- game = PygletSnakeEngine(25, 25, 50, results=True)
- game.add_bot(random_bounds_bot)
- game.add_bot(random_square_bot)
- for i in xrange(2):
- game.add_bot(BotWrapper('bots/peter.py'))
+ rows, columns, apples = map(int, sys.argv[1:4])
+ game = PygletSnakeEngine(rows, columns, apples)
+ for filename in sys.argv[4:]:
+ bot = BotWrapper(filename)
+ game.add_bot(bot)
game.run()