Mercurial > rinkhals
changeset 323:978efd39a099
Limit maximum numbe of foxes generated
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 21:30:18 +0000 |
parents | f8e9a8851d7d |
children | 305af737c0a8 |
files | gamelib/constants.py gamelib/gameboard.py |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/constants.py Sat Sep 05 19:31:59 2009 +0000 +++ b/gamelib/constants.py Sat Sep 05 21:30:18 2009 +0000 @@ -53,3 +53,6 @@ } TURN_LIMIT = TURN_LIMITS['Two weeks'] + +ABS_MAX_NUM_FOXES = 50 # Limit possible uppoer number of foxes, due to concerns + # about performance, etc.
--- a/gamelib/gameboard.py Sat Sep 05 19:31:59 2009 +0000 +++ b/gamelib/gameboard.py Sat Sep 05 21:30:18 2009 +0000 @@ -322,6 +322,9 @@ self.tv = tiles.FarmVid() self.tv.png_folder_load_tiles('tiles') self.tv.tga_load_level(data.filepath('levels/farm.tga')) + height, width = self.tv.size + # Ensure we don't every try to create more foxes then is sane + self.max_foxes = min(height+width-15, constants.ABS_MAX_NUM_FOXES) self.create_display() self.selected_tool = None @@ -985,7 +988,7 @@ x, y = 0, 0 width, height = self.tv.size min_foxes = (self.days+3)/2 # always more than one fox - new_foxes = random.randint(min_foxes, min_foxes*2) + new_foxes = min(random.randint(min_foxes, min_foxes*2), self.max_foxes) while len(self.foxes) < new_foxes: side = random.randint(0, 3) if side == 0: