diff --git a/README.md b/README.md index c0c5217..c9886a9 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Run the script `terrain_rivers.py` via command line. You can optionally append t ``` ./terrain_rivers.py 1000 ``` -For a default 401x401 map, it should take between 1 and 2 minutes. It will generate 5 files directly in the mod folder, containing the map data. +For a default 400x400 map, it should take between 1 and 2 minutes. It will generate 5 files directly in the mod folder, containing the map data. ## Map generation Just create a Minetest world with `singlenode` mapgen, enable this mod and start the world. The data files are immediately copied in the world folder so you can re-generate them afterwards, it won't affect the old worlds. diff --git a/terrain_rivers.py b/terrain_rivers.py index d7c7137..a526d7b 100755 --- a/terrain_rivers.py +++ b/terrain_rivers.py @@ -15,14 +15,14 @@ argc = len(sys.argv) if argc > 1: mapsize = int(sys.argv[1]) else: - mapsize = 401 + mapsize = 400 -scale = (mapsize-1) / 2 -n = np.zeros((mapsize, mapsize)) +scale = mapsize / 2 +n = np.zeros((mapsize+1, mapsize+1)) # Set noise parameters params = { - "octaves" : int(np.ceil(np.log2(mapsize-1)))+1, + "octaves" : int(np.ceil(np.log2(mapsize)))+1, "persistence" : 0.5, "lacunarity" : 2., } @@ -32,8 +32,8 @@ xbase = np.random.randint(65536) ybase = np.random.randint(65536) # Generate the noise -for x in range(mapsize): - for y in range(mapsize): +for x in range(mapsize+1): + for y in range(mapsize+1): n[x,y] = noise.snoise2(x/scale + xbase, y/scale + ybase, **params) nn = n*mapsize/5 + mapsize/20 @@ -87,7 +87,7 @@ save(model.dirs, 'dirs', dtype='u1') save(model.rivers, 'rivers', dtype='>u4') with open('size', 'w') as sfile: - sfile.write('{:d}\n{:d}'.format(mapsize, mapsize)) + sfile.write('{:d}\n{:d}'.format(mapsize+1, mapsize+1)) # Display the map if matplotlib is found try: