Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2010
(56)
-
▼
February
(24)
- Foreign Footballers In The Premiership A Question ...
- Police Car Auctions Calgary Where And When Are Pol...
- Reef Oil Spf 15 Work Coconut Oil After Tanning?
- Phrases About Sympathy A Revealing Secret About Yo...
- Chest Infection Symptoms Treatment One Monthn Old ...
- Why Do My Legs Keep Aching Why Do My Legs Keep Hur...
- Stereo Microphone Camcorder Beginner Camcorder Mic...
- How To Steralize A Metal Blade I Havent Got A Pier...
- Prayers To Get Well Soon How Do I Word A Get Well ...
- Removing Stitching From Football Jerseys I Need He...
- How To Implement My Own Java Certificate Authority...
- Funky Cheer Spandex How Would I Get A Copy Of The ...
- Carlton Suitcase Combination Lock How Do I Change ...
- Original Groping Videos Help, Please...got Some Qu...
- Symptoms Of Gall Bladder Attacks I'm Fourteen, Am ...
- Business Names Ideas Interior Design Need An Idea ...
- Microsoft Word Microsoft Word?
- Brookstone Helicopter Spinning Why Is My RC Helico...
- How Do You Get Cheats To Work For Vba Emerald Can ...
- Pottery Barn Scratch And Dent I Have A Pottery Bar...
- My Spleen Is Swollen From Mono How Do I Change Tha...
- Video Store Flashers Is It Required To Open A Vide...
- Jams By Converse India Where Can I Get A Pair Of C...
- Do U Have To Have A Licence To Drive A Horse Trail...
-
▼
February
(24)
2 comments:
If no argument constructor for java.util.Random in the JDK you use, you can "System.currentTimeMillis ()" parameter, as long as the seed used.
For the next random number from the generator in the range 0-51, inclusive, simple, "nextInt (52).
eg
import java.util.Random;
long seed = System.currentTimeMillis ();
Random random = new Random (seed);
int i = random.nextInt (52);
Very good - I guess the bridge is initialized before you call that?
However, observations of Math.random (I assume that most pseudo-random numbers work the same), because they, at random numbers in the order indicated the same tendency to give the initial value.
Thus, instead of the production with Math.random () in the loop, you need the seeds initialized before the loop and pass as a parameter when the interior.
This will ensure a new sequence each time, thus preventing the shuffle, so that the same cards each time. It is typical for a time (or I / O function) Source Math.random the first call, for example, the time in milliseconds, as always when Math.random not offer a new way to sequence each time. This means that you cannextInt random method instead of "restart" sequence every time.
Edit
****
In terms of documentation, using each new Random object to initialize the default time for the seeds to create a chance in the loop, and within nextInt select the next random number.
Post a Comment