When writing programs that have pseudo-random behavior -- games being the obvious but by no means only case -- it is helpful to be able to reproduce a sequence of pseudo-random numbers while testing and debugging so that the same behaviors can be repeated. For exactly this reason, there is a seed function in most languages that can be used to provide the pseudo-random number generator (PRNG) with a repeatable starting point.
Even if there were, the seeding technique only works when testing a fixed linear execution path and provides no way to skip ahead, e.g., if the bug or feature you're interested in testing kicks in around the billionth iteration of the PRNG, you have to go through a billion iterations every time. For all practical purposes, most PRNGs behave like sequential access tapes instead of random access memory.
Fortunately, there is a simple and relatively efficient way to sample elements from an effectively infinite multidimensional array of pseudo-random numbers by using a simple checksum algorithm like CRC-32. In its simplest form -- and assuming we already have a CRC-32 implementation handy (see below) -- it looks like this:
The salt argument is a string that consistently identifies the random number array you will be addressing. For most purposes, this can be fairly brief, and for efficiency's sake, it should be as short as possible. The coord argument is a string representation of the coordinate system in use. For a simple series of pseudo-random numbers, that is, a one-dimensional array, this can be an integer:
In the example above, as long as salt is aardvark, setting coord to 100 will always yield 0.6918889253865927. Likewise,
It should be noted that while CRC-32 yields a good first approximation of a uniform distribution, it is by no means a secure cryptographic hash and should not be used as such.
The CRC-32 implementation used here follows: