phillip1882 Posted June 25, 2012 Posted June 25, 2012 (edited) so lately I've been studying randomness for no particular reason. the problem with most prng is they use both multiplication and modulus, both expensive, and are not necessarily very good at producing randomness. i believe i've come up with a nice, compact pseudo-random number generator. here it is in python. v = [0]*3 seed1 = 1995714531 v[0] = 0x96696996 v[1] = seed1 v[2] = 0xb5b5adad def rot(x,k): return ((x<<k)|(x>>(32-k)))&4294967295 #the &num is unnecessary in other programing languages def rng(): v[0], v[2], v[1] = rot(v[2],8), rot(v[1],17), v[0]^(~v[1]&v[2]) return v[1] Edited June 25, 2012 by phillip1882
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now