random function

How was the random function written? Where could I find the code, or would one of you be able to paste it up here?
you mean like rand/srand?

The actual code used is implementation dependent so nobody here can really post the code.

If you want to know how it works, it's something like a simple math formula with numbers chosen to produce seemingly random patterns.

This code has a similar effect:

1
2
3
4
5
6
7
8
9
10
11
12
unsigned rand_state;

void my_srand(unsigned seed)
{
  rand_state = seed;
}

unsigned my_rand()
{
  rand_state = (69069 * rand_state) + 362437;
  return rand_state;
}
Topic archived. No new replies allowed.