|
static int | GetWeightedIndex (notnull array< float > weights, float value01) |
| Given array of weights, get a random index based on the weight values.
|
|
◆ GetWeightedIndex()
static int SCR_ArrayHelper.GetWeightedIndex |
( |
notnull array< float > | weights, |
|
|
float | value01 ) |
|
static |
Given array of weights, get a random index based on the weight values.
Definition SCR_ArrayHelper.c:2
static int GetWeightedIndex(notnull array< float > weights, float value01)
Given array of weights, get a random index based on the weight values.
Definition SCR_ArrayHelper.c:17
i.e in an array [80, 15, 5], 80% of the time, we get index 0, 15% index 1 and 5% index 2, weight sum does not have to add up to any particular value, i.e [100, 100, 100, 100] gives equal 25% distribution (provided random distribution) for all 4 indices
- Parameters
-
[in] | weights | array with weights |
[in] | value | a value between [0..1], can be random, perlin, or any other; if outside these boundaries, will be Math.Mod-ed |
- Returns
- index selected based on weight or -1 if weights is empty
The documentation for this interface was generated from the following file:
- Game/Helpers/SCR_ArrayHelper.c