Noise & Peaks Guide?

Place to get help with not working mods / modding interface.
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Noise & Peaks Guide?

Post by PsudoSage »

Hi, i would like to get into making a mod for factorio and was wondering if anyone could give an explanation of how the ore generation code works. I have been looking at the code for a few mods to see if I can make sense of it but I don't quite get what all the variables are doing to affect the generation. I would like to be able to make some ore spawn outside the spawn area and I would like to be able to make some deposits really small etc.
slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: Noise & Peaks Guide?

Post by slay_mithos »

I would like to second that, because I would love to tune some resources to my needs (mainly stone, dytech uses so much of it), but I don't want to do it the wrong way around.
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

Looks like I'll just have to have a stab in the dark with some trial and error. Maybe I'll write a little test mod and post it up with a load of commented code on my findings.
User avatar
ludsoe
Fast Inserter
Fast Inserter
Posts: 243
Joined: Tue Feb 11, 2014 8:16 am
Contact:

Re: Noise & Peaks Guide?

Post by ludsoe »

PsudoSage wrote:Looks like I'll just have to have a stab in the dark with some trial and error. Maybe I'll write a little test mod and post it up with a load of commented code on my findings.
Ill look forward to reading up on your findings when your done.
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Noise & Peaks Guide?

Post by ficolas »

Factorio wiki-> auto place
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Noise & Peaks Guide?

Post by drs9999 »

User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Noise & Peaks Guide?

Post by Dysoch »

this are my findings from a while back (2 months or so)
some things might be wrong, but i guess most is accurate
note: the random values are no longer working correctly. and this is from factorio 0.8, so things have been added since

