NatFloat

From Vintage Story Wiki

This page was last verified for Vintage Story version 1.19.3.

A somewhat more natural random number generator. The main difference to pure random is that you can define a distribution to influence how often certain values are chosen.

Arguments

  • avg: Average value
  • var: Variation
  • dist: Distribution type
Overview - Distribution modes
Name Explanation
uniform Select completely random numbers within avg-var until avg+var (the default distribution).
triangle Select random numbers with numbers near avg being the most commonly selected ones, following a triangle curve.
gaussian Select random numbers with numbers near avg being the most commonly selected ones, following a gaussian curve.
narrowgaussian Select random numbers with numbers near avg being the most commonly selected ones, following a narrow gaussian curve.
verynarrowgaussian Select random numbers with numbers near avg being the most commonly selected ones, following a very narrow gaussian curve.
narrowinversegaussian Select random numbers with numbers near avg being the least commonly selected ones, following an upside down gaussian curve.
inversegaussian Select random numbers with numbers near avg being the least commonly selected ones, following an upside down gaussian curve.
narrowinversegaussian Select random numbers with numbers near avg being the least commonly selected ones, following an upside down narrow gaussian curve.
invexp Select numbers in the form of avg + var, wheras low value of var are preferred.
stronginvexp Select numbers in the form of avg + var, wheras low value of var are strongly preferred.
strongerinvexp Select numbers in the form of avg + var, wheras low value of var are very strongly preferred.
dirac Select completely random numbers within avg-var until avg+var only ONCE and then always 0.


Here are some plots for these distributions. They are created by generating 8000 random numbers between 0 and 200, where the X-Axis is the resulting value and the Y-Axis the amount of times this value was chosen.

Natfloat-uniform.png Natfloat-triangle.png Natfloat-gauss.png Natfloat-narrowgauss.png Natfloat-verynarrowgauss.png

Natfloat-invgaus.png Natfloat-narrowinvgaus.png Natfloat-invexp.png Natfloat-stronginvexp.png Natfloat-stronverinvexp.png

Translated to the Natfloat arguments the horizontal center point in these graphs denote the "avg" value, the width of the plot is determined by the "var" value. In json, the uniform distribution would be in the written as such:
{ avg: 100, var: 100, dist: "uniform" }


See also EvolvingNatFloat


Modding
Green Items require C# coding
Basics

Getting Started | Basic Examples | Theme Pack

Asset System | Textures | Items | Recipes | Blocks | Entities | Model Creator | Animation Basics | VTML & Icons | Packaging & Release | Modinfo | Debugging

Advanced

JSON Patching | Advanced JSON Item | The Remapper | Server-Client Considerations | Compatibility with other mods

Setting up your Development Environment

Advanced Blocks | Advanced Items | Block and Item Interactions | Block Behavior | Block Entity | Particle Effects | World Access | Inventory Handling | Commands | GUIs | Network API | Monkey patching (Harmony)

Data Management

Savegame Data Storage | ModConfig File | Chunk Data Storage | TreeAttribute

Worldgen

WorldGen Concepts | Terrain | Ores | Trees | WorldGen API | NatFloat | EvolvingNatFloat | Json Random Generator

Rendering

Shaders and Renderers

Property Overview

Item | Entity | Block | Block Behaviors | Block Classes | Block Entities | Block Entity Behaviors | World properties

Workflows & Infrastructure

Modding Efficiency Tips | Mod-engine compatibility | Mod Extensibility | VS Engine

Additional Resources

List of server commands | List of client commands | Client startup parameters | Server startup parameters | Creative Starter Guide | ServerBlockTicking | Bot System | WorldEdit | Cinematic Camera | Adjustable FPS Video Recording

Example Mods | API Docs | GitHub Repository