import java.util.*; /** * @author Nicklas Hjalmarsson * @version 1.0 * * Dice */ public class Dice{ // Sets the counter seed to the time private static long counter= (new Random()).nextLong(); /** * Gets you a random number between 0 and 100 */ public static int roll(){ Random dice = new Random(counter); int roll = (int)(100 * dice.nextFloat()); counter = dice.nextLong(); // edit the seed for next use System.out.println("The dice hit "+roll); return roll; } /** * Returns a double with mean 1 and may be what the heck anything.. */ public static double hitroll(){ Random dice = new Random(counter); double roll = (dice.nextGaussian()+2)/2; counter = dice.nextLong(); // edit the seed for next use System.out.println("The dice hit "+roll); return roll; } /** * Returns an integer between 0 and the given integer, inclusive! */ public static int rand(int max) { Random dice = new Random(counter); counter = dice.nextLong(); return (int)Math.round(dice.nextFloat()*max); } public static void main(String[] args){ for(int i = 0; i<10;i++) System.out.println(rand(10)); } }