Selection Methods
Selection methods decide how RNGNeeds chooses item indices from a probability list. Your list still defines probabilities, enabled state, locked items, depletion, and repeat prevention — the selection method is the algorithm that turns that data into a result.
Which path should you use?
Use a built-in method
Best when you want default behavior, performance is already fine, and you only need to switch algorithms — not invent a new one.
Extend the system
Best when you need custom selection logic, want a special rule the built-ins do not cover, or are comfortable working at API level.
Built-in selection methods
Built-in methods
Linear SearchSimple linear search. A strong default for smaller lists and common gameplay scenarios.
Linear Search [BURST]Burst-compiled version of Linear Search. Better suited to larger workloads and large numbers of picks in one operation.
Cumulative ProbabilityUses cumulative probabilities and binary search. A good general-purpose option across different list sizes.
Cumulative Probability [BURST]Burst-compiled cumulative-probability method. Great when you care about throughput for larger selection jobs.
Random SelectionIgnores item probabilities entirely and selects from items uniformly at random.
Quick guidance
When each built-in method makes sense
Linear Search / Linear Search [BURST]Good fit for many gameplay lists, especially smaller lists or situations where the number of picks per call is low.
Cumulative Probability / Cumulative Probability [BURST]Good fit when lists get larger or you want a more scalable general-purpose selection algorithm.
Random SelectionUse only when you intentionally want a uniform distribution and do not want probabilities to matter.
Full custom path: ISelectionMethod
ISelectionMethod is the lowest-level extension path.
Use it when you want complete ownership of the selection process.
That also means you are responsible for the technical details yourself.
ISelectionMethod contract
IdentifierThe unique key used to register and look up the method. This is the value stored in ProbabilityList<T>.SelectionMethodID.
NameHuman-readable display name for the method.
EditorTooltipTooltip shown in the Unity editor when applicable.
SelectItemsPerforms the actual selection and returns the picked indices.
Recommended custom path: SelectionMethodBase
SelectionMethodBase is the partial implementation for custom selection logic.
If you want to focus on your own algorithm instead of rebuilding the whole selection pipeline, start here.
This base class handles a lot of the heavy lifting around the selection process so you can focus on the part that makes your method unique.
What SelectionMethodBase helps with
Why inherit from SelectionMethodBase
Prep and item data setupThe base class prepares the probability list, item data, enabled-item tracking, positive-probability tracking, and seeded random state.
Repeat-prevention integrationIt already knows how to integrate with RNGNeeds repeat-prevention options such as Spread, Repick, and Shuffle.
Depletable-list supportIt handles depletion-aware selection flow and applies item unit changes back to the list when required.
Selection loop lifecycleThe base class owns the common loop and cleanup lifecycle, which means less boilerplate and fewer opportunities to subtly break expected behavior.
The main members you usually care about
SelectionMethodBase members
ProbabilityListThe active probability list being processed.
ItemDataRuntime item data used during selection.
EnabledIndicesWithPositiveProbabilityIndices of items that are currently eligible and have positive probability.
AllIndicesWithPositiveProbabilityIndices of all items with positive probability, whether currently selectable or not.
LastPickedIndexThe most recently picked item index from the list's history.
ItemCountNumber of items in the list.
TotalProbabilityTotal probability accumulated during prep.
SelectItemThe key method you implement. This is where your custom selection logic usually lives.
PrepOverride only if you need additional preparation before selection starts.
PrepItemOverride when you want to collect per-item data while the list is being prepared.
SpreadResultHook for repeat-prevention spread behavior.
ShuffleResultHook for repeat-prevention shuffle behavior.
Minimal custom method example
public class MySelectionMethod : SelectionMethodBase
{
public override string Identifier => "MySelectionMethod";
public override string Name => "My Selection Method";
protected override bool SelectItem(out int selectedIndex)
{
selectedIndex = EnabledIndicesWithPositiveProbability[
m_Random.NextInt(0, EnabledIndicesWithPositiveProbability.Length)
];
return true;
}
}
Then register it through RNGNeeds Core:
RNGNeedsCore.RegisterSelectionMethod(new MySelectionMethod());
Which custom path is better?
Choose your difficulty level
Inherit from SelectionMethodBaseBest for most custom extensions. You keep the familiar RNGNeeds pipeline and concentrate on the part that makes your selection logic special.
Implement ISelectionMethod directlyBest when you deliberately want total control and are comfortable recreating all required behavior yourself.
Need help with a custom method?
If you want help choosing an approach, shaping a custom method, or sanity-checking the behavior of your algorithm, feel free to drop by our Support page and join the Discord from there.