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

  • Home
  • SEARCH
  • 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 8129541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:21:00+00:00 2026-06-06T08:21:00+00:00

When grabbing Random().nextInt(int) integers for two entirely separate mechanics (e.g. attack rolls and superficial

  • 0

When grabbing Random().nextInt(int) integers for two entirely separate mechanics (e.g. attack rolls and superficial random animations), is there any reason to use separate Random() instances for each mechanic? For example, might it help ensure a more even dispersion of random values for each mechanic?

–

Similarly, in a continuing game where an even dispersion of random values is important, is there any reason to store a Random()’s instance or seed with saved game data — and pick up where it left off when the game is loaded — rather than creating a new instance each time?

For example, in a turn-based game where the player may be lucky or unlucky on each turn, is it possible that creating a new Random() instance on game load could bring about a situation where a player is abnormally lucky or unlucky?

–

(Note: When I say “creating a new instance”, I mean using just “Random random = new Random()”, with no seed specified.)

Thanks!

  • 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. Editorial Team
    Editorial Team
    2026-06-06T08:21:03+00:00Added an answer on June 6, 2026 at 8:21 am

    No. No reason. Use the same instance.

    With some exceptions:

    1. The predictability of the pattern is desired. For instance, to seed a particular “solitaire game number” or to “ensure the same random events occur” (e.g. stop save/load “cheating” 😉 It may require extra work to utilize the PRNG repeatability as the internal state is not exposed. This is a business rule.
    2. Threading is used, and there is a performance issue with using the same Random instance. (Random is Thread-safe in Java, I previously misspoke.)

    The issue with same-seeding is that the PRNG sequence will start the same (and thus be known or, usually more often, causes the same [colliding] sequence and “lack of randomness”). The quality of the randomness of the sequence, however is not affected.

    As an aside: thankfully Java has a pretty good default Random constructor:

    Creates a new random number generator. This constructor sets the seed of the random number generator to a value very likely to be distinct from any other invocation of this constructor.

    In JDK 6 it is implemented as:

    this(++seedUniquifier + System.nanoTime());
    

    (Of course, it’s possible to imagine/contrive a degenerate scenario with the above implementation as well…)

    Happy coding.

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

Sidebar

Related Questions

I am grabbing a block of text, and within this block there will be
I've made a simple grabbing demo page . It doesn't have any easing/acceleration. I
I am grabbing some data from a page using the code below: int clientId
I've looked around and there doesnt seem to be any easy way to do
There are a few APIs for grabbing the address book/contact list from the major
Grabbing delimited dates from database and adding new ones to the list, then want
Grabbing album art for current song and using it to change a certain imageView.image
I'm grabbing some binary data out of my MySQL database. It comes out as
I'm having trouble grabbing the TR count in JQuery of a table that inside
Rather than just grabbing the user's friends' emails, I want to show their list

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.