What's the meaning of the autoplace_controls?

Place to get help with not working mods / modding interface.
Post Reply
yeganer
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Mon Jul 06, 2015 12:07 pm
Contact:

What's the meaning of the autoplace_controls?

Post by yeganer »

Hey guys,

I'm in the process to rewrite the popular mod RSO to support multiple surfaces and in the process of doing that i'd like to simplyfy it's configuration by using the autoplace_controls as basis for the internal resource patch generation. Currently i am struggeling a bit to understand the impact of all the different settings.

In particular i'm interested in the formula that determines the amount of ore that is spawned in each tile.
Another thing i'm curious about is the impact of the map_gen_settings. Like in which way does a setting of "very rich" influence the final amount of ore in the tile.
I'm guessing richness_multiplier and size_control_multiplier are used to translate the map_gen_settings into real the final value.

I read the part on the wiki but it didn't make much sense to me without code or some formulas to help understand it.

What i don't understand about the peaks is how they are used. I thought the way it worked was that every resource has a noise layer and if that exceeds a threshold the resource will be spawned. But that doesn't make sense when there are peaks without a noise-layer and it won't explain how the starting area spawns are done.

Can someone please help me understand that?

Thanks in advance,
yeganer

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: What's the meaning of the autoplace_controls?

Post by cube »

This post talks about frequencies and sizes:
https://forums.factorio.com/forum/vie ... 670#p63561

And here are some details about how richness influences spawners:
https://forums.factorio.com/forum/vie ... 053#p88302

The amount of ore is given by the value of the noise function.
First the raw value is calculated as the noise function (blue line in the first linked post) minus the threshold level (black line).
If this is positive, then the final amount is calculated using this code:

Code: Select all

(this->richnessBase + value * this->richnessMultiplier) * settings.richnessMultiplier
where this->richnessBase and this->richnessMultiplier are the values set in the resource prototype, value comes from the previous step and settings.richnessMultiplier is a value between 1/2 and 2 controlled by the richness drop down box.


Peaks are a way to specify multiple conditions that affect placement of an entity, each entity can have multiple of them. For example trees use peaks referring to temperature and moisture of the environment to create biomes. Noise layer can be a part of a peak which means that the peak's value also depends on perlin noise, however in practice we use only peaks with either noise or map properties (like temperature) and not both of them together.

Another important thing to note is that frequency and size controls only the perlin noise values, not the map properties. This means that if you make a placement rule that depends only on map properties (or depends too strongly on map properties), the frequency and size controls will have no effect.

Generally I prefer to use map properties, because not having user controls makes the parameter tuning much easier, map properties already contain data to make biomes and make a more believable terrain (imho), and also because each noise layer that has to be evaluated takes some non trivial ammount of CPU when generating map.
I have an optimization in mind for 0.13 that should decrease the performance impact significantly, but the first two arguments still stand even for the future.

yeganer
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Mon Jul 06, 2015 12:07 pm
Contact:

Re: What's the meaning of the autoplace_controls?

Post by yeganer »

Thank you very much, that information is awesome!

I have only one small question. the value is calculated as

Code: Select all

value = noise-threshold
So what order of magnitude does value have? from what i have seen ingame i would estimate something around 0.05 - 0.2? Is there an upper limit to that value and if so, how big is it?

My goal is to translate all the stuff that is in the prototype to use it for spawning. My goal is to create patches with approximately the same richness like vanilla but to control where it will be spawned and the shape of them (I'm currently using Metaballs and they work great for that purpose)

The information about the map properties is really cool. I could use that to decide where the resources should be spawned.
Does each property like elevation, water availability etc. have their own noise layer?

Thank you again for the help.

EDIT: I was just wondering how the fluid spawning was done. I wasn't able to find anything about that on the forums or the wiki.

safan
Fast Inserter
Fast Inserter
Posts: 126
Joined: Mon Dec 23, 2013 7:26 pm
Contact:

Re: What's the meaning of the autoplace_controls?

Post by safan »

i don't yet get it all:

i'm trying to make a new tile, mountain, with the same properties as waters. So i copied the tile settings of water, but now i'm stuck with the

autoplace = water_autoplace_settings(250),
layer = 45,

If i copy from grass i get

autoplace = ("grass", {{{35, 0.8}, {0, 0.4}}}
layer = 40,

so what arguments does the autoplace want, and what does the layer mean.

In an idealistic situation i want under the map generator choices for water a new line for mountains (none to very big)
and then create long ranges of inpassable terrain.

Do i need more then an autoplace with good arguments? How can i best test if these work?

thanks

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: What's the meaning of the autoplace_controls?

Post by cube »

yeganer wrote:Thank you very much, that information is awesome!

I have only one small question. the value is calculated as

Code: Select all

value = noise-threshold
So what order of magnitude does value have? from what i have seen ingame i would estimate something around 0.05 - 0.2? Is there an upper limit to that value and if so, how big is it?

My goal is to translate all the stuff that is in the prototype to use it for spawning. My goal is to create patches with approximately the same richness like vanilla but to control where it will be spawned and the shape of them (I'm currently using Metaballs and they work great for that purpose)

The information about the map properties is really cool. I could use that to decide where the resources should be spawned.
Does each property like elevation, water availability etc. have their own noise layer?

Thank you again for the help.

EDIT: I was just wondering how the fluid spawning was done. I wasn't able to find anything about that on the forums or the wiki.
The raw value is calculated as a sum of peak influences. By default peaks have range from -1 to 1, but they also have a selectable multiplier that we use very often (mostly between 0.01 - 0.5, IIRC), so the final range is really up to you.

Yes, elevation is a noise layer filtered by some custom function, temperature is noise layer - constant * elevation, moisture is noise layer * linear function of temperature

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: What's the meaning of the autoplace_controls?

Post by cube »

safan wrote:i don't yet get it all:

i'm trying to make a new tile, mountain, with the same properties as waters. So i copied the tile settings of water, but now i'm stuck with the

autoplace = water_autoplace_settings(250),
layer = 45,

If i copy from grass i get

autoplace = ("grass", {{{35, 0.8}, {0, 0.4}}}
layer = 40,

so what arguments does the autoplace want, and what does the layer mean.

In an idealistic situation i want under the map generator choices for water a new line for mountains (none to very big)
and then create long ranges of inpassable terrain.

Do i need more then an autoplace with good arguments? How can i best test if these work?

thanks
In your grass example you are missing "autoplace_settings" before the first bracket :-)
We are using the fact that lua is a full programming language and putting the repetitive parts into helper functions. In this case "autoplace_settings" and "water_autoplace_settings", which both call function "peaks" from "autoplace_utils".

You won't be able to directly use the water source, because it is set up to only work for negative elevations (if the parameter is 250, it means "at least 250 meters deep").
To add mountains that simply cover everything high enough, you could copy the "water_autoplace_settings" and change signs in the "elevation_optimal" line.

Post Reply

Return to “Modding help”