Code example for Random

Methods: nextLongsetSeed

0
 
 
    public static long getRandomSeedUsingTwoIntSeeds( final int firstSeed, final int secondSeed )
    { 
        seedRandom( theTempRandom, (long) ( firstSeed * 7237 ), (long) ( secondSeed * 5317 ) );
        return theTempRandom.nextLong();
    } 
 
 
    /** 
     * Seeds the specified random number generator, and make the start position a bit more scrambled by reading off a few random values. 
     * 
     * @param random 
     * @param seed 
     */ 
    public static void seedRandom( final Random random, final long seed )
    { 
        random.setSeed( seed );
        random.nextLong();
        random.nextLong();
        random.setSeed( random.nextLong() );
        random.nextLong();
        random.nextLong();
        random.nextLong();
    } 
 
 
    /** 
     * Seeds the specified random number generator with the combination of two different random seeds. 
     * Also reads off a few random values, to get the random number generator into a bit more random state. 
     * 
     * @param random 
     * @param firstSeed 
     * @param secondSeed 
     */ 
    public static void seedRandom( final Random random, final long firstSeed, final long secondSeed )
    { 
        // TODO: check on the net if someone has some good algorithm for this.. 
 
        random.setSeed( firstSeed );
        random.nextLong();
        random.nextLong();
        random.setSeed( random.nextLong() ^ secondSeed );
        random.nextLong();
        random.nextLong();
        random.nextLong();
    } 
 
 
    /** 
     * Seeds the specified random number generator with the combination of three different random seeds. 
Contextual code suggestions in your IDE  Get Codota for Java