How to Compose Good NoiseExpression / probability_expression

Place to report issues and suggest improvements to the API documentation.
Loup&Snoop
Inserter
Inserter
Posts: 48
Joined: Wed Dec 04, 2024 4:33 am
Contact:

How to Compose Good NoiseExpression / probability_expression

Post by Loup&Snoop »

One thing that has always sucked for me is figuring out map generation. The documentation currently explains how each variable works, and how you're supposed to put things in (https://lua-api.factorio.com/latest/typ ... ssion.html). The thing I really struggled with was:

"How do I compose an actually functional probablity_expression?"

I eventually gave up for my mod because I could not figure it out, and every guess requires restarting factorio. I think this would need more of a tutorial or something, but it is not clear to me how I would go about it. Even when I copied expressions from vanilla, their collisions would eventually limit how many different things I could put on a map because they would collide with each other. I look at the noise expressions for vanilla, and (assuming I don't get lost in a morass of following references to functions of functions of functions) the functions that I do see are very complicated.

What would be helpful is a general guide on how to make NoiseExpressions that actually work.
curiosity
Filter Inserter
Filter Inserter
Posts: 683
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: How to Compose Good NoiseExpression / probability_expression

Post by curiosity »

Have you looked at the vanilla ones?
Loup&Snoop
Inserter
Inserter
Posts: 48
Joined: Wed Dec 04, 2024 4:33 am
Contact:

Re: How to Compose Good NoiseExpression / probability_expression

Post by Loup&Snoop »

I have. The issue is that they are fairly complex OR behind functions of functions of functions of functions across files. I just don't understand the process by looking at the finished product. Maybe I'm just bad, but I have no idea how this places rocks:

Code: Select all

autoplace =
    {
      control = "rocks",
      order = "a[doodad]-a[rock]-c[medium]",
      probability_expression = "multiplier * control * (region_box + rock_density - penalty)",
      local_expressions =
      {
        multiplier = 0.4,
        penalty = 1.4,
        region_box = "range_select_base(moisture, 0.35, 1, 0.2, -10, 0)",
        control = "control:rocks:size"
      }
This one isn't even mathematically complex like some others (which can be a 6-line string of named noise functions with clamps etc). But I don't understand how to interpret this enough to compose my own noise function to place things. Nor it is clear how I would go about making a second one of these in a way that avoids collisions. Even with the auxiliary docs (https://lua-api.factorio.com/latest/aux ... sions.html) I do not know how to read the above autoplace specification.

From the documentation, I understand the rules. I understand: this is the prototype, here's the format, the string goes here, here's how the string is parsed, etc... The documentation explains the rules. What I do NOT understand is how to actually compose a proper NoiseExpression to get some sort of desired result.

A good example would be a mini-tutorial (and this may make more sense in the Wiki):
-Here's how you make a circle of rocks.
-Now let's make random circles of rocks that repeat randomly across the map.
-Let's make the circle of rocks less dense.
-Now lets have TWO types of rocks with different functions that can each go into these circles....

Something like that, so I understand HOW I'm supposed to compose noise functions with the pieces we have.
Post Reply

Return to “Documentation Improvement Requests”