Page 3 of 34

procedural map

Posted: Wed Aug 17, 2016 12:20
by procedural_map
Using Lua, how do I procedurally generate a map? I copy-pasted some examples from wiki into init.lua but they don't work (don't create map or something like this)

For example (I might use not proper minetest's names)
1)
y = 1 => sand
y < 1 => rock
y > 1 => air
2) Then let's say every 3rd block in x- and z- coordinate will be dirt (y = 1; z, x = 3, 6, 9, 12, ...)

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:08
by paramat
burli,

This is a lua mapgen? Operating in singlenode mapgen or adding to another? Can you link to your code?
The sand is probably the seabed sand from the defined biomes, this does appear sometimes in core mapgens down to y = -112 and is caused by overgeneration of large caves.

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:19
by paramat
procedural_map,

You create a lua mapgen using the lua voxel manipulator, an example simple mapgen is here https://github.com/paramat/noise23

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:22
by BrunoMine
What is the best way to check if an area is generated a plain?

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:47
by paramat
You mean detect a grassland biome?

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:51
by BrunoMine
Yes, I do not want to create decorative items. I want to create structures such as villages.

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:54
by paramat
So you're looking for a fairly flat area too?

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 17:55
by BrunoMine
Yes, exacly.

Re: Post your mapgen questions here (modding or engine)

Posted: Thu Aug 18, 2016 19:44
by BrunoMine
Here's an example. This looks like a smooth behavior of the perlin noise.
Image

Re: Post your mapgen questions here (modding or engine)

Posted: Fri Aug 19, 2016 18:08
by paramat
Easiest way is to use the 'mapgen object heightmap' and scan it for a small height variation.
For biome hopefully soon we will have a 'get biome at point' API (hmmmm intends to write it), until then you'll have to use the mapgen's heat- and humidity- (and in mgv6 tree-) noises and check for values that result in grassland.

Re: Post your mapgen questions here (modding or engine)

Posted: Fri Aug 19, 2016 20:01
by Sokomine
BrunoMine wrote: Yes, I do not want to create decorative items. I want to create structures such as villages.
That was my original intention as well, but it didn't prove to be practical. Most horizontal areas will not be large enough for your village anyway. And it's not exactly cheap to locate such areas. In the end, just changing the terrain in a believable way and pretending it had always looked like that (minus the village of course :-)) works pretty well. The additional advantage is that there's less dependency on the mapgen actually used.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 10:36
by duane
Sokomine wrote:
BrunoMine wrote: Yes, I do not want to create decorative items. I want to create structures such as villages.
That was my original intention as well, but it didn't prove to be practical. Most horizontal areas will not be large enough for your village anyway. And it's not exactly cheap to locate such areas. In the end, just changing the terrain in a believable way and pretending it had always looked like that (minus the village of course :-)) works pretty well. The additional advantage is that there's less dependency on the mapgen actually used.
I did the same with primitive villages, cities, even metal-rich soil for ferns. If you're looking for something, it's always easier to find if you put it there yourself.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 11:34
by burli
I think, with the default mapgens it is not possible. They don't provide any informations about the map. Even with heightmap and biome you have still have the problem, that you need to check a lot, e.g. if there are trees in the way.

Structures like buildings should be placed before any other decoration. But this is currently not possible for mods because they run after everything is done. That's why I suggested some kind of Mapgen API a few weeks ago to split map generation in different steps and execute lua mapgens between the steps from the C++ mapgen or replace entire steps

I read a bit about map generation and there are some different types of methodes. Using noises is one of the easiest, but as I mentioned you don't have much information and no control about your map.

I think about something like a "geome" map, geological regions similar to biomes, but with different land shapes like different kind of mountains, mesa, highlands, hills, plateaus, canyons, plains, lakes, of course oceans or even (nearly) flat regions for a village "geome" without any decoration

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 18:31
by paramat
If you know biome you can avoid trees, or if there are trees you can remove them for a 'vilage in a forest' effect.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 18:50
by burli
Of course can I avoid trees, but it is just easier if you have a "village biome"

Removing trees has two problems. It costs time to generate and remove them and removing may result in half cutted tree.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 19:11
by BrunoMine
viewtopic.php?f=9&t=15382
This was my attempt to create something. I used the height of the land and avoiding trees (simply canceling the placement of the village). The code is not very clean, but the results are very interesting.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 20:43
by burli
burli wrote:Removing trees has two problems. It costs time to generate and remove them and removing may result in half cutted tree.
Needed 30 seconds to find an example in BrunoMine's mod. That can always happen if you place trees first

