beaglemage / Fantasy_map_generator

Create RPG/ fantasy maps with Python
Creative Commons Zero v1.0 Universal
4 stars 3 forks source link

index 1000 is out of bounds for axis 0 with size 1000 #1

Open fredzannarbor opened 2 years ago

fredzannarbor commented 2 years ago

Hi,

any idea what's happening here?

I set width to 1000 instead of 4000 to rule out memory issues. I have a modern Mac.

(unity) fred@Freds-MacBook-Pro:~/unity/Fantasy_map_generator/Map generator$ python world_map.py
Heightmap generated
Forests generated
Hills generated
Brick lands generated
Map colors generated
Color borders smoothed
Trees placed
Traceback (most recent call last):
  File "world_map.py", line 1073, in <module>
    colors = place_settlements(hmap, colors)
  File "world_map.py", line 1019, in place_settlements
    while (not ok_for_town(x,y)) or not dist_ok(x,y):
  File "world_map.py", line 936, in ok_for_town
    if hmap[i][j] < Max/7.5 or hmap[i][j] > Max*.5:
IndexError: index 1000 is out of bounds for axis 0 with size 1000
fredzannarbor commented 2 years ago

If I understand the code correctly (big question mark), it looks as if sometimes when the application tries to place a town, this function:

while (not ok_for_town(x,y)) or not dist_ok(x,y):
            x = np.random.randint(im_width-102)+51
            y = np.random.randint(im_width-288)+144

is generating impossible values. Do I need to tweak the generation of x & y to keep it within certain limits?