Interface PTableEntry<T>

An entry in a PTable.

interface PTableEntry<T> {
    high: number;
    low: number;
    relativeWeight: number;
    value: T;
    weight: number;
}

Type Parameters

  • T

Properties

high: number

The highest P value that will hit this range.

Due to the nature of how rolls work, the previous entry's high value will be equivalent to the next entry's low value. Previous entries will be checked first, so this overlap acts as the low-end barrier for all later entries rather than the low-end inclusive range.

Entries are checked as low <= p <= high. So in the case where the 1st entry is 0 <= 0.3 <= 0.25 and the 2nd entry is 0.25 <= 0.3 <= 0.5, the lower bound of the 2nd entry effectively means p must be greater than 0.25.

low: number

The highest P value that will hit this range.

Due to the nature of how rolls work, the previous entry's high value will be equivalent to the next entry's low value. Previous entries will be checked first, so this overlap acts as the low-end barrier for all later entries rather than the low-end inclusive range.

Entries are checked as low <= p <= high. So in the case where the 1st entry is 0 <= 0.3 <= 0.25 and the 2nd entry is 0.25 <= 0.3 <= 0.5, the lower bound of the 2nd entry effectively means p must be greater than 0.25.

relativeWeight: number

This is the weight of the entry with respect to all other entries.

This is effectively the range between its low value and high value.

value: T

The value that will be returned by the entry.

weight: number

The weight assigned to this entry.

Weights, as a value, are all relative to all other weights in the PTable.

As an example, if you have a set of weights that looks like [1,1,1,1], each item in the set will have a 1/4 (25%) share of all P values. On the flipside, you could also use [0.25, 0.25, 0.25, 0.25] to represent the same share.