As I have been programming in Greenfoot I have noticed that the pseudorandom numbers that Greenfoot.getRandomNumber() produces are not very random... This caused problems in certain cases for me. So i started using another method of generating random numbers that works very well and wanted to share it with everyone that has the same problem as I, so enjoy :).
1 2 3 4 5 6 7 8 9 10 | import java.util.Random //gets the current time in mili secs to create a good seed for randomization seed = System.getCurrentTimeMilis(); //creates a random number generator Random rand = new Random(); // sets the seed for creating more randomized numbers rand.setSeed(seed); //generates the random number (this generate different types of variables see docs to find all) rand.nextInt(); |