diff --git a/main.py b/main.py index ef5079f..e79ac15 100644 --- a/main.py +++ b/main.py @@ -70,16 +70,17 @@ def add_dock(world, home): # find the closest bit of water to the house? # find the biggest body of water - -def percentage_of_land(world): +def distribution(world): total = world_w * world_h - above_land = 0 + above_water = 0 + for y in range(world_h): for x in range(world_w): cell = world[y][x] if cell > water: - above_land = above_land + 1 - return above_land / total + above_water = above_water + 1 + + return above_water / total def print_map(world, home): for y in range(world_h): @@ -103,8 +104,10 @@ def print_map(world, home): world = generate_world(seed) i = 1 -while (percentage_of_land(world) < 0.25 or 1 - percentage_of_land(world) < 0.25): +land_percentage = distribution(world) +while (land_percentage < 0.25 or 1 - land_percentage < 0.25): world = generate_world(seed + i) + land_percentage = distribution(world) i = i + 1 print(str(i - 1) + " seed iterations")