Image

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 21:02
by BrunoMine
This should be a check failure, it should not happen.

Re: Post your mapgen questions here (modding or engine)

Posted: Sat Aug 20, 2016 21:09
by burli
BrunoMine wrote:This should be a check failure, it should not happen.
I flew around for a few minutes and I found lots of examples. Here is a tree decaying

Image

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Aug 21, 2016 00:46
by BrunoMine
I performed the necessary corrections. The houses are not built in place of trees.
I checked for 1 minute and found the error.
Download again DEV version of the project.

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Aug 21, 2016 05:27
by burli
Even if it works it takes additional time while map generation and you can't build a house or village in a forest

It's like building a house from the roof down to the cellar. It may work, but it takes more time and the result might be different from what you want

If I would write a mapgen I would place the buildings first, then the trees

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Aug 21, 2016 06:46
by duane
burli wrote:Even if it works it takes additional time while map generation and you can't build a house or village in a forest

It's like building a house from the roof down to the cellar. It may work, but it takes more time and the result might be different from what you want

If I would write a mapgen I would place the buildings first, then the trees
Write that mapgen!

Seriously, there's nothing stopping you from placing everything yourself. Gael de Sailly did it, and valleys mapgen was very popular when I discovered minetest. (Sadly, I think I scuttled it when I converted it to C, even though you can still place all the valleys decorations on top of the C mapgen.)

Yes, it's going to take more CPU time, but if you're doing any modifications via voxelmanip, you've already spent most of that time. Anyway, liquid and light handling are the worst time wasters for me, no matter where the bits and pieces are being placed. Gael de Sailly had it right. Do everything yourself as long as you're doing any of it and save the time the regular mapgen would take.

If I were really clever, I'd write the basics (or steal them from valleys) with single node setting and overload the voxelmanip functions so that all other mods worked through my framework, so that data was only read and written once, and lighting and liquid calculations happened once at the end of the process. Cut the C mapgens out altogether!

But I'm blithering again...

Re: Post your mapgen questions here (modding or engine)

Posted: Sun Aug 21, 2016 07:33
by burli
duane wrote: Write that mapgen!

Seriously, there's nothing stopping you from placing everything yourself. Gael de Sailly did it, and valleys mapgen was very popular when I discovered minetest. (Sadly, I think I scuttled it when I converted it to C, even though you can still place all the valleys decorations on top of the C mapgen.)

Yes, it's going to take more CPU time, but if you're doing any modifications via voxelmanip, you've already spent most of that time. Anyway, liquid and light handling are the worst time wasters for me, no matter where the bits and pieces are being placed. Gael de Sailly had it right. Do everything yourself as long as you're doing any of it and save the time the regular mapgen would take.

If I were really clever, I'd write the basics (or steal them from valleys) with single node setting and overload the voxelmanip functions so that all other mods worked through my framework, so that data was only read and written once, and lighting and liquid calculations happened once at the end of the process. Cut the C mapgens out altogether!

But I'm blithering again...
We both know that there is an ugly 1GB limit, if you would like to do this in Lua. I don't think that it is possible to write the mapgen I have in mind in Lua and I don't have the C++ skills to write a native mapgen.

Nevertheless I will write my own mapgen, but more to get programming skills than to make an actual mapgen

Re: Post your mapgen questions here (modding or engine)

Posted: Mon Aug 22, 2016 06:19
by burli
How do I create a voronoi diagram and how do I use it?

Re: Post your mapgen questions here (modding or engine)

Posted: Mon Aug 22, 2016 08:46
by qwertymine3
burli wrote:How do I create a voronoi diagram and how do I use it?
You can either generate it pixel by pixel, by testing the distance to each point near the pixel and finding the closest.
Here is a good explanation of how to do this: http://web.archive.org/web/201604190631 ... l-noise-2/

Or you can generate a diagram of vectors which bound the 'cells', using an algorithm such as fortunes algorithm. To use this, you would then have to use an algorithm to render the polygons.

For minetest mapgen, the former method is fast enough for 2d noise. 3d noise is very hard to optimise with the former method, and would requires some advanced algorithms with the latter method.