1. Peter Ward
  2. SnakeGame

Commits

Peter Ward  committed 9c5f299

enable user-defined bot colours

  • Participants
  • Parent commits bb016e2
  • Branches default

Comments (0)

Files changed (1)

File snakegame/engine.py

View file
             x, y = self.get_random_position()
             self.board[y][x] = common.APPLE
 
-    def add_bot(self, bot, team=None):
+    def add_bot(self, bot, team=None, colour=None):
         """
         A bot is a callable object, with this method signature:
             def bot_callable(
         letter = self.letters.pop()
 
         name = bot.__name__
-        colour = hash_colour(name)
+        if colour is None:
+            colour = hash_colour(name)
 
         position = self.replace_random(common.EMPTY, letter.upper())
         if position is None: