Starfield:Leveled Lists

Leveled Lists are a data structure that Starfield uses to randomly spawn items, NPCs and other procedurally generated features. By default, the algorithm uniformly samples one element from the list, conditional on the level, where the it will sample from the elements restricted to the level that is closest to the player's level without exceeding it. Once the algorithm selects an element, it spawns one or more instances of the object, depending on the quantity associated with the element. An element can itself be a leveled list, in which case the sampling is recursive, where the quantity of the result is multiplied by the element's quantity. Some lists have a non-zero chance of spawning nothing. The behavior of the algorithm is modulated by the following flags:
 * All Levels: The algorithm samples from all objects with a level less than the player's level, not just those with the highest level among them
 * Each: When sampling from a child list, the algorithm uses the element's quantity to determine how many times to independently sample from the child list, instead of multiplying it by the quantity returned from a single sampling
 * Use All: The algorithm spawns a single object from every element in the list, with randomness potentially persisting from the sampling of child lists