terrain_rivers.py: `mapsize` is now the number of intervals

instead of the number of nodes.
This commit is contained in:
Gael-de-Sailly 2020-04-26 19:51:21 +02:00
parent cd90a21df4
commit cd4b517585
2 changed files with 8 additions and 8 deletions

View File

@ -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.

View File

@ -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: