User:DeathFish/RandomWeights Tutorial
Functional statements
RollChancesRandomWeightsN
Common misconceptions
What probability does RollChances represent?
RollChances is the probability that a single weighted selection attempt will be executed at all, not the probability that a selected element will be used after being picked.
- Many people confuse it with
ExtraWarheads.DetonationChances, which is the probability that an already selected warhead will actually be used (detonated).
The relationship between N and the number of execution rounds
RandomWeightsN is the weight list used for the N-th draw in the current round, not the weight list used for every draw in the N-th round, nor the weight for the N-th element.
Meaning of “the last weight list”
If RandomWeightsX cannot be read, then reading of all subsequent numbered lists stops:
- If
RandomWeights/RandomWeights0,RandomWeights1andRandomWeights3are defined, butRandomWeights2andRandomWeights4are not, then draw 0 usesRandomWeights/RandomWeights0, and draws 1–4 all useRandomWeights1.
Execution flow of the weighted multi‑choice system
Note
The following flow is completed within a single round of usage.
1. Check whether a weight definition exists
- No → Do not perform multi‑choice; continue with default behaviour.
- Yes → Check
RollChances: the number of entries in this list determines the number of attempts.- If not written, it is treated as
RollChances=100%, i.e. one attempt that always succeeds.
- If not written, it is treated as
2. Use the value in RollChances corresponding to the current attempt to decide whether to draw
- No → Move to the next attempt.
- Yes → Begin a weighted multi‑choice draw.
3. Use the RandomWeights list corresponding to the current attempt to define the weights, and perform the draw
- For attempt 0, use the
RandomWeights/RandomWeights0list. - For attempt 1, use the
RandomWeights1list. - If a list is missing for the first time, let this be attempt X; then from this attempt onward, all subsequent draws use
RandomWeights[X-1]as the weight list.
4. Has the number of attempts determined by RollChances been reached?
- No → Move to the next attempt.
- Yes → The flow is fully complete.
If, after the draw, there is no additional “use probability” (as in the current Super Weapon random system), every selected item is activated. If there is an additional use probability after the draw (as with ExtraWarheads), then an extra check is performed – for example, with ExtraWarheads, each selected warhead still goes through ExtraWarheads.DetonationChances individually to decide whether it detonates or not.
Summary / supplementary notes
From the flow described above, it can be seen that:
- The number of entries in
RollChancesdetermines the number of attempts for the multi‑choice draw.- This therefore determines the maximum number of results (super weapons / warheads) that can be drawn.
- At least one attempt is made – an attempt may fail, so it is possible that no result is drawn at all.
Tip
Writing only RandomWeights/RandomWeights0 without RollChances results in a single weighted draw.
- If the number of entries in a
RandomWeightsNlist is greater than the number of candidate elements, the extra weight values correspond to “empty”.- Example: a single weighted draw has only
Types=Abut the weight list isRandomWeightsN=1,2,3,4. The chance of drawing A is1/(1+2+3+4) = 1/10.
- Example: a single weighted draw has only
- If the number of entries in a
RandomWeightsNlist is less than the number of candidate elements, elements without a corresponding weight effectively have a weight of 0.- Example: a single weighted draw has
Types=A,B,C,D(four elements) but the weight list isRandomWeightsN=1. This is equivalent toRandomWeightsN=1,0,0,0, so A is always drawn.- If the weight list is changed to
RandomWeightsN=25,75, that is equivalent toRandomWeightsN=25,75,0,0. The chance of drawing A is25/(25+75+0+0) = 1/4, and the chance of drawing B is75/(25+75+0+0) = 3/4.
- If the weight list is changed to
- Example: a single weighted draw has
Extended usage – simulating DetonationChances-style probabilities with a weight system
Probability table
| Type | A | B | C | D | E |
|---|---|---|---|---|---|
DetonationChances |
40% | 20% | 35% | 25% | 15% |
Implementation
[SOMESECTION] Types=A,B,C,D,E RollChances=40%,20%,10%,50%,30% RandomWeights0=1 RandomWeights1=0,1 RandomWeights2=0,0,1 RandomWeights3=0,0,1,1 RandomWeights4=0,0,0,0,1,1
Process walkthrough
With 5 RollChances entries, 5 attempts are made. The outcome of each successful attempt is:
- Attempt 0 (40% success): always selects A (weight list
1) - Attempt 1 (20% success): always selects B (weight list
0,1) - Attempt 2 (10% success): always selects C (weight list
0,0,1) - Attempt 3 (50% success): 50% C, 50% D (weight list
0,0,1,1) - Attempt 4 (30% success): 50% E, 50% nothing (weight list
0,0,0,0,1,1; index 5 is invalid)
Expected activations
The activation probability[1] for each type is the sum over all attempts of (attempt success rate × probability of selecting that type):
- A: 40% × 100% = 40%
- B: 20% × 100% = 20%
- C: 10% × 100% + 50% × 50% = 10% + 25% = 35%
- D: 50% × 50% = 25%
- E: 30% × 50% = 15%
References
- Phobos documentation - LimboDelivery.
- Phobos documentation - Linked superweapons.
- Phobos documentation - Next.
- Phobos documentation - Extra warhead detonations.
Footnotes
- ↑ Expected number of activations