Code Monkey home page Code Monkey logo

Comments (2)

TediusTimmy avatar TediusTimmy commented on August 19, 2024 1

Wikipedia's definition of a Lehmer random number generator is of the form:
x(n+1) = a * x(n) mod m
Where you choose a and m such that the period of the sequence is m-1 (usually).

His implementation, however:
Takes the seed and adds a magic number. He then multiplies the result by another magic number, xors the high 32 bits onto the low 32 bits, multiplies this result by a third magic number, again xoring the high 32 bits onto the low 32 bits, and finally returns the low 32 bits.

So, you've got an additive sequence that feeds into two sequential Lehmer RNGs of modulus 2^32, where the output of each Lehmer is conditioned with the truncated bits (probably because a power of 2 is a poor modulus).

I don't know what algorithm it is, but it seems to be random enough for his uses. I was just wondering if he had a reference for it.

from olcpixelgameengine.

skejeton avatar skejeton commented on August 19, 2024

Math formulas usually look more complicated than the actual implementation

from olcpixelgameengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.