Post your mapgen questions here (modding or engine)

procedural_map
New member
Posts: 4
Joined: Wed Aug 17, 2016 11:48

procedural map

by procedural_map » Post

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, ...)

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

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.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

procedural_map,

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

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

What is the best way to check if an area is generated a plain?

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

You mean detect a grassland biome?

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

Yes, I do not want to create decorative items. I want to create structures such as villages.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

So you're looking for a fairly flat area too?

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

Yes, exacly.

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

Here's an example. This looks like a smooth behavior of the perlin noise.
Image
Attachments
exemplo.jpg
exemplo.jpg (104.01 KiB) Viewed 1319 times

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

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.

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

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

by Sokomine » Post

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.
A list of my mods can be found here.

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

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

by duane » Post

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.
Believe in people and you don't need to believe anything else.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

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

by paramat » Post

If you know biome you can avoid trees, or if there are trees you can remove them for a 'vilage in a forest' effect.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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.

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

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.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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
Attachments
screenshot_20160820_223952.jpg
screenshot_20160820_223952.jpg (326.71 KiB) Viewed 1319 times

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

This should be a check failure, it should not happen.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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
Attachments
screenshot_20160820_225001.jpg
screenshot_20160820_225001.jpg (528.89 KiB) Viewed 1319 times

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

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

by BrunoMine » Post

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.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

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

by duane » Post

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...
Believe in people and you don't need to believe anything else.

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

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

User avatar
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

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

by burli » Post

How do I create a voronoi diagram and how do I use it?

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

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

by qwertymine3 » Post

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.
Avatar by :devnko-ennekappao:

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests