Page 1 of 1

Random Map Generator

Posted: Wed Jan 14, 2015 7:43 pm
by Sophalin
Hello all
I am new to the game but I understand the concepts quite well.
However I am trying to play the sandbox, so I create a random map. The only thing I changed in the categories is the line of the coal. I wanted lots of coal so I change it to very high frequency, Very large size and very good richness.
Although the areas of coal are rich, they are quite small in size and even though on some maps it seems that there are plenty of coal fields in most of them there are very few fields.

This is not the case with the copper and iron. even if I put normal amounts of them, I got many times large fields of copper and iron.

I tried about 50 maps...

is this some kind of bug or sheer bad luck?

Re: Random Map Generator

Posted: Wed Jan 14, 2015 10:49 pm
by n9103
Frequency seems to be more of a divisor than a multiplier.
More frequent patches means smaller individual ones. Vice versa for less frequent.

Re: Random Map Generator

Posted: Thu Jan 15, 2015 10:07 am
by cube
I should have drawn this a long time ago:
factorio-resources.png
factorio-resources.png (31 KiB) Viewed 16468 times
The blue wavy line is an internal noise function, black line is a "level" that is used to determine resource placement, red lines are actual placed resources.

The high frequency refers mainly to the noise function. Increasing the frequency increases count of resource fields and decreases their size and distance between them.

This mechanism is used all through the map generation in factorio, with some adjustments.

Re: Random Map Generator

Posted: Thu Jan 15, 2015 10:34 am
by Choumiko
cube wrote:The blue wavy line is an internal noise function, black line is a "level" that is used to determine resource placement, red lines are actual placed resources.

The high frequency refers mainly to the noise function. Increasing the frequency increases count of resource fields and decreases their size and distance between them.

This mechanism is used all through the map generation in factorio, with some adjustments.
Very interesting, so if the noise function where sinus, this would mean sth. like f(x) = sin(frequency*x)+size ( -1 < size < 1) ? And the distance between rising nullpoints (is that the term?) would be the placed ressources.

Re: Random Map Generator

Posted: Thu Jan 15, 2015 5:21 pm
by cube
Choumiko wrote:Very interesting, so if the noise function where sinus, this would mean sth. like f(x) = sin(frequency*x)+size ( -1 < size < 1) ? And the distance between rising nullpoints (is that the term?) would be the placed ressources.
Almost. The map generator works tile by tile, so the resources are placed on a tile x if f(x) > 0. The amount of resources on the tile is given by f(x) * richness.

Re: Random Map Generator

Posted: Thu Jan 15, 2015 5:27 pm
by katyal
so low frequency = widely spaced large + poor deposits
high frequency = tightly spaced small rich deposits

do size and richness have any secondary effects or are they just modifiers?

Re: Random Map Generator

Posted: Thu Jan 15, 2015 6:16 pm
by Xterminator
Wow that's really interesting. Cool to know how it actually works. :D
In my experience if you want a map with a butt load of resources, it is usually nest to just increase size and richness, and not touch frequency.

Re: Random Map Generator

Posted: Fri Jan 16, 2015 3:02 pm
by cube
katyal wrote:so low frequency = widely spaced large + poor deposits
high frequency = tightly spaced small rich deposits

do size and richness have any secondary effects or are they just modifiers?
Frequency doesn't modify the amount of resources on a tile. If you increase frequency then each of the deposists has less resources in total (because it covers less area), but per tile of a deposit there will be the same number of resources.
Also changing frequency doesn't affect the average ammount of resources in a (large) map, only their distribution.

Re: Random Map Generator

Posted: Fri Jan 16, 2015 4:35 pm
by katyal
So cube to go with the combobox on the map settings screen would it be possible to see (hopefully even edit) the underlying values?

Also have you tried different algorithms for generating resources? If so...no matter the results you got, would it be possible to release them, like rso mod for example? OR maybe something like ssilk was suggesting in https://forums.factorio.com/forum/vie ... f=6&t=4692

Re: Random Map Generator

Posted: Sat Jan 17, 2015 10:45 am
by ssilk
@Katyal: this is the problem: finding an algorithm, which can be called _per tile_ without knowing anything else but the coordinates and the map-seed and return a map-tile (not a complete chunk), that matches fine into the neighborhood.

The point is: on this level of map generation, the algorithm can't know anything around him. And so it cannot change the generated amount of resources. Cause of missing input and disability to look at other map tiles around.

And to explain my idea again (for cube: see also https://forums.factorio.com/forum/vie ... 517#p63517): you cannot change this. But instead of that you can add a second map generator and tell him to be "blended in" in this area only.

So, this is what you need to do: generate a map. Open it with the map editor and look at it. Too less coal. Ok, let's add a second map, that has a coal patch, about here... The coal patch is blended in. You can play around with the looking of that coal patch, if you're lucky you can look more around.

The end of this process is a mod/scenario, that has a description, like "Katyal's totally weighted resources". It is not an already rendered map, it is a description for the map generator to run with this seed and add/overlap other maps with that seed at those coordinates.

You can do other cool things with this. Let's say you have an already finished map, which has a smelting area. So you can go into the map editor and tell him, to load this area of your map into that area of the generated. And suddenly you have a finished smelting area in your map, which is not included, when starting the map, it is only generated, when you generate that part of the map.

In other words: if you put over the current map generator an advanced map generator, that has the additional input parameters "a list of maps" and "rules, that tells which map should be blended in how strong at which coordinates", you can generate nearly anything. :)

Re: Random Map Generator

Posted: Sun Jan 18, 2015 4:29 pm
by Sophalin
This seems odd to me

That means that if I use High freq, low size, good richness, I will have small very rich deposits but on my last game, the definitions were up-side-down than those, and i had huge deposits with more than 44K! of copper, iron and coal!

Btw, is there anything in the definitions to control forests size?

Re: Random Map Generator

Posted: Mon Jan 19, 2015 5:27 am
by katyal
The current method used to distribute resources is perlin noise...I was just asking if another method had been tried, and if so could we see the results.

What about having a few prerendered "resource maps" (greyscale images that affect resource placement). You keep the current map generation but the resource map would influence the results.

Re: Random Map Generator

Posted: Tue Jan 20, 2015 11:00 am
by cube
We've been planning to make some changes to world generation for a long time now:
1) Simpler gui, more relying on mods than on tons of combo boxes (how many resources, how many enemies, how much water)
2) guaranteed starting area resources + less probable islands (a trick with pre-generating rather large part of the world around start and checking if it meets the requirements)
3) lua code for autoplacer -- this would enable generating destroyed (or even working!) bases, treasure chests guarded by biters..... a lot of fun things :-)

Unfortunately all these have fairly low priority now, don't expect them for 0.12. But it will happen some day :-)

Re: Random Map Generator

Posted: Tue Jan 20, 2015 2:46 pm
by katyal
Thats fantastic, no need to rush just knowing that these things are in the development pipeline is enough for now