The reason I asked was because I was playing with landscape fractals a while ago, and I remember thinking that something like this would have been very handy, and that I could probably make it myself.

My understanding is that most rngs are designed for use in cryptography where the requirements for randomness are kind of overkill compared to how you would usually use the numbers in games.

JakobProgsch, your reversible lcg seems very interesting, though I don't understand everything.

I'm a little rusty with my discrete mathematics, could you help me out?

This is my attempt at reversing lcg:

x' : next int

x : current int

a and m is relatively prime

from next int:

x' ≡ a * x + c (mod m)

trying to reorder:

x' - c ≡ a * x (mod m)

ainverse * (x' - c) ≡ ainverse * a * x ≡ x (mod m)

which should mean

prevx = mod(ainverse * (x - c), m);

while you have:

prevx = (ainverse * mod(x - c, m)) % m;

is this the same? Or could you help me point out what's wrong with my derivation?

Also according to wikipedia it is recommended to discard some of the least significant bits from x before using it as a random number. Just thought somebody might be interested in case they use your implementation.

Kind of as a side question, has anyone had issues with lcg not being random enough when using it in games?