Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: ENVIRONMENT & ENVIRONMENT_SPEC frequencies  (Read 969 times)

Xilian

  • Bay Watcher
    • View Profile
ENVIRONMENT & ENVIRONMENT_SPEC frequencies
« on: July 10, 2019, 03:06:40 pm »

The DF wiki on frequency for the ENVIRONMENT token ([ENVIRONMENT:<class>:<inclusion type>:<frequency>]):
The frequency number varies from 1 to 100 and determines the relative frequency at which the stone will be chosen to appear - if all frequency values are the same, then all stones will be equally likely to appear.

Now I'm wondering if anyone knows how this frequency is used. Does world gen pile all entries with the ENVIRONMENT TOKEN and distribute them according to the frequency disregarding class values. Or does world gen distribute all entries with a specific class value using the relative frequency? The Former seems like it'd be easier to handle by the system, while the latter would allow more control over inorganic material distribution.

Further elaborating on this. How does world gen handle the ENVIRONMENT_SPEC token. This token allows you to place clusters within clusters. One could imagine that if the parent cluster has a frequency of 50, and the nested cluster a frequency of 100, that the nested cluster would be limited to a 50 freq. Likewise if the nested cluster has a frequency of 50 aswell, would it mean that the nested cluster thus has an actual frequency of 25 (disregarding the distribution of different rock layers)?
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution
Re: ENVIRONMENT & ENVIRONMENT_SPEC frequencies
« Reply #1 on: July 10, 2019, 03:25:49 pm »

the FREQ value I think follows the same rules of OBJECT:CREATURE's FREQ where it may be 1-100 but it's still a ratio. So if all stone was FREQ 1 it's the same as all being FREQ 100 because they are all even ratios.

but having two stone layers as 100 (A and B) and one as 50 (C) just means 50/250 which is basically a 20% chance of showing up, leaving 40% for layer A and B. So you'd have a 20% chance to be picked as a stone layer for C in the given ENVIRONMENT type

Same with _SPEC version, if you had one nested type


So I think DF just jams all the types in their groups, then shuffles through them based on their ratio'd FREQs of the whole group.

_SPEC probably is the same but could be something once the parent is placed. RNG picks BASALT, DIAMOND is E_SPEC of BASALT so roll change to place DIAMOND. Now even then I'm pretty sure I never always see things placed inside others, but that may be a quirk of "what" is allowed in the Region/Embark zone
Logged

Wannabehero

  • Bay Watcher
    • View Profile
Re: ENVIRONMENT & ENVIRONMENT_SPEC frequencies
« Reply #2 on: July 10, 2019, 05:59:21 pm »

I can only report on my own limited observations, but I've done some extensive modding of geologic layers/veins/clusters in an unreleased mineral overhaul mod.  What I've observed is thus:

Frequency values for minerals are only used when the material is allowable within a selection pool, and only for non-layer materials. For example, the game determines that a layer material will be SEDIMENTARY class because of both the world seed as well as the world-gen geology rules; the game then runs a selection pool of all sedimentary class layer minerals. Because this is a layer decision, all SEDIMENTARY minerals are equally weighted to appear when the game places this layer.

The game repeats this selection processed for each layer section of the world, and then moves on to placing minerals within the layers. This is when frequency and ENVIRONMENT comes into play. During world gen the game will make many calls for placement of various minerals/materials, picking based on relative frequency of each candidate for that group in the selection pool for that call.  The game makes calls for placement of layers, then veins and clusters, and then other special features (small clusters, trees and plants).

There seems to be a hierarchy to the order that minerals are placed in the world:

LAYER --> CLUSTER --> VEIN --> CLUSTER_SMALL --> CLUSTER_ONE

This is observable in that large clusters do not overwrite veins (or at least, I've never seen it) but veins will run through large clusters and into/from the surrounding layers. Similarly, small clusters can overwrite locations in veins, and single cluster minerals can overwrite small clusters.  I could be wrong in this assumption, as I haven't run extensive tests to back this up yet.

The LAYER mineral is always placed down first. From there the game will calculate, based on the seed algorithm and the MINERAL_SCARCITY setting of world-gen, if it wants to place clusters or veins within a section of the ENVIRONMENT layer. The frequency settings on the minerals, to the best of my knowledge, have absolutely zero impact on the game deciding how many additional clusters and veins to place within environment layers (or within the clusters/veins themselves); it is the mineral scarcity setting prior to world gen that determines how many minerals you get. If the placement algorithm says YES to placing a cluster or vein, then all possible candidate minerals that are viable for that ENVIRONMENT class (have the right tag) are placed in a pool and weighted based on their frequency values in regards to the ENVIRONMENT being called in the placement decision. A winner is picked and placed within the layer. The process repeats based on MINERAL_SCARCITY restrictions.

The placement algorithm will also run checks on all placed minerals as part of this process, determining if they are themselves a valid ENVIRONMENT for additional minerals, in addition to host layer.  This is where ENVIRONMENT_SPEC tag comes into play. If the placement algorithm says YES to placing another mineral within a previous one, it will place all candidates with valid _SPEC tags for the host mineral into a frequency weighted pool and pick one to place. This is not guaranteed to happen; it still depends heavily on your MINERAL_SCARCITY world settings.

Take the example of all the rare diamonds in the base game.  Each of them only occurs as a CLUSTER_ONE in the ENVIRONMENT_SPEC of faint yellow diamond. Not every faint yellow diamond cluster will have a rare diamond occurring in it, but every time the placement algorithm determines a faint yellow diamond cluster will host another mineral, it will be one of the rarer diamonds, as they are the only viable candidates for faint yellow diamond as the host.

Minerals can definitely be placed within one-another, but it usually requires a very high mineral occurrence (low MINERAL_SCARCITY) settings to be easily observed.
« Last Edit: July 10, 2019, 06:03:29 pm by Wannabehero »
Logged