<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.factorio.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=TOGoS</id>
	<title>Official Factorio Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.factorio.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=TOGoS"/>
	<link rel="alternate" type="text/html" href="https://wiki.factorio.com/Special:Contributions/TOGoS"/>
	<updated>2026-08-20T15:03:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=176644</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=176644"/>
		<updated>2019-10-24T01:58:17Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Note utility of literal-expression&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-boolean ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same boolean value (true or false) every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Useful mostly for passing expressions (to be evaluated later) to the &#039;&#039;&#039;spot-noise&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== array-construction ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;value_expressions&#039;&#039;&#039; property should be a list of expressions,&lt;br /&gt;
each of which will be evaluated to come up with the corresponding value&lt;br /&gt;
in the resulting array.&lt;br /&gt;
&lt;br /&gt;
Can be used to construct map positions ([x, y]) and map position lists ([[x0,y0], [y1,y1], ...]).&lt;br /&gt;
&lt;br /&gt;
=== procedure-delimiter ===&lt;br /&gt;
&lt;br /&gt;
Evaluates and returns the value of its &#039;&#039;&#039;expression&#039;&#039;&#039; property, which is itself an expression.&lt;br /&gt;
&lt;br /&gt;
This hints to the compiler that it should break the subexpression into its own procedure&lt;br /&gt;
so that the result can be re-used in multiple places.&lt;br /&gt;
For instance if you want to re-use the same multioctave noise for determining probability&lt;br /&gt;
of multiple tiles/entities, wrap the multioctave noise expression in a procedure-delimiter.&lt;br /&gt;
Alternatively, make the noise its own [[Prototype/NamedNoiseExpression|NamedNoiseExpression]] and reference it by name, using a variable.&lt;br /&gt;
&lt;br /&gt;
=== if-else-chain ===&lt;br /&gt;
&lt;br /&gt;
Has an &#039;&#039;&#039;arguments&#039;&#039;&#039; property that is a list of condition-result expression pairs followed by a default result expression, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;if-else-chain&amp;quot;,&lt;br /&gt;
  arguments = {&lt;br /&gt;
    condition1, result1,&lt;br /&gt;
    condition2, result2,&lt;br /&gt;
    ...&lt;br /&gt;
    defaultResult&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of the if-else-chain is the value of the first result expression whose condition expression evaluated to true,&lt;br /&gt;
or the value of the default result (&#039;else&#039;) expression.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: &#039;&#039;&#039;candidate_spot_count = X&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size and candidate_point_count) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
The infinite series of candidate points (of which &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; are actually considered) generated by &#039;&#039;&#039;spot-noise&#039;&#039;&#039; expressions with the same &#039;&#039;&#039;seed0&#039;&#039;&#039;, &#039;&#039;&#039;seed1&#039;&#039;&#039;, &#039;&#039;&#039;region_size&#039;&#039;&#039;, and &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; will be identical.  This allows multiple spot-noise expressions (e.g. for different ore patches) to avoid overlap by using different points from the same list, determined by &#039;&#039;&#039;skip_span&#039;&#039;&#039; and &#039;&#039;&#039;skip_offset&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=176643</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=176643"/>
		<updated>2019-10-24T01:33:58Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Add section on array-construction expressions.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-boolean ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same boolean value (true or false) every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== array-construction ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;value_expressions&#039;&#039;&#039; property should be a list of expressions,&lt;br /&gt;
each of which will be evaluated to come up with the corresponding value&lt;br /&gt;
in the resulting array.&lt;br /&gt;
&lt;br /&gt;
Can be used to construct map positions ([x, y]) and map position lists ([[x0,y0], [y1,y1], ...]).&lt;br /&gt;
&lt;br /&gt;
=== procedure-delimiter ===&lt;br /&gt;
&lt;br /&gt;
Evaluates and returns the value of its &#039;&#039;&#039;expression&#039;&#039;&#039; property, which is itself an expression.&lt;br /&gt;
&lt;br /&gt;
This hints to the compiler that it should break the subexpression into its own procedure&lt;br /&gt;
so that the result can be re-used in multiple places.&lt;br /&gt;
For instance if you want to re-use the same multioctave noise for determining probability&lt;br /&gt;
of multiple tiles/entities, wrap the multioctave noise expression in a procedure-delimiter.&lt;br /&gt;
Alternatively, make the noise its own [[Prototype/NamedNoiseExpression|NamedNoiseExpression]] and reference it by name, using a variable.&lt;br /&gt;
&lt;br /&gt;
=== if-else-chain ===&lt;br /&gt;
&lt;br /&gt;
Has an &#039;&#039;&#039;arguments&#039;&#039;&#039; property that is a list of condition-result expression pairs followed by a default result expression, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;if-else-chain&amp;quot;,&lt;br /&gt;
  arguments = {&lt;br /&gt;
    condition1, result1,&lt;br /&gt;
    condition2, result2,&lt;br /&gt;
    ...&lt;br /&gt;
    defaultResult&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of the if-else-chain is the value of the first result expression whose condition expression evaluated to true,&lt;br /&gt;
or the value of the default result (&#039;else&#039;) expression.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: &#039;&#039;&#039;candidate_spot_count = X&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size and candidate_point_count) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
The infinite series of candidate points (of which &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; are actually considered) generated by &#039;&#039;&#039;spot-noise&#039;&#039;&#039; expressions with the same &#039;&#039;&#039;seed0&#039;&#039;&#039;, &#039;&#039;&#039;seed1&#039;&#039;&#039;, &#039;&#039;&#039;region_size&#039;&#039;&#039;, and &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; will be identical.  This allows multiple spot-noise expressions (e.g. for different ore patches) to avoid overlap by using different points from the same list, determined by &#039;&#039;&#039;skip_span&#039;&#039;&#039; and &#039;&#039;&#039;skip_offset&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176600</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176600"/>
		<updated>2019-10-15T21:33:10Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Put &amp;#039;control&amp;#039; under &amp;#039;general properties&amp;#039; and alphabetize them&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== General Properties ==&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== default_enabled ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
Indicates whether the thing should be placed even if [http://lua-api.factorio.com/latest/Concepts.html#MapGenSettings MapGenSettings] do not provide frequency/size/richness for it&lt;br /&gt;
(either for the specific prototype of for the control named by AutoplaceSpecification.control).&lt;br /&gt;
&lt;br /&gt;
If true, normal frequency/size/richness (value=1) are used in that case.  Otherwise it is treated as if &#039;none&#039; were selected.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== placement_density ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/uint32]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
For entities and decoratives, how many times to attempt to place on each tile&lt;br /&gt;
(probability and collisions are taken into account each attempt).&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
== Properties for Expression-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
== Properties for Peak-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176599</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176599"/>
		<updated>2019-10-15T21:31:22Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: More info on default_enabled&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== General Properties ==&lt;br /&gt;
&lt;br /&gt;
=== default_enabled ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
Indicates whether the thing should be placed even if [http://lua-api.factorio.com/latest/Concepts.html#MapGenSettings MapGenSettings] do not provide frequency/size/richness for it&lt;br /&gt;
(either for the specific prototype of for the control named by AutoplaceSpecification.control).&lt;br /&gt;
&lt;br /&gt;
If true, normal frequency/size/richness (value=1) are used in that case.  Otherwise it is treated as if &#039;none&#039; were selected.&lt;br /&gt;
&lt;br /&gt;
=== placement_density ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/uint32]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
For entities and decoratives, how many times to attempt to place on each tile&lt;br /&gt;
(probability and collisions are taken into account each attempt).&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
== Properties for Expression-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
== Properties for Peak-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176598</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176598"/>
		<updated>2019-10-15T21:21:19Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Types/bool, not Types/boolean&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== General Properties ==&lt;br /&gt;
&lt;br /&gt;
=== default_enabled ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/bool]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
=== placement_density ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/uint32]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
For entities and decoratives, how many times to attempt to place on each tile&lt;br /&gt;
(probability and collisions are taken into account each attempt).&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
== Properties for Expression-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
== Properties for Peak-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176597</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176597"/>
		<updated>2019-10-15T21:19:53Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Document &amp;#039;placement_density&amp;#039; and break expression and peak properties into different sections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== General Properties ==&lt;br /&gt;
&lt;br /&gt;
=== default_enabled ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/boolean]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: true&lt;br /&gt;
&lt;br /&gt;
=== placement_density ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/uint32]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
For entities and decoratives, how many times to attempt to place on each tile&lt;br /&gt;
(probability and collisions are taken into account each attempt).&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
== Properties for Expression-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
== Properties for Peak-based AutoplaceSpecifications ==&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176593</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176593"/>
		<updated>2019-10-15T19:40:12Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: /* placement_density */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== placement_density ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/uint32]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
