Update
This commit is contained in:
15
main.py
15
main.py
@ -70,16 +70,17 @@ def add_dock(world, home):
|
|||||||
# find the closest bit of water to the house?
|
# find the closest bit of water to the house?
|
||||||
# find the biggest body of water
|
# find the biggest body of water
|
||||||
|
|
||||||
|
def distribution(world):
|
||||||
def percentage_of_land(world):
|
|
||||||
total = world_w * world_h
|
total = world_w * world_h
|
||||||
above_land = 0
|
above_water = 0
|
||||||
|
|
||||||
for y in range(world_h):
|
for y in range(world_h):
|
||||||
for x in range(world_w):
|
for x in range(world_w):
|
||||||
cell = world[y][x]
|
cell = world[y][x]
|
||||||
if cell > water:
|
if cell > water:
|
||||||
above_land = above_land + 1
|
above_water = above_water + 1
|
||||||
return above_land / total
|
|
||||||
|
return above_water / total
|
||||||
|
|
||||||
def print_map(world, home):
|
def print_map(world, home):
|
||||||
for y in range(world_h):
|
for y in range(world_h):
|
||||||
@ -103,8 +104,10 @@ def print_map(world, home):
|
|||||||
|
|
||||||
world = generate_world(seed)
|
world = generate_world(seed)
|
||||||
i = 1
|
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)
|
world = generate_world(seed + i)
|
||||||
|
land_percentage = distribution(world)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
print(str(i - 1) + " seed iterations")
|
print(str(i - 1) + " seed iterations")
|
||||||
|
Reference in New Issue
Block a user