changeset 238:1a7097c0fc8f

Try harder to have 10 chickens at the start
author Neil Muller <drnlmuller@gmail.com>
date Sat, 05 Sep 2009 09:54:47 +0000
parents 4a87bfa5cc63
children 8224d1ac99c7
files gamelib/gameboard.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gameboard.py	Sat Sep 05 09:48:48 2009 +0000
+++ b/gamelib/gameboard.py	Sat Sep 05 09:54:47 2009 +0000
@@ -778,13 +778,17 @@
         """Add some random chickens to start the game"""
         x, y = 0, 0
         width, height = self.tv.size
+        tries = 0
         while len(self.chickens) < 10:
             if x < width:
                 tile = self.tv.get((x, y))
             else:
                 y += 1
                 if y >= height:
-                    break
+                    y = 0
+                    tries += 1
+                    if tries > 3:
+                        break # Things have gone wierd
                 x = 0
                 continue
             # See if we place a chicken