For entities and decoratives, how many times to attempt to place on each tile&lt;br /&gt;
(probability and collisions are taken into account each attempt).&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176592</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176592"/>
		<updated>2019-10-15T19:39:46Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: placement_density&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== placement_density ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[[Types/uint32]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
For entities and decoratives, how many times to attempt to place on each tile&lt;br /&gt;
(probability and collisions are taken into account each attempt).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176591</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176591"/>
		<updated>2019-10-15T19:33:15Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: /* General structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability (of placement on any given tile) and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176590</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176590"/>
		<updated>2019-10-15T19:32:34Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: /* General structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
&lt;br /&gt;
Autoplace specification describe conditions for placing tiles, entities, and decoratives during surface generation.&lt;br /&gt;
Probability of placement and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176589</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=176589"/>
		<updated>2019-10-15T19:31:49Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Reword to indicate either peaks or expressions can be used&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
Autoplace specification describe conditions for placing the entity and several parameters.&lt;br /&gt;
Probability of placement and richness (which has different meaning depending on the thing being placed)&lt;br /&gt;
can be defined either in terms of a set of peaks, or using explicit expressions.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot;, &amp;quot;neutral&amp;quot;, or a custom force name. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=174308</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=174308"/>
		<updated>2019-07-12T22:13:07Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Fix some tix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-boolean ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same boolean value (true or false) every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== procedure-delimiter ===&lt;br /&gt;
&lt;br /&gt;
Evaluates and returns the value of its &#039;&#039;&#039;expression&#039;&#039;&#039; property, which is itself an expression.&lt;br /&gt;
&lt;br /&gt;
This hints to the compiler that it should break the subexpression into its own procedure&lt;br /&gt;
so that the result can be re-used in multiple places.&lt;br /&gt;
For instance if you want to re-use the same multioctave noise for determining probability&lt;br /&gt;
of multiple tiles/entities, wrap the multioctave noise expression in a procedure-delimiter.&lt;br /&gt;
Alternatively, make the noise its own [[Prototype/NamedNoiseExpression|NamedNoiseExpression]] and reference it by name, using a variable.&lt;br /&gt;
&lt;br /&gt;
=== if-else-chain ===&lt;br /&gt;
&lt;br /&gt;
Has an &#039;&#039;&#039;arguments&#039;&#039;&#039; property that is a list of condition-result expression pairs followed by a default result expression, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;if-else-chain&amp;quot;,&lt;br /&gt;
  arguments = {&lt;br /&gt;
    condition1, result1,&lt;br /&gt;
    condition2, result2,&lt;br /&gt;
    ...&lt;br /&gt;
    defaultResult&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of the if-else-chain is the value of the first result expression whose condition expression evaluated to true,&lt;br /&gt;
or the value of the default result (&#039;else&#039;) expression.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: &#039;&#039;&#039;candidate_spot_count = X&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size and candidate_point_count) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
The infinite series of candidate points (of which &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; are actually considered) generated by &#039;&#039;&#039;spot-noise&#039;&#039;&#039; expressions with the same &#039;&#039;&#039;seed0&#039;&#039;&#039;, &#039;&#039;&#039;seed1&#039;&#039;&#039;, &#039;&#039;&#039;region_size&#039;&#039;&#039;, and &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; will be identical.  This allows multiple spot-noise expressions (e.g. for different ore patches) to avoid overlap by using different points from the same list, determined by &#039;&#039;&#039;skip_span&#039;&#039;&#039; and &#039;&#039;&#039;skip_offset&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=174307</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=174307"/>
		<updated>2019-07-12T22:10:50Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Update about suggested_minimum_candidate_point_spacing and how to generate identical point lists&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-boolean ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same boolean value (true or false) every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== procedure-delimiter ===&lt;br /&gt;
&lt;br /&gt;
Evaluates and returns the value of its &#039;&#039;&#039;expression&#039;&#039;&#039; property, which is itself an expression.&lt;br /&gt;
&lt;br /&gt;
This hints to the compiler that it should break the subexpression into its own procedure&lt;br /&gt;
so that the result can be re-used in multiple places.&lt;br /&gt;
For instance if you want to re-use the same multioctave noise for determining probability&lt;br /&gt;
of multiple tiles/entities, wrap the multioctave noise expression in a procedure-delimiter.&lt;br /&gt;
Alternatively, make the noise its own [[Prototype/NamedNoiseExpression|NamedNoiseExpression]] and reference it by name, using a variable.&lt;br /&gt;
&lt;br /&gt;
=== if-else-chain ===&lt;br /&gt;
&lt;br /&gt;
Has an &#039;&#039;&#039;arguments&#039;&#039;&#039; property that is a list of condition-result expression pairs followed by a default result expression, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;if-else-chain&amp;quot;,&lt;br /&gt;
  arguments = {&lt;br /&gt;
    condition1, result1,&lt;br /&gt;
    condition2, result2,&lt;br /&gt;
    ...&lt;br /&gt;
    defaultResult&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of the if-else-chain is the value of the first result expression whose condition expression evaluated to true,&lt;br /&gt;
or the value of the default result (&#039;else&#039;) expression.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size and candidate_point_count) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
The infinite series of candidate points (of which &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; are actually considered) generated by &#039;&#039;&#039;spot-noise&#039;&#039;&#039; expressions with the same &#039;&#039;&#039;seed0&#039;&#039;&#039;, &#039;&#039;&#039;seed1&#039;&#039;&#039;, &#039;&#039;&#039;region_size&#039;&#039;&#039;, and &#039;&#039;&#039;suggested_minimum_candidate_point_spacing&#039;&#039;&#039; will be identical.  This allows multiple spot-noise expressions (e.g. for different ore patches) to avoid overlap by using different points from the same list, determined by &#039;&#039;&#039;skip_span&#039;&#039;&#039; and &#039;&#039;&#039;skip_offset&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=173519</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=173519"/>
		<updated>2019-05-23T02:13:48Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; the if-else-chain example code block&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-boolean ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same boolean value (true or false) every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== procedure-delimiter ===&lt;br /&gt;
&lt;br /&gt;
Evaluates and returns the value of its &#039;&#039;&#039;expression&#039;&#039;&#039; property, which is itself an expression.&lt;br /&gt;
&lt;br /&gt;
This hints to the compiler that it should break the subexpression into its own procedure&lt;br /&gt;
so that the result can be re-used in multiple places.&lt;br /&gt;
For instance if you want to re-use the same multioctave noise for determining probability&lt;br /&gt;
of multiple tiles/entities, wrap the multioctave noise expression in a procedure-delimiter.&lt;br /&gt;
Alternatively, make the noise its own [[Prototype/NamedNoiseExpression|NamedNoiseExpression]] and reference it by name, using a variable.&lt;br /&gt;
&lt;br /&gt;
=== if-else-chain ===&lt;br /&gt;
&lt;br /&gt;
Has an &#039;&#039;&#039;arguments&#039;&#039;&#039; property that is a list of condition-result expression pairs followed by a default result expression, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;if-else-chain&amp;quot;,&lt;br /&gt;
  arguments = {&lt;br /&gt;
    condition1, result1,&lt;br /&gt;
    condition2, result2,&lt;br /&gt;
    ...&lt;br /&gt;
    defaultResult&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of the if-else-chain is the value of the first result expression whose condition expression evaluated to true,&lt;br /&gt;
or the value of the default result (&#039;else&#039;) expression.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=173518</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=173518"/>
		<updated>2019-05-23T02:13:01Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Document procedure-delimiter and if-else-chain expression types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-boolean ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same boolean value (true or false) every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== procedure-delimiter ===&lt;br /&gt;
&lt;br /&gt;
Evaluates and returns the value of its &#039;&#039;&#039;expression&#039;&#039;&#039; property, which is itself an expression.&lt;br /&gt;
&lt;br /&gt;
This hints to the compiler that it should break the subexpression into its own procedure&lt;br /&gt;
so that the result can be re-used in multiple places.&lt;br /&gt;
For instance if you want to re-use the same multioctave noise for determining probability&lt;br /&gt;
of multiple tiles/entities, wrap the multioctave noise expression in a procedure-delimiter.&lt;br /&gt;
Alternatively, make the noise its own [[Prototype/NamedNoiseExpression|NamedNoiseExpression]] and reference it by name, using a variable.&lt;br /&gt;
&lt;br /&gt;
=== if-else-chain ===&lt;br /&gt;
&lt;br /&gt;
Has an &#039;&#039;&#039;arguments&#039;&#039;&#039; property that is a list of condition-result expression pairs followed by a default result expression, like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;if-else-chain&amp;quot;,&lt;br /&gt;
  arguments = {&lt;br /&gt;
    condition1, result1,&lt;br /&gt;
    condition2, result2,&lt;br /&gt;
    ...&lt;br /&gt;
    defaultResult&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result of the if-else-chain is the value of the first result expression whose condition expression evaluated to true,&lt;br /&gt;
or the value of the default result (&#039;else&#039;) expression.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=173517</id>
		<title>Types/AutoplaceSpecification</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/AutoplaceSpecification&amp;diff=173517"/>
		<updated>2019-05-23T01:27:50Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Note probability_expression and richness_expression&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Autoplace specification is used to determine which entities are placed when generating map.&lt;br /&gt;
Currently it is used for enemy bases, resources and other entities (trees, fishes, ...).&lt;br /&gt;
&lt;br /&gt;
== General structure ==&lt;br /&gt;
Autoplace specification consists of a set of peaks that describe conditions for placing the entity and&lt;br /&gt;
several parameters.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
=== probability_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated at every point on the map to determine probability.&lt;br /&gt;
If left blank, probability is determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
=== richness_expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
If specified, provides a noise expression that will be evaluated to determine richness.&lt;br /&gt;
&lt;br /&gt;
If probability_expression is specified and richness_expression is not,&lt;br /&gt;
then probability_expression will be used as the richness expression.&lt;br /&gt;
&lt;br /&gt;
If neither are specified, then probability and richness are both determined by the &#039;peaks&#039; system based on the properties listed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== sharpness ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
[[File:sharpness.png|thumb|Example of sharpness filter with value 0.5]]&lt;br /&gt;
&lt;br /&gt;
Parameter of the sharpness filter for post-processing probability of entity placement. Value of 0 disables the filter, with value 1, the filter is a step function centered around 0.5.&lt;br /&gt;
See [[#Probability_Calculation|Probability Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_probability ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Multiplier for output of the sharpness filter.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== tile_restriction ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of specifications, see below&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: empty list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Restricts surfaces or transition the entity can appear on.&lt;br /&gt;
&lt;br /&gt;
Contains list of specifications, each specification is a single [[Types/string]] with the ID of an allowed tile, or a &lt;br /&gt;
list of two [[Types/string]]s for entities allowed on transitions.&lt;br /&gt;
&lt;br /&gt;
=== richness_base ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_multiplier_distance_bonus ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus to richness multiplier per tile of distance from starting point.&lt;br /&gt;
See [[#Richness_Calculation]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== control ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/AutoplaceControl|autoplace control]] that applies to this entity.&lt;br /&gt;
&lt;br /&gt;
=== force ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;neutral&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.8.0&lt;br /&gt;
&lt;br /&gt;
Force of the placed entity. One of &amp;quot;enemy&amp;quot;, &amp;quot;player&amp;quot; or &amp;quot;neutral&amp;quot;. Only matters for EntityWithForce or EntityWithOwner.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.0&lt;br /&gt;
&lt;br /&gt;
Order for placing the entity (has no effect when placing tiles). Entities whose order compares less are placed earlier (this influences placing multiple entities which collide with itself), from entities with equal order string only one with the highest probability is placed.&lt;br /&gt;
&lt;br /&gt;
=== size_control_multiplier ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Magic. Based on sum of influences of noises.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.9.2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Until&#039;&#039;&#039;: 0.12.x&lt;br /&gt;
&lt;br /&gt;
This value times the size control setting is added to influence right before sharpness filter.&lt;br /&gt;
Very small has a multiplier of -1, very big has 1.5.&lt;br /&gt;
This value is replaced by ```coverage``` parameter in 0.13.0.&lt;br /&gt;
&lt;br /&gt;
=== random_probability_penalty ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
A random value between 0 and this number is subtracted from a probability after sharpness filter.&lt;br /&gt;
Only works for entities.&lt;br /&gt;
See [[#Probability_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== peaks ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: list of [[#Autoplace Peaks]]&lt;br /&gt;
&lt;br /&gt;
If this property is missing, then the whole autoplace specification is interpreted as a single peak&lt;br /&gt;
&lt;br /&gt;
=== coverage ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: Calculated from existing peaks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.0&lt;br /&gt;
&lt;br /&gt;
Sets a fraction of surface that should be covered by this item.&lt;br /&gt;
&lt;br /&gt;
Internally this adds an additive influence modifier, so that expected fraction of tiles where total influence &amp;gt; 0.5 (the threshold for sharpness filter) equals the parameter.&lt;br /&gt;
&lt;br /&gt;
Because of the autoplace system&#039;s complexity, this is only accurate on simple rules and does some simplification on the more complex ones:&lt;br /&gt;
* There is always just one combination of tile properties (see [[#Dimensions]]) for which the coverage is calculated. This combination is given by a first *_optimal value encountered of each type other than starting_area and tier_from_start. Starting_area value is fixed to 0 and tier_from_start to 4.&lt;br /&gt;
* min_influence and max_influence are completely ignored.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_amount ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
If this value is non zero, influence of this entity will be calculated differently in starting area:&lt;br /&gt;
For each entity with this parameter a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
The central tile of this blob will have approximately amount of resources selected by this value.&lt;br /&gt;
&lt;br /&gt;
=== starting_area_size ===&lt;br /&gt;
&#039;&#039;&#039; Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 10&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since&#039;&#039;&#039;: 0.13.10&lt;br /&gt;
&lt;br /&gt;
See [[#starting_area_amount]].&lt;br /&gt;
Controls approximate radius of the blob in tiles.&lt;br /&gt;
&lt;br /&gt;
== Autoplace Peaks ==&lt;br /&gt;
&lt;br /&gt;
=== influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Influence multiplier.&lt;br /&gt;
See [[#Influence_Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== min_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: min double&lt;br /&gt;
&lt;br /&gt;
Minimal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== max_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Maximal influence (after all calculations) of current peak.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== richness_influence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Bonus for influence multiplier when calculating richness.&lt;br /&gt;
See [[#Influence Calculation]].&lt;br /&gt;
&lt;br /&gt;
=== noise_layer ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ID of [[Prototype/NoiseLayer|noise layer]] to use for this peak.&lt;br /&gt;
If empty, then no noise is added to this peak.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_persistence ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0.5&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Min&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Max&#039;&#039;&#039;: 1&lt;br /&gt;
&lt;br /&gt;
Persistence of the noise.&lt;br /&gt;
See [[#Noise]].&lt;br /&gt;
&lt;br /&gt;
=== noise_octaves_difference ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/int]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Difference between number of octaves of the world and of the noise.&lt;br /&gt;
See [[#Noise]]&lt;br /&gt;
&lt;br /&gt;
=== *_optimal ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Optimal value of a tile property. If the property is close to this value, peak influence is 1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: 0&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that is still considered optimal.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_max_range ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
Distance from the optimal parameters that get influence of -1.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
=== *_top_property_limit ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/double]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default&#039;&#039;&#039;: max double&lt;br /&gt;
&lt;br /&gt;
Limit distance from the optimum on a single (positive) side. This is pure magic.&lt;br /&gt;
See [[#Dimensions]].&lt;br /&gt;
&lt;br /&gt;
== Dimensions ==&lt;br /&gt;
Peaks may reference a number of tile properties, specifying range of optimal values of the property&lt;br /&gt;
and a range over which it is interpolated to no effect.&lt;br /&gt;
&lt;br /&gt;
Currently the properties are:&lt;br /&gt;
* starting_area_weight -- Number from 1 (inside starting area) to 0 (not influenced by starting area).&lt;br /&gt;
* roughness -- a number between -1.5 and 1.5 which describe roughness of the terrain. In 0.7.2 roughness is visible only on the edges of lakes (smooth vs jagged).&lt;br /&gt;
* elevation -- elevation of the terrain, up to 5000. Values smaller than 0 mean under water (elevation &amp;lt; 0 doesn&#039;t imply water tile, though)&lt;br /&gt;
* water -- amount of available water on tile. Very simple dependence on elevation for now.&lt;br /&gt;
* temperature -- average temperature on tile. Depends on elevation and some noise.&lt;br /&gt;
* tier_from_start -- Distance from start in starting area sizes, rounded to integers.&lt;br /&gt;
&lt;br /&gt;
You can see sheets on the generation of trees, doodads, biomes, water and tiles on this page: [[AutoplaceSheets]]&lt;br /&gt;
&lt;br /&gt;
== Influence Calculation ==&lt;br /&gt;
&lt;br /&gt;
There are two possible modes in which influence is calculated.&lt;br /&gt;
By default influence is calculated as a sum of influences of peaks (see next paragraph).&lt;br /&gt;
When [[#starting_area_amount]] parameter is non zero a position in starting area is selected and a blob is placed centered on this position.&lt;br /&gt;
Influence is then a maximum of the default calculated value and a value obtained from this blob.&lt;br /&gt;
&lt;br /&gt;
Influence of a peak is obtained by calculating a distance from each of its dimensions and sum of these individual distances is used as a distance from optimal conditions.&lt;br /&gt;
Based on this distance a peak gets influence between -1 and 1, which is then multiplied&lt;br /&gt;
by the noise function, if it is specified, and by the [[#influence|influence]] constant (or by [[#influence|influence]] + [[#richness_influence|richness_influence]]&lt;br /&gt;
if calculating richness).&lt;br /&gt;
Finally this value is clamped to a range between [[#min_influence|min_influence]] and [[#max_influence|max_influence]].&lt;br /&gt;
&lt;br /&gt;
== Probability_Calculation ==&lt;br /&gt;
Probability of placing an entity at a given position is calculated as a sum of influences plus a [[#size_control_multiplier|bonus for autoplace control]], passed through a [[#sharpness|sharpening filter]], multiplied by [[#max_probability|max_probability]] and finally a random value gets subtracted.&lt;br /&gt;
&lt;br /&gt;
max_probability * sharpness_filter(sum of influences + size modifier from GUI) - random(0, random_probability_penalty)&lt;br /&gt;
&lt;br /&gt;
== Richness_Calculation ==&lt;br /&gt;
If an entity is to be placed at a position and it a resource or a part of an enemy base, then richness is calculated in the next step.&lt;br /&gt;
as sum of influences * ([[#richness_multiplier|richness_multiplier]] + distance * [[#richness_multiplier_distance_bonus|richness_multiplier_distance_bonus]]) + [[#richness_base|richness_base]].&lt;br /&gt;
&lt;br /&gt;
Note, that when calculating richness, influences of individual peaks use [[#richness_influence|richness_influence]] bonus.&lt;br /&gt;
&lt;br /&gt;
== Noise ==&lt;br /&gt;
A peak may have a noise multiplied with its influence.&lt;br /&gt;
Noise used is a 2D multioctave perlin noise ( http://freespace.virgin.net/hugo.elias/models/m_perlin.htm ).&lt;br /&gt;
Range of the noise is approximately from -1.5 to 1.5.&lt;br /&gt;
&lt;br /&gt;
Factorio uses up to 256 different (non correlated) layers of perlin noise, a noise layer has to be defined as a prototype before use (see [[Prototype/NoiseLayer]]).&lt;br /&gt;
&lt;br /&gt;
Intended use is to have noise layers separate for different types of objects that might appear (trees vs dry_trees vs enemy-bases).&lt;br /&gt;
Also it has proven useful not to mix peaks containing noise with peaks referencing tile properties.&lt;br /&gt;
&lt;br /&gt;
== Controls ==&lt;br /&gt;
If the autoplace specification has a [[#control|control]] selected, then its influence is affected by the row in map generator gui.&lt;br /&gt;
Autoplace controls must be defined before use, see [[Prototype/AutoplaceControl]].&lt;br /&gt;
&lt;br /&gt;
* Frequency -- If frequency is set to low, then it increases number of octaves for all noises in this specification&lt;br /&gt;
* Size -- Set to large adds a bonus to all the final influence, also very slightly increases number of octaves&lt;br /&gt;
* Richness -- Adds a simple multiplier to richness.&lt;br /&gt;
&lt;br /&gt;
In case you are wondering why we can &amp;quot;very slightly increase number of octaves&amp;quot; and not just add whole octaves, it is because we sacrificed a goat to gods of computer graphics and to Ken Perlin in particular.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=173516</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=173516"/>
		<updated>2019-05-22T21:18:34Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Alternate expressions can be made available in the map generator GUI by blah blah blah&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
Prototype type: &#039;&#039;&#039;noise-expression&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A [[Types/NoiseExpression]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
e.g. the &amp;quot;elevation&amp;quot; expression is used to calculate elevation for every point on a map.&lt;br /&gt;
&lt;br /&gt;
[http://lua-api.factorio.com/latest/Concepts.html#MapGenSettings MapGenSettings]&lt;br /&gt;
can override which named expression is used to calculate a given property by having an entry in&lt;br /&gt;
&amp;lt;code&amp;gt;property_expression_names&amp;lt;/code&amp;gt;.  e.g. &amp;lt;code&amp;gt;elevation = &amp;quot;0.16-elevation&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
Alternate expressions can be made available in the map generator GUI by setting their&lt;br /&gt;
&amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt; to the name of the property they should override.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[Prototype]].&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
=== intended_property ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Names the property that this expression is intended to provide a value for, if any.&lt;br /&gt;
This will make the expression show up as an option in the map generator GUI, unless it is the only expression with that&lt;br /&gt;
intended property, in which case it will be hidden and selected by default.&lt;br /&gt;
&lt;br /&gt;
For example if a noise expression is intended to be used as an alternative temperature generator, &amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt; should be &amp;quot;temperature&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
Used to order alternative expressions in the map generator GUI.&lt;br /&gt;
For a given property (e.g. &#039;temperature&#039;), the NamedNoiseExpression with that property&#039;s name as its &amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt;&lt;br /&gt;
with the lowest order will be chosen as the default in the GUI.&lt;br /&gt;
&lt;br /&gt;
If no order is specified, it defaults to &amp;quot;2000&amp;quot; if the property name matches the expression name&lt;br /&gt;
(making it the &#039;technical default&#039; generator for the property if none is specified in MapGenSettings),&lt;br /&gt;
or &amp;quot;3000&amp;quot; otherwise.  A generator defined with an order less than &amp;quot;2000&amp;quot; but with a unique name&lt;br /&gt;
can thereby override the default generator used when creating a new map through the GUI without automatically overriding&lt;br /&gt;
the &#039;technical default&#039; generator, which is probably used by existing maps.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=173515</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=173515"/>
		<updated>2019-05-22T21:17:15Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Note that intended_property is how you make expressions show up in the map generator GUI&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
Prototype type: &#039;&#039;&#039;noise-expression&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A [[Types/NoiseExpression]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
e.g. the &amp;quot;elevation&amp;quot; expression is used to calculate elevation for every point on a map.&lt;br /&gt;
&lt;br /&gt;
[http://lua-api.factorio.com/latest/Concepts.html#MapGenSettings MapGenSettings]&lt;br /&gt;
can override which named expression is used to calculate a given property by having an entry in&lt;br /&gt;
&amp;lt;code&amp;gt;property_expression_names&amp;lt;/code&amp;gt;.  e.g. &amp;lt;code&amp;gt;elevation = &amp;quot;0.16-elevation&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[Prototype]].&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
=== intended_property ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Names the property that this expression is intended to provide a value for, if any.&lt;br /&gt;
This will make the expression show up as an option in the map generator GUI, unless it is the only expression with that&lt;br /&gt;
intended property, in which case it will be hidden and selected by default.&lt;br /&gt;
&lt;br /&gt;
For example if a noise expression is intended to be used as an alternative temperature generator, &amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt; should be &amp;quot;temperature&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
Used to order alternative expressions in the map generator GUI.&lt;br /&gt;
For a given property (e.g. &#039;temperature&#039;), the NamedNoiseExpression with that property&#039;s name as its &amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt;&lt;br /&gt;
with the lowest order will be chosen as the default in the GUI.&lt;br /&gt;
&lt;br /&gt;
If no order is specified, it defaults to &amp;quot;2000&amp;quot; if the property name matches the expression name&lt;br /&gt;
(making it the &#039;technical default&#039; generator for the property if none is specified in MapGenSettings),&lt;br /&gt;
or &amp;quot;3000&amp;quot; otherwise.  A generator defined with an order less than &amp;quot;2000&amp;quot; but with a unique name&lt;br /&gt;
can thereby override the default generator used when creating a new map through the GUI without automatically overriding&lt;br /&gt;
the &#039;technical default&#039; generator, which is probably used by existing maps.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=173514</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=173514"/>
		<updated>2019-05-22T21:15:05Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Talk about intended_property and order&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
Prototype type: &#039;&#039;&#039;noise-expression&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A [[Types/NoiseExpression]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
e.g. the &amp;quot;elevation&amp;quot; expression is used to calculate elevation for every point on a map.&lt;br /&gt;
&lt;br /&gt;
[http://lua-api.factorio.com/latest/Concepts.html#MapGenSettings MapGenSettings]&lt;br /&gt;
can override which named expression is used to calculate a given property by having an entry in&lt;br /&gt;
&amp;lt;code&amp;gt;property_expression_names&amp;lt;/code&amp;gt;.  e.g. &amp;lt;code&amp;gt;elevation = &amp;quot;0.16-elevation&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[Prototype]].&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;br /&gt;
&lt;br /&gt;
== Optional properties ==&lt;br /&gt;
=== intended_property ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Names the property that this expression is intended to provide a value for, if any.&lt;br /&gt;
&lt;br /&gt;
For example if a noise expression is intended to be used as an alternative temperature generator, &amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt; should be &amp;quot;temperature&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== order ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/Order]]&lt;br /&gt;
&lt;br /&gt;
Used to order alternative expressions in the map generator GUI.&lt;br /&gt;
For a given property (e.g. &#039;temperature&#039;), the NamedNoiseExpression with that property&#039;s name as its &amp;lt;code&amp;gt;intended_property&amp;lt;/code&amp;gt;&lt;br /&gt;
with the lowest order will be chosen as the default in the GUI.&lt;br /&gt;
&lt;br /&gt;
If no order is specified, it defaults to &amp;quot;2000&amp;quot; if the property name matches the expression name&lt;br /&gt;
(making it the &#039;technical default&#039; generator for the property if none is specified in MapGenSettings),&lt;br /&gt;
or &amp;quot;3000&amp;quot; otherwise.  A generator defined with an order less than &amp;quot;2000&amp;quot; but with a unique name&lt;br /&gt;
can thereby override the default generator used when creating a new map through the GUI without automatically overriding&lt;br /&gt;
the &#039;technical default&#039; generator, which is probably used by existing maps.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=173308</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=173308"/>
		<updated>2019-05-14T19:41:29Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Update about literal-object to indicate the actual use case.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the argument&lt;br /&gt;
of the &#039;&#039;&#039;autoplace-probability&#039;&#039;&#039; function (where the &#039;literal object&#039; is an [[Types/AutoplaceSpecification|AutoplaceSpecitication]])&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=170231</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=170231"/>
		<updated>2019-03-07T16:51:26Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: There&amp;#039;s no &amp;lt;math&amp;gt; support here, so remove &amp;quot;&amp;lt;/math&amp;gt;&amp;quot; after volume formula&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&#039;&#039;&#039;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=170227</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=170227"/>
		<updated>2019-03-07T16:49:45Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Even random() is actually referrentially transparent, because it takes x, y as seed, so rephrase about that.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a function call with all-constant arguments can be constant-folded (due to [[Wikipedia:Referential_transparency|referential transparency]]), etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&amp;lt;/math&amp;gt;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=169769</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=169769"/>
		<updated>2019-03-01T19:22:52Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Replace 0.16 info with stuff about overriding via MapGenSettings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
Prototype type: &#039;&#039;&#039;noise-expression&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A [[Types/NoiseExpression]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
e.g. the &amp;quot;elevation&amp;quot; expression is used to calculate elevation for every point on a map.&lt;br /&gt;
&lt;br /&gt;
[http://lua-api.factorio.com/latest/Concepts.html#MapGenSettings MapGenSettings]&lt;br /&gt;
can override which named expression is used to calculate a given property by having an entry in&lt;br /&gt;
&amp;lt;code&amp;gt;property_expression_names&amp;lt;/code&amp;gt;.  e.g. &amp;lt;code&amp;gt;elevation = &amp;quot;0.16-elevation&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
Inherits all properties from [[Prototype]].&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169741</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169741"/>
		<updated>2019-03-01T18:03:24Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Link to no togos-example-noise-programs tutorial mod&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;) is [[Wikipedia:Referential_transparency|referentially transparent]] and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&amp;lt;/math&amp;gt;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://togos.github.io/togos-example-noise-programs/ A tutorial on authoring noise functions]&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169215</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169215"/>
		<updated>2019-02-28T00:39:03Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: /* Example definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;) is [[Wikipedia:Referential_transparency|referentially transparent]] and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&amp;lt;/math&amp;gt;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- Makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169214</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169214"/>
		<updated>2019-02-28T00:37:32Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: space after &amp;#039;&amp;#039;&amp;#039;skip-span&amp;#039;&amp;#039;&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;) is [[Wikipedia:Referential_transparency|referentially transparent]] and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039; candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&amp;lt;/math&amp;gt;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- As of 0.17, makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169213</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=169213"/>
		<updated>2019-02-28T00:36:50Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Document the &amp;quot;spot-noise&amp;quot; function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;) is [[Wikipedia:Referential_transparency|referentially transparent]] and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
=== literal-expression ===&lt;br /&gt;
&lt;br /&gt;
Returns the expression represented by its &#039;&#039;&#039;literal-value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
=== spot-noise ===&lt;br /&gt;
&lt;br /&gt;
Generates random conical spots.  The map is divided into square regions, and within each region, candidate points are chosen at random and target density, spot quantity, and radius are calculated for each point (or one of every &#039;&#039;&#039;skip_span&#039;&#039;&#039;candidate points) by configured expressions.  Each spot contributes a quantity to a regional target total (which is the average of sampled target densities times the area of the region) until the total has been reached or a maximum spot count is hit.  The output value of the function is the maximum height of any spot at a given point.&lt;br /&gt;
&lt;br /&gt;
The parameters that provide expressions to be evaluated for each point (all named &#039;&#039;&#039;something_expression&#039;&#039;&#039;) need to actually return expression objects.  &lt;br /&gt;
&lt;br /&gt;
The quantity of the spot is assumed to be the same as its volume.  Since the volume of a cone is &#039;&#039;&#039;pi * radius^2 * height / 3&amp;lt;/math&amp;gt;,&lt;br /&gt;
the height (&#039;peak value&#039;) of any given spot is calculated as &#039;&#039;&#039;3 * quantity / (pi * radius^2)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039; (number)&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; (constant integer) - random seed, part 1 - usually the map seed is used&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; (constant integer) - random seed, part 2 - usually chosen to identify the noise layer&lt;br /&gt;
* &#039;&#039;&#039;region_size&#039;&#039;&#039; (constant integer, default: 512) - width/height of each region&lt;br /&gt;
* &#039;&#039;&#039;skip_offset&#039;&#039;&#039; (constant integer, default: 0) - offset of the first candidate point to use&lt;br /&gt;
* &#039;&#039;&#039;skip_span&#039;&#039;&#039; (constant integer, default: 1) - number of candidate points to skip over after each one used as a spot, including the used one&lt;br /&gt;
* &#039;&#039;&#039;candidate_point_count&#039;&#039;&#039; (constant integer, default:256) - how many candidate points to generate&lt;br /&gt;
* &#039;&#039;&#039;candidate_spot_count&#039;&#039;&#039; (constant integer, default depends on skip_span) - an alternative to candidate_point_count - number of spots to generate: ```candidate_spot_count = X``` is equivalent to &#039;&#039;&#039;candidate_point_count / skip_span = X&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;minimum_candidate_point_spacing&#039;&#039;&#039; (constant number, default depends on region size) - minimum spacing to *try* to achieve while randomly picking points; spot noise may end up placing spots closer than this in crowded regions&lt;br /&gt;
* &#039;&#039;&#039;hard_region_target_quantity&#039;&#039;&#039; (constant boolean, default: true) - whether to place a hard limit on the total quantity in each region by reducing the size of any spot (which will be the last spot chosen) that would put it over the limit.&lt;br /&gt;
* &#039;&#039;&#039;density_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate density at that point&lt;br /&gt;
* &#039;&#039;&#039;spot_quantity_expression&#039;&#039;&#039; (number-returningexpression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s quantity&lt;br /&gt;
* &#039;&#039;&#039;spot_radius_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s radius (this, together with quantity, will determine the spots peak value)&lt;br /&gt;
* &#039;&#039;&#039;spot_favorability_expression&#039;&#039;&#039; (number-returning expression) - an expression that will be evaluated for each candidate spot to calculate the spot&#039;s favorability; spots with higher favorability will be considered first when building the final list of spots for a region&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- As of 0.17, makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=168128</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=168128"/>
		<updated>2019-02-15T02:19:45Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Show better practice of providing an alternate &amp;#039;temperature&amp;#039; generator rather than simply overriding the default.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments. Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression (as opposed to every function just being its own expression type) because function calls all have similar properties -- arguments are themselves expressions, a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;) is [[Wikipedia:Referential_transparency|referentially transparent]] and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;togs-new-temperature-function&amp;quot;,&lt;br /&gt;
    intended_property = &amp;quot;temperature&amp;quot;, -- As of 0.17, makes this available in the &#039;temperature generator&#039; drop-down&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164153</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164153"/>
		<updated>2018-09-02T23:18:27Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Syntax-highlight the literal-object example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;, -- for 0.17; for 0.16 override &amp;quot;default-temperature&amp;quot; instead.&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164150</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164150"/>
		<updated>2018-09-02T21:26:02Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Don&amp;#039;t really need that &amp;quot;e.g.&amp;quot; when the section is called &amp;#039;example&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
To override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;, -- for 0.17; for 0.16 override &amp;quot;default-temperature&amp;quot; instead.&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164149</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164149"/>
		<updated>2018-09-02T21:25:28Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Note and give example of noise.define_noise_function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
Noise expressions can be provided as object literals or built using functions in the built-in &amp;lt;code&amp;gt;noise&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&amp;lt;code&amp;gt;noise.define_noise_function&amp;lt;/code&amp;gt; allows noise expressions to be defined using a shorthand&lt;br /&gt;
that&#039;s a subset of Lua (see [[#Example definition|example definition]] for an example and its literal equivalent).&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
== Example definition ==&lt;br /&gt;
&lt;br /&gt;
e.g. to override the &#039;temperature&#039; named noise expression with one that linearly increases to the southeast:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;, -- for 0.17; for 0.16 override &amp;quot;default-temperature&amp;quot; instead.&lt;br /&gt;
    expression = noise.define_noise_function( function(x,y,tile,map)&lt;br /&gt;
      return (x + y) / 1000&lt;br /&gt;
    end)&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Which is equivalent to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local noise = require(&amp;quot;noise&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
data:extend{&lt;br /&gt;
  {&lt;br /&gt;
    type = &amp;quot;noise-expression&amp;quot;,&lt;br /&gt;
    name = &amp;quot;temperature&amp;quot;,&lt;br /&gt;
    expression = {&lt;br /&gt;
      type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
      function_name = &amp;quot;divide&amp;quot;,&lt;br /&gt;
      arguments = {&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;function-application&amp;quot;,&lt;br /&gt;
          function_name = &amp;quot;add&amp;quot;,&lt;br /&gt;
          arguments = {&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;x&amp;quot;&lt;br /&gt;
            },&lt;br /&gt;
            {&lt;br /&gt;
              type = &amp;quot;variable&amp;quot;,&lt;br /&gt;
              variable_name = &amp;quot;y&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
          type = &amp;quot;literal-number&amp;quot;,&lt;br /&gt;
          literal_value = 1000&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164130</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164130"/>
		<updated>2018-09-01T17:46:50Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: TOGoS moved page User:TOGoS/Types/NoiseExpression to Types/NoiseExpression without leaving a redirect: Now fleshed out enough to be useful!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Types/NoiseExpression =&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164129</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164129"/>
		<updated>2018-09-01T17:26:53Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: &amp;quot;every time&amp;quot; is 2 words&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Types/NoiseExpression =&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same string every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164128</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164128"/>
		<updated>2018-09-01T17:10:49Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Document noise functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Types/NoiseExpression =&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same stringevery time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;br /&gt;
&lt;br /&gt;
Scaling input and output can be accomplished other ways, but are done so commonly&lt;br /&gt;
as to be built into this function for performance reasons.&lt;br /&gt;
&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (named)&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;x&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;y&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;seed0&#039;&#039;&#039; - integer between 0 and 4294967295 (inclusive) used to populate the backing random noise&lt;br /&gt;
* &#039;&#039;&#039;seed1&#039;&#039;&#039; - integer between 0 and 255 (inclusive) used to provide extra randomness when sampling&lt;br /&gt;
* &#039;&#039;&#039;octaves&#039;&#039;&#039; - how many layers of noise at different scales to sum&lt;br /&gt;
* &#039;&#039;&#039;persistence&#039;&#039;&#039; (constant) - how strong is each layer compared to the next larger one&lt;br /&gt;
* &#039;&#039;&#039;input_scale&#039;&#039;&#039; (default: 1) - x and y will be multiplied by this before sampling&lt;br /&gt;
* &#039;&#039;&#039;output_scale&#039;&#039;&#039; (default: 1) - output will be multiplied by this before being returned&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164127</id>
		<title>Types/NoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Types/NoiseExpression&amp;diff=164127"/>
		<updated>2018-09-01T16:28:29Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Move from User:TOGoS&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Types/NoiseExpression =&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same stringevery time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=User:TOGoS&amp;diff=164126</id>
		<title>User:TOGoS</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=User:TOGoS&amp;diff=164126"/>
		<updated>2018-09-01T16:28:16Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Remove noise expressions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m TOGoS!  I&#039;m mostly trying to open up the terrain generation so that it can be hacked on (by staff or modders) without having to embed oneself in the C++ guts of factorio for several weeks.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=User:TOGoS&amp;diff=164125</id>
		<title>User:TOGoS</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=User:TOGoS&amp;diff=164125"/>
		<updated>2018-09-01T16:27:35Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: /* Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m TOGoS!  I&#039;m mostly trying to open up the terrain generation so that it can be hacked on (by staff or modders) without having to embed oneself in the C++ guts of factorio for several weeks.&lt;br /&gt;
&lt;br /&gt;
= Types/NoiseExpression =&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same stringevery time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: term, other term&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and adds them.&lt;br /&gt;
&lt;br /&gt;
=== subtract ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: minuend, subtrahend&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and subtracts the second from the first.&lt;br /&gt;
&lt;br /&gt;
=== multiply ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: factor, other factor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and multiplies them.&lt;br /&gt;
&lt;br /&gt;
=== divide ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: dividend, divisor&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments and divides the first by the second.&lt;br /&gt;
&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: base, exponent&lt;br /&gt;
&lt;br /&gt;
Takes 2 positional arguments, and raises the first to the second power.&lt;br /&gt;
&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be absoluted&lt;br /&gt;
&lt;br /&gt;
Takes a single positional argument and returns its absolute value.  i.e. If the argument is negative, it is inverted.&lt;br /&gt;
&lt;br /&gt;
=== clamp ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be clamped, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
First argument is clamped between the second and third.  The second is treated as a lower limit and the third the upper limit.&lt;br /&gt;
&lt;br /&gt;
=== ridge ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Arguments (positional)&#039;&#039;&#039;: value to be ridged, lower limit, upper limit&lt;br /&gt;
&lt;br /&gt;
Similar to clamp but the input value is folded back across the upper and lower limits&lt;br /&gt;
until it lies between them.&lt;br /&gt;
&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=User:TOGoS&amp;diff=164124</id>
		<title>User:TOGoS</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=User:TOGoS&amp;diff=164124"/>
		<updated>2018-09-01T16:07:29Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Move noise expression work to my user page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I&#039;m TOGoS!  I&#039;m mostly trying to open up the terrain generation so that it can be hacked on (by staff or modders) without having to embed oneself in the C++ guts of factorio for several weeks.&lt;br /&gt;
&lt;br /&gt;
= Types/NoiseExpression =&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
A fragment of a functional program used to generate coherent noise, probably for purposes related to terrain generation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== type ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of the type of this expression.&lt;br /&gt;
Which other properties apply depend on the expression type.&lt;br /&gt;
&lt;br /&gt;
== Expression types ==&lt;br /&gt;
&lt;br /&gt;
=== variable ===&lt;br /&gt;
&lt;br /&gt;
Reference to a pre-defined variable, constant, or a named noise expression.&lt;br /&gt;
&lt;br /&gt;
Predefined variables include &amp;quot;x&amp;quot;, &amp;quot;y&amp;quot;, and &amp;quot;distance&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable_name&#039;&#039;&#039;: a [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
=== function-application ===&lt;br /&gt;
&lt;br /&gt;
Apply a function to a list or associative array of arguments.&lt;br /&gt;
Some functions expect arguments to be named and some expect them not to be.&lt;br /&gt;
&lt;br /&gt;
Function calls are their own class of expression&lt;br /&gt;
(as opposed to every function just being its own expression type)&lt;br /&gt;
because function calls all have similar properties --&lt;br /&gt;
arguments are themselves expressions,&lt;br /&gt;
a call to any pure function (i.e. most functions other than &amp;lt;code&amp;gt;random()&amp;lt;/code&amp;gt;)&lt;br /&gt;
is [https://en.wikipedia.org/wiki/Referential_transparency referentially transparent]&lt;br /&gt;
and can be constant-folded if all of its arguments are constant, etc.&lt;br /&gt;
&lt;br /&gt;
Properties:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function_name&#039;&#039;&#039; (a string; see functions, below)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (a list or associative array of argument expressions)&lt;br /&gt;
&lt;br /&gt;
=== literal-number ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same number every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
=== literal-string ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same stringevery time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of strings or use for them,&lt;br /&gt;
this is useful only in constant contexts.&lt;br /&gt;
&lt;br /&gt;
=== literal-object ===&lt;br /&gt;
&lt;br /&gt;
Evaluates to the same object every time, given by the &#039;&#039;&#039;literal_value&#039;&#039;&#039; property.&lt;br /&gt;
&lt;br /&gt;
e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  type = &amp;quot;literal-object&amp;quot;,&lt;br /&gt;
  literal_value = {&lt;br /&gt;
    name = &amp;quot;Bob Hope&amp;quot;,&lt;br /&gt;
    birth_date = {&lt;br /&gt;
      year = 1903,&lt;br /&gt;
      month = 5,&lt;br /&gt;
      day_of_month = 29&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the noise generation runtime has no notion of objects or use for them,&lt;br /&gt;
this is useful only in constant contexts, such as the &#039;&#039;&#039;points&#039;&#039;&#039; argument&lt;br /&gt;
of the &#039;&#039;&#039;distance-from-nearest-point&#039;&#039;&#039; function.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== add ===&lt;br /&gt;
=== subtract ===&lt;br /&gt;
=== multiply ===&lt;br /&gt;
=== divide ===&lt;br /&gt;
=== exponentiate ===&lt;br /&gt;
=== absolute-value ===&lt;br /&gt;
=== clamp ===&lt;br /&gt;
=== ridge ===&lt;br /&gt;
=== factorio-basis-noise ===&lt;br /&gt;
=== factorio-multioctave-noise ===&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=164011</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=164011"/>
		<updated>2018-08-29T02:38:59Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Types/NoiseExpression&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A [[Types/NoiseExpression]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
In 0.16 the &#039;name&#039; of the NamedNoiseExpression must be &amp;quot;default-&amp;lt;property&amp;gt;&amp;quot;, e.g. &amp;quot;default-elevation&amp;quot;&lt;br /&gt;
for it to be picked up by the terrain generation system and used to calculate elevation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== name ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of this expression, e.g. &amp;quot;default-temperature&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=164010</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=164010"/>
		<updated>2018-08-29T02:38:34Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Types/NoiseExpression&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A [[Types/NoiseExpreession]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
In 0.16 the &#039;name&#039; of the NamedNoiseExpression must be &amp;quot;default-&amp;lt;property&amp;gt;&amp;quot;, e.g. &amp;quot;default-elevation&amp;quot;&lt;br /&gt;
for it to be picked up by the terrain generation system and used to calculate elevation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== name ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of this expression, e.g. &amp;quot;default-temperature&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
	<entry>
		<id>https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=164009</id>
		<title>Prototype/NamedNoiseExpression</title>
		<link rel="alternate" type="text/html" href="https://wiki.factorio.com/index.php?title=Prototype/NamedNoiseExpression&amp;diff=164009"/>
		<updated>2018-08-29T02:37:26Z</updated>

		<summary type="html">&lt;p&gt;TOGoS: Created page with &amp;quot;== Basics ==  A NoiseExpreession together with a name.  Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.  I...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basics ==&lt;br /&gt;
&lt;br /&gt;
A [[NoiseExpreession]] together with a name.&lt;br /&gt;
&lt;br /&gt;
Named noise expressions are used to specify functions for elevation, temperature, moisture, aux, and cliffiness.&lt;br /&gt;
&lt;br /&gt;
In 0.16 the &#039;name&#039; of the NamedNoiseExpression must be &amp;quot;default-&amp;lt;property&amp;gt;&amp;quot;, e.g. &amp;quot;default-elevation&amp;quot;&lt;br /&gt;
for it to be picked up by the terrain generation system and used to calculate elevation.&lt;br /&gt;
&lt;br /&gt;
== Mandatory properties ==&lt;br /&gt;
&lt;br /&gt;
=== name ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/string]]&lt;br /&gt;
&lt;br /&gt;
Name of this expression, e.g. &amp;quot;default-temperature&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== expression ===&lt;br /&gt;
&#039;&#039;&#039;Type&#039;&#039;&#039;: [[Types/NoiseExpression]]&lt;br /&gt;
&lt;br /&gt;
The expression itself.&lt;/div&gt;</summary>
		<author><name>TOGoS</name></author>
	</entry>
</feed>