summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpygame_snake.py14
-rw-r--r--snake.py3
2 files changed, 11 insertions, 6 deletions
diff --git a/pygame_snake.py b/pygame_snake.py
index c2ac323..64faf9b 100755
--- a/pygame_snake.py
+++ b/pygame_snake.py
@@ -136,19 +136,25 @@ class PygameSnakeEngine(SnakeEngine):
if running:
time.sleep(2)
- # Early window close, late process cleanup.
- pygame.display.quit()
-
if __name__ == '__main__':
from bots import *
from oldbot import BotWrapper
+ ROWS = 25
+ COLUMNS = 25
+ APPLES = 50
+ game = PygameSnakeEngine(ROWS, COLUMNS, APPLES, results=True)
+
while True:
- game = PygameSnakeEngine(25, 25, 50, results=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('oldbots/peter.py'))
game.run()
+ game.new_game(ROWS, COLUMNS, APPLES)
+
+ # Early window close, late process cleanup.
+ pygame.display.quit()
+
diff --git a/snake.py b/snake.py
index 3a286e7..ba25814 100644
--- a/snake.py
+++ b/snake.py
@@ -20,8 +20,6 @@ class SnakeEngine(object):
self.letters = list(string.lowercase)
self.letters.reverse()
- self.game_id = random.randint(0, sys.maxint)
-
self.bots = {}
self.results = None
if results:
@@ -43,6 +41,7 @@ class SnakeEngine(object):
def new_game(self, rows, columns, n_apples):
self.start_time = time.time()
+ self.game_id = random.randint(0, sys.maxint)
self.rows = rows
self.columns = columns