Config randomizer used to generate configuration from a set of input parameters.
Recurses through your input configuration object, and checks for two scenarios:
-
If the sub-object matches RandomizableCount interface, it calculates a concrete length based off of the count, and fills the array with mimics of the itemDetails interface.
-
If the sub-object matches RandomizableRange interface, it calculates a concrete value within the minValIncl and maxValIncl range according to the weight function.
- The potential values to chose from are found by starting at the minValIncl, and stepping by the stepper amount until the maxValIncl is reached
Note: if the maxValIncl is not an even amount of steps from the minValIncl (NOT recommended), the last value before going over the max value, as well as the max value, will both be included. For example:
1->5 by 1.5 = 1, 2.5, 4, 5
Note: As you will see in the example, these two interfaces can be used together. You can leverage a RandomizableCount whose itemDetails contains a RandomizableRange.
The following input configuration
{
a: {
b: {
minValIncl: 1,
maxValIncl: 4,
weightFnKey: "EVEN",
stepper: 1
},
c: {
d: {
minValIncl: 0.1,
maxValIncl: 0.5,
stepper: 0.1,
weightFnKey: "EVEN"
}
},
e: {
count: {
minValIncl: 1,
maxValIncl: 4,
stepper: 1,
weightFnKey: "EVEN"
},
itemDetails: {
e_1: "hello",
e_2: {
minValIncl: 0.6,
maxValIncl: 0.9,
stepper: 0.1,
weightFnKey: "EVEN"
}
}
}
}
}
Could produce the following when run through deRandomize.
{
a: {
b: 2
c: {
d: 0.1
},
e: [{
e_1: "hello",
e_2: 0.7
}, {
e_1: "hello",
e_2: 0.6
}]
}
}
- EVEN
- Gives every step value an even weight, so each value is equally likely.