Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 06-19-2008
Elysia
Usually, it means you give the computer a start number, then it applies an algorithm on that number to produce "random" numbers.
Of course, there are "random" generators and not-so-random generators (not-so-random generators may produce the exact same sequence of numbers from the same seed).
• 06-19-2008
whiteflags
Well actually, you can get a pseudorandom number algorithmically by multiplying a seed with a constant and taking the mod of another constant. I'll show you one:
Code:

```int seed=1; void LCGseed (unsigned int _seed) {   int i, h=1;   unsigned char *p=&_seed;   for (i=0; i < sizeof _seed; h++) {       h = h>>24 * h<<4 ^ p[i];   }   seed=h; } int LCGrand (void) {   return seed*=16807UL &#37; 2147483647UL; }```
The algorithm, when called several times, naturally produces a series called a period. Large periods are good, but more important is the factor of unpredictability. We shouldn't rely on the default seed because that would make the generator more predictable and the result very deterministic. The seed is actually the last number the generator returned. If you're using the generator for the first time, it would be a good idea to set the seed somewhere in the period to start off from other than the default value, using a unique source, like the time.

The example is actually a great deal similar to the rand/srand generator provided by C++, and that's not a very good one. But it's a place to start. You can learn more about PRNGs on the web.
• 06-19-2008
shawnt
Quote:

Originally Posted by Nestor
Listem men, i started programing yesterday....well today 1 am, i havn't gotten as far as a random numbers generator:P but if you are bored you can explain how it can be a random number generator if the computer can't think for itself?

http://cboard.cprogramming.com/cplusplus-programming/103889-random-isnt-really-random.html

for through understanding, read till the last page. :D
• 06-20-2008
Nestor
• 06-20-2008
anon
It's got an extra http// in it by mistake. Delete that in the address bar and you can follow it.
• 06-20-2008
lruc
go back
Go back to tutorials. In my opinion Cprogramming tutorials suck so find a better online tutorial, buy a book, or just stop posting such stupid threads
• 06-20-2008
Elysia
And you'd better learn to control that attitude of yours, because frankly, it sucks.
• 06-20-2008
Nestor
Me? Was that to me?
• 06-20-2008
Elysia
No, to lruc.
Nothing wrong with you, Nestor. Don't worry.
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12