Game dev
Saved & recent

Shuffle bag

Related terms: sampling without replacement, controlled randomness, loot table

Put a chosen set of outcomes into a bag, shuffle it and draw each item once before refilling. Unlike independent random rolls, this controls how often each outcome appears within a complete bag. Repeated copies can give some outcomes more weight.

A bag does not automatically prevent every streak: the last item of one bag can match the first of the next, and duplicate items can sit together. Extra rules can prevent those repeats. Left 4 Dead shuffles boss events such as Tank, Witch and Nothing, and separately forbids consecutive repeats. Use this when distribution matters alongside surprise.

Game example
Valve: shuffled boss events in Left 4 Dead
Further reading
Godot Engine: Random Number Generation and Shuffle Bags
C B A A C B first bag refill repeat across refill draw order
Each bag holds one circle, square and diamond. The circle happens to appear at the end of one bag and the start of the next.

View in the full Game dev collection