[2.0.72] resource_autoplace_all_patches noise-expressions with identical regular_patch_set_index influence each other

Post your bugs and problems so we can fix them.
Keithen
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Jul 04, 2022 7:36 pm
Contact:

[2.0.72] resource_autoplace_all_patches noise-expressions with identical regular_patch_set_index influence each other

Post by Keithen »

With this code in a data.lua (no other code anywhere else, no other mods. zipped mod is attached.):

Code: Select all

local copper = data.raw["noise-expression"]["default-copper-ore-patches"]
copper.expression = copper.expression
	:gsub("regular_rq_factor = 0%.11", "regular_rq_factor = 0.03")
	:gsub("regular_patch_set_index = 1", "regular_patch_set_index = 0")
And starting a new freegame with default settings, I would expect iron patches to be the same size as usual, with small copper patches in the middle (or very little/no copper, if the RNG got unlucky, I guess).

Instead I see the following (very small, roughly circular iron patch with bits of copper ore. A normal iron patch should have like 4 times that radius (and be less regular and all that)):
smol_iron.png
smol_iron.png (570.47 KiB) Viewed 234 times
When I turn off iron ore in the new game settings, I get small circular copper patches, roughly of the dimensions shown in the screenshot.

If instead I turn off copper ore, I get perfectly normal iron patches.

So it looks like changing the index in the copper noise expression somehow influenced the iron noise expression or something?
Attachments
factorio-current copy.log
(6.65 KiB) Downloaded 11 times
wtff_0.0.1.zip
Packed repro mod. sry for the name.
(667 Bytes) Downloaded 12 times
RampageNPC
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Apr 05, 2025 10:42 am
Contact:

Re: [2.0.72] resource_autoplace_all_patches noise-expressions with identical regular_patch_set_index influence each othe

Post by RampageNPC »

I'm seeing the same behavior on my experiments with trying to get angelsinfiniteores working.

I've got a minimal reproducer [1] adding an infinite version of coal which is supposed to generate a smaller patch within normal coal patches.
For that I'm adding a new resource with a modified regular_patch_set_index [2] (Credit to Keithen for showing this approach).

I can see that the resulting ore patches do have the same spots from their underlying spot_noise functions [3], with different sizings.
However, if I try to generate both at the same time, it looks like the two spot_noise functions are inadvertently coupled together:
(The added infinite coal is pink, the normal coal is still black)
Factorio_Repro_Size_Slide.gif
Factorio_Repro_Size_Slide.gif (90.26 KiB) Viewed 43 times
Factorio_Repro_Frequency_Slide.gif
Factorio_Repro_Frequency_Slide.gif (672.26 KiB) Viewed 43 times
I would expect that these would be placed separately, with differing frequencies producing some patches of only one of them, and the sizes controlling how big each of them is.

The autoplace expressions look like this:

Code: Select all

resource.coal.autoplace:
{
  "order": "b",
  "probability_expression": "(var('control:coal:size') > 0) * (clamp(var('default-coal-patches'), 0, 1))",
  "richness_expression": "(var('control:coal:size') > 0) * (1*var('control:coal:richness')*(var('default-coal-patches'))*max((1000+distance)/2600,1))"
}

resource.infinite-coal.autoplace:
{
  "order": "a",
  "probability_expression": "(var('control:infinite-coal:size') > 0) * (clamp(var('default-infinite-coal-patches'), 0, 1))",
  "richness_expression": "(var('control:infinite-coal:size') > 0) * (1*var('control:infinite-coal:richness')*(var('default-infinite-coal-patches'))*max((1000+distance)/2600,1))"
}
The corresponding noise expressions look like this (whitespace added for readability):

Code: Select all

noise-expression.default-coal-patches.expression:
"resource_autoplace_all_patches{
    base_density = 8,
    base_spots_per_km2 = 2.5,
    candidate_spot_count = 21,
    frequency_multiplier = var('control:coal:frequency'),
    has_starting_area_placement = 1,
    random_spot_size_minimum = 0.25,
    random_spot_size_maximum = 2,
    regular_blob_amplitude_multiplier = 0.125,
    regular_patch_set_count = default_regular_resource_patch_set_count,
    regular_patch_set_index = 2,
    regular_rq_factor = 0.1,
    seed1 = 100,
    size_multiplier = var('control:coal:size'),
    starting_blob_amplitude_multiplier = 0.125,
    starting_patch_set_count = default_starting_resource_patch_set_count,
    starting_patch_set_index = 2,
    starting_rq_factor = 0.15714285714286
}"


noise-expression.default-infinite-coal-patches.expression:
"resource_autoplace_all_patches{
    base_density = 4,
    base_spots_per_km2 = 2.5,
    candidate_spot_count = 21,
    frequency_multiplier = var('control:infinite-coal:frequency'),
    has_starting_area_placement = 0,
    random_spot_size_minimum = 0.25,
    random_spot_size_maximum = 2,
    regular_blob_amplitude_multiplier = 0.125,
    regular_patch_set_count = default_regular_resource_patch_set_count,
    regular_patch_set_index = 2,
    regular_rq_factor = 0.1,
    seed1 = 100,
    size_multiplier = var('control:infinite-coal:size'),
    starting_blob_amplitude_multiplier = 0.125,
    starting_patch_set_count = default_starting_resource_patch_set_count,
    starting_patch_set_index = 0,
    starting_rq_factor = 0.14285714285714
}"


[1]:
Reproducer can be found here. Factorio version used is 2.0.72

[2]:
The regular_patch_set_index is retrieved from the autoplace_sets global variable here. To get the normal and infinite resource to share indices, I modify this index before calling the resource_autoplace_settings function.
This is to make sure the spot_noise yields the same spots for both ores:
https://github.com/wube/factorio-data/b ... ce.lua#L89

[3]:
With the regular_patch_set_index adjusted, the two spot_noise functions share the four parameters needed to generate identical spots according to https://lua-api.factorio.com/2.0.72/aux ... spot_noise - namely the seed0, seed1, region_size and suggested_minimum_candidate_point_spacing parameters.
Post Reply

Return to “Bug Reports”