Thanks everyone! I will be posting some more questions as I have 24
"little" programs that have to be written before I can take my mid
term..... Heavy heavy math. Highschool was um.... too many years ago
to remember and I only took Algebra II in college. I might be in
trouble. Trying to understand what that squiggly "E" means....

You guys have all been a great help! Thanks so much!
Stephanie

--- In [email protected], "Nico Heinze" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], Thomas Hruska <thruska@> wrote:
> >
> > onecrazeemom wrote:
> > > I finally completed the dice roll program. Now, what do
> > > I do to make the rolls more random? They seem to come up
> > > with doubles quite often.
> > > I used srand( time(0)) to get my random numbers.
> > > I used the modulus(I
> > > think that is what it is called) 
> > > 
> > > dieOne = 1 + rand() %6;
> > > dieTwo = 1 + rand() %6;
> > > 
> > > srand( time(0) );
> > > 
> > > Just curious what gives you a true random number when the lines of
> > > code are run so close together. Here are a couple of rolls:
> > > 
> > > 1. 3, 1
> > > 2. 6, 1
> > > 3. 6, 2
> > > 4. 5, 5
> > > 5. 1, 1
> > > 6. 3, 4
> > > 7. 4, 6
> > > 
> > > I guess they are more random than I thought, but the first
> > > two times I ran the program it came up with doubles.
> > > 
> > > Thanks in advance,
> > > Stephanie
> > 
> > Probably what you are "experiencing" is the side effect of
> > using the modulus of a random number with a number not
> > evenly divisible by the maximum range of the random number
> > generator.
> > 
> > True random number generators are MUCH harder to create (all
> > the implementations of rand() that I've seen are simple
> > congruential pseudorandom generators).  You get into heavy
> > math and/or cryptography VERY quickly if you start rolling
> > your own.
> <snip>
> 
> Stephanie,
> 
> if you have access to a well-sorted public library, get your hands on
> volume 2 of Donald Knuth's "The Art Of Computer Programming"; really
> heavy stuff to work through, but he explained the basics of
> pseudo-number generation so well that this writing is still valid
> (it's been written in the early 1970's).
> And he explains how you can test your own pseudo-random number
> generators for their quality without much effort, only some time to
> have your check program run it. Pretty easy to implement. And very
> well explained (though the math background is too heavy for me).
> 
> Regards,
> Nico
>


Reply via email to