Code: Select all

 autoplace =
      {
        control = "sand", -- this is the control group. You need to add it also to autoplace-controls.lua. The generator (when starting a new map) has then the richness, size and frequenty options.
        sharpness = 0.8, -- this value corrisponds to the clutterness of a deposit. Meaning at 1 they will be like iron or copper ores spots. 0 is everywhere. 0.8 here shows a normal ore spot, but a bit more spaced apart
        richness_multiplier = math.random(75000), -- this give the multiplier a random number between 0 and 75000 (means richness_base * multiplier * richness setting (setting richness to very rich gives it a 2x or 3x bonus i believe (based on my observations)
        richness_base = math.random(5000,15000), -- this gives a number between 5000 and 15000. This is the base value of a deposit, and the rest is calculated above (at multiplier) and below (at the influences)
        peaks = {
         { -- this first peak is special. this is not added normally to the game. The way it works is as follows:
              influence = 0, -- this does nothing. but if set to a nonzero value, it would change drastically (a shitload of ore well appear in the world, and we dont want that to happen :P)
              richness_influence = 1.2, -- this is the changeling. this makes sure that no single tile of resource is the same. that works simple, like this (noise value) * richness_influence * richness_multiplier = the size of deposit. the noise value is a random value between -1,5 and 1,5 with a prefered likeness of around 0
              noise_layer = "random" -- this is a surrogate layer. it does not correspond with any resource, thus rendering its layer useless. but it needs to be added, otherwise it gives and error
            },
         { --for the rest, i dont know the exact formulas for calculating, but i know what they do.
           influence = 0.21, -- these things are really tricky. changing them by even 0.01 is enough to spawn 5000 more tiles in only 50 chunks!
           starting_area_weight_optimal = 0, -- these 3 things are the starting area influences. they specify the range and weigth of the resource in the starting area. it thus corresponds to how many resources there will be in your starting area 
           starting_area_weight_range = 0, -- the starting range of the starting area
           starting_area_weight_max_range = 2, -- the maximum allowed size of the starting area. Making this higher, means more ore in your starting area, and a larger radius in which they spawn
         },
         {
           influence = 0.3, -- same as above
           starting_area_weight_optimal = 1,
           starting_area_weight_range = 0,
           starting_area_weight_max_range = 2,
         },
         {
           influence = 0.65,
           noise_layer = "sand", -- this checks for sand in the vicinity. if it found some, it adds 0.4 to each multiplier the further away they are. but very close, they remove 1.9 multiplier for each tile.
           noise_octaves_difference = -1.9,
           noise_persistence = 0.4,
           starting_area_weight_optimal = 0,
           starting_area_weight_range = 0,
           starting_area_weight_max_range = 2,
         },
         {
           influence = 0.55,
           noise_layer = "sand",
           noise_octaves_difference = -2.3, --same as above
           noise_persistence = 0.4,
           starting_area_weight_optimal = 1,
           starting_area_weight_range = 0,
           starting_area_weight_max_range = 2,
         },
         {
           influence = -0.2,
           max_influence = 0, --i havent quite found out what this does xD
           noise_layer = "iron-ore", -- this works the same as above, but checks for iron instead of sand
           noise_octaves_difference = -2.3,
           noise_persistence = 0.45,
         },
         {
           influence = -0.2,
           max_influence = 0,
           noise_layer = "copper-ore", -- this works the same as above, but checks for copper instead of sand
           noise_octaves_difference = -2.3,
           noise_persistence = 0.45,
         },
         {
           influence = -0.2,
           max_influence = 0,
           noise_layer = "coal", -- this works the same as above, but checks for coal instead of sand
           noise_octaves_difference = -2.3,
           noise_persistence = 0.45,
         },
         {
           influence = -0.2,
           max_influence = 0,
           noise_layer = "stone", -- this works the same as above, but checks for stone instead of sand
           noise_octaves_difference = -3,
           noise_persistence = 0.45,
         },
        },
      },
Edit: extended it a bit.
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

Thanks for the help guys, I have been having a tinker with this all night. I think I have loosely figured it out, I cant stress loosely enough though. It seems the peaks are all combined to create one final result, which is not what I thought at first. The first peak that's completely random seems to be either a raw map seed or a blank noise layer, then the next peaks adds the specific noise layers for the resource. The last ones stop overlapping by reducing influence where it finds other resources.

I'll write a quick summary of my guesswork using the default copper peaks, corrections & confirmations are welcome as this is still very confusing and I might be completely wrong.

Default Copper Ore:
First Peak (Random Or Empty)

Code: Select all

influence = 0.2, -- 0.2 of an empty layer would mean the map would be 20% filled with 'noise'.
starting_area_weight_optimal = 0,
starting_area_weight_range = 0,
starting_area_weight_max_range = 2,
Second Peak: (Main copper generation)

Code: Select all

influence = 0.65,
noise_layer = "copper-ore",
noise_octaves_difference = -1.9, -- Increase copper generation the further from start
noise_persistence = 0.3, -- Increase by this much
starting_area_weight_optimal = 0, -- No starting bonus
starting_area_weight_range = 0,
starting_area_weight_max_range = 2,
Third Peak: (Starting area boost)

Code: Select all

influence = 0.3, -- Small amount of influence
starting_area_weight_optimal = 1, -- Affects starting area only
starting_area_weight_range = 0,
starting_area_weight_max_range = 2,
Fourth Peak: (Starting area increasing boost)

Code: Select all

influence = 0.55,
noise_layer = "copper-ore",
noise_octaves_difference = -2.3, -- Increased ores towards the outer edge of the starting area
noise_persistence = 0.4,
starting_area_weight_optimal = 1, -- Another starting area only
starting_area_weight_range = 0,
starting_area_weight_max_range = 2,
Fifth peak (Avoid Iron):

Code: Select all

influence = -0.2, -- Negative influence reduces value near iron
max_influence = 0, -- Max of 0 stops copper from generating on iron
noise_layer = "iron-ore", -- Noise layer determines what to avoid
noise_octaves_difference = -2.3, -- Increased effect further from start to match irons own increase
noise_persistence = 0.45,
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

I found some other useful tags that may be used for rare ore generation too inside the biter spawner peaks:

Code: Select all

influence = 0.5,
noise_layer = "enemy-base",
noise_octaves_difference = -1.8,
noise_persistence = 0.5,
tier_from_start_optimal = 20, -- These 3 properties are used to keep enemy bases from spawning inside the starting area, could be useful for rare ores (diamonds, gold etc)
tier_from_start_top_property_limit = 20,
tier_from_start_max_range = 40,
slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: Noise & Peaks Guide?

Post by slay_mithos »

Nice, so you can make it as if the bitters settled on specific resources by forcing them to spawn near enemy bases.

This opens up decent potential in setting more lore about those bitters, by making them spawn near specific resources, as if they needed it to live.
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

I think that is a possibility, you could either make an ore use the same noise layer as the biters, or have another noise layer thats just influenced by the biter noise layer like the opposite of the 'iron avoid' peak above. Just with increased influence instead of reduced.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Noise & Peaks Guide?

Post by Dysoch »

If ypu are going to release a mod with custom ores, make sure tou check out other mods that bring ores. (dyTech and Fmod)
I suggest to use the same internal names to make them compatible with each other
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

If they have the same name across different mods are they automatically compatible (Like minecrafts ore dictionary) or will compatibility need to be added by each mod through an interface?

I was thinking of making a resource pack mod that contains just resources and associated items then using that mod as a base for any other mods I feel like tinkering with.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Noise & Peaks Guide?

Post by Dysoch »

If there internal names are the same, they are automaticly compatible. A good example is that fmod has molten-iron, and so does v2 of dytech, making it compatible with recipes of fmod and dytech. (Only recipes from fmod will disable, but that is intentional)
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: Noise & Peaks Guide?

Post by slay_mithos »

What's great about factorio's way of adding items/recipes is that it is all based on the internal name.

You can make a "gold-ore" resource, and only add recipe to smelt it to "gold-plate", and it will happily also use the "gold-ore" generated by f-mod (underground mining only, no surface resource), as well as use your ore to melt it to its "molten-gold".

There are only a few thing to consider, which is that any prototype with the same internal name will overwrite any previous declaration.
For items, it means mostly the icon and where it's placed by the auto-sort in the inventory, but it could change quite a bit for recipes, depending on which mod loads last.

Anyway, it means that if you take a bit of time to check the other mods first, you might be able to make yours so that it complements it by using the same internal names (or even require them and use their resources instead in your recipes, up to you).
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

I'm going to follow the base mods coding standards as much as possible in terms of naming things. I have had a quick look at fmod and dytechs names and so far the stuff I have set up is already compatible, the only issue I see is a slight change in my gem names so no probs.

Looks like it will be pretty cool for modding resources in then with good compatibility features.
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Noise & Peaks Guide?

Post by Dysoch »

PsudoSage wrote:I'm going to follow the base mods coding standards as much as possible in terms of naming things. I have had a quick look at fmod and dytechs names and so far the stuff I have set up is already compatible, the only issue I see is a slight change in my gem names so no probs.

Looks like it will be pretty cool for modding resources in then with good compatibility features.
If you release it, ill take a look and we can work something out for compatibility to my new metallurgy system ;)
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
PsudoSage
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Mar 19, 2014 7:20 pm
Contact:

Re: Noise & Peaks Guide?

Post by PsudoSage »

Dysoch wrote:If you release it, ill take a look and we can work something out for compatibility to my new metallurgy system ;)
Sounds good. I'll do that.

I have managed to make dual ore generation work.. kinda. I made a galena style deposit with silver and lead combined. I'm gonna try some noise layer tricks tomorrow to see if I can improve it because I want to do this for gems too and I think it will need slightly more advanced control to handle like 5 or 4 ores at once.

Image
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

Re: Noise & Peaks Guide?

Post by Dysoch »

PsudoSage wrote:
Dysoch wrote:If you release it, ill take a look and we can work something out for compatibility to my new metallurgy system ;)
Sounds good. I'll do that.

I have managed to make dual ore generation work.. kinda. I made a galena style deposit with silver and lead combined. I'm gonna try some noise layer tricks tomorrow to see if I can improve it because I want to do this for gems too and I think it will need slightly more advanced control to handle like 5 or 4 ores at once.

Image
Looks good ;)

But my advise, try with all mods that add ores, and see how the world looks ;) we dont want a floor of only ores ;)
And since silver and lead isnt used quite as much, try to makr the deposits a bit smaller
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6
slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: Noise & Peaks Guide?

Post by slay_mithos »

Still talking about noise layers, is it possible to state layers that might not exist (like dytech's gems or sand)?

If so, what is the actual effect if that layer is not used (because that mod might not be installed), and how to get around the problem if there is one?

I mean that if we can take compatibility into account right from the start, it might make thing easier in the long run.
Post Reply

Return to “Modding help”