Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 107893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:49:33+00:00 2026-05-11T01:49:33+00:00

Two Questions: Will I get different sequences of numbers for every seed I put

  • 0

Two Questions:

Will I get different sequences of numbers for every seed I put into it?

Are there some ‘dead’ seeds? (Ones that produce zeros or repeat very quickly.)

By the way, which, if any, other PRNGs should I use?

Solution: Since, I’m going to be using the PRNG to make a game, I don’t need it to be cryptographically secure. I’m going with the Mersenne Twister, both for it’s speed and huge period.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:49:33+00:00Added an answer on May 11, 2026 at 1:49 am

    To some extent, random number generators are horses for courses. The Random class implements an LCG with reasonably chosen parameters. But it still exhibits the following features:

    • fairly short period (2^48)
    • bits are not equally random (see my article on randomness of bit positions)
    • will only generate a small fraction of combinations of values (the famous problem of ‘falling in the planes‘)

    If these things don’t matter to you, then Random has the redeeming feature of being provided as part of the JDK. It’s good enough for things like casual games (but not ones where money is involved). There are no weak seeds as such.

    Another alternative which is the XORShift generator, which can be implemented in Java as follows:

    public long randomLong() {   x ^= (x << 21);   x ^= (x >>> 35);   x ^= (x << 4);   return x; } 

    For some very cheap operations, this has a period of 2^64-1 (zero is not permitted), and is simple enough to be inlined when you’re generating values repeatedly. Various shift values are possible: see George Marsaglia’s paper on XORShift Generators for more details. You can consider bits in the numbers generated as being equally random. One main weakness is that occasionally it will get into a ‘rut’ where not many bits are set in the number, and then it takes a few generations to get out of this rut.

    Other possibilities are:

    • combine different generators (e.g. feed the output from an XORShift generator into an LCG, then add the result to the output of an XORShift generator with different parameters): this generally allows the weaknesses of the different methods to be ‘smoothed out’, and can give a longer period if the periods of the combined generators are carefully chosen
    • add a ‘lag’ (to give a longer period): essentially, where a generator would normally transform the last number generated, store a ‘history buffer’ and transform, say, the (n-1023)th.

    I would say avoid generators that use a stupid amount of memory to give you a period longer than you really need (some have a period greater than the number of atoms in the universe– you really don’t usually need that). And note that ‘long period’ doesn’t necessarily mean ‘high quality generator’ (though 2^48 is still a little bit low!).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.