title: Combine World and Object Seed to Create Repeatable Random Number
body: <p>I want to create an algorithm to generate objects. It will take two seeds: a hard seed (1 per universe/per game, set up in ini file) and a 'soft' seed that is passed to the function by each object that uses the function. (The soft seed belongs to the object and does not change between function calls). The purpose of this function is to output a random number (between 0-100) that is 'unique' for each object, but is repeatable: the output number is the same every time the object is generated (so long as the hard seed remains the same). </p>
  
  <p>Declaring the Random outside of the function and using nextDouble() gives me good distribution but would mean that objects won't be repeatable if they generate out of order (which is possible, the program will generate objects in different orders). </p>
  
  <p>Recreating the Random within the function gives me a bad number distribution.</p>
  
  <p>Is my uneven distribution due to bad seeding/seed weights? How can I improve this function?</p>
  
  <p>The following is Pseudo-code: a test class I set up:</p>
  
  <pre><code>  public class SeedRandomTest {
      int hardSeed = 100;
      Random generator = new Random(hardSeed);
      public SeedRandomTest(){
          for (int i = 0; i &lt; 10; i++){
              algorithmRand(i);
          }
      }
  
      public void algorithmRand(int seed){
          //seed would be a argument, hardseed from config properties
  
  
          int i = 0;
          int genSeed = hardSeed + seed*100;
      //      Random generator = new Random(genSeed);
          generator.setSeed(genSeed);
          double j = (generator.nextDouble() * (100));
          i = (int) j;
  
  
  
          System.out.println("num = "+ i);
       }
    }
  </code></pre>