Shuffling, in the domain of procedural generation, is the generation of a random permutation(reordering) from a sequence of elements. While a simple Fisher-Yates shuffle is usually sufficient for sequences short enough to fit in a reasonable amount of memory, special techniques may be needed for sets of enormous length. The techniques explicated here may also be thought of as a means of taking a roving path through large sets that is assured to never hit the same element more than once, without requiring that you keep a record of where you've already stepped.


A linear concruential generator with parameters that satisfy certain requirements will have a period exactly as large as the domain, IE, it will not output the same number twice until it has covered every single number in the domain, providing a full psuedorandom permutation of the domain. See the Period section here.

If you do not know how large the sequence is going to be in advance and are thus unable to hand-pick LCG parametizations that meet the requirements for full periodicity, or if you want to be assured that your permutation is cryptographically random, you will prefer the technique detailed here over an LCG. (Summary: count up from zero, encypher the counter, and draw what the encyphered counter points to. Since cyphers are bijective, no two distinct counters will encypher to the same draw address.)

External Links

Shuffling - Wikipedia article on Shuffling.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License