Mail Archives: djgpp/1994/12/07/09:32:40
This source demonstrates a better rand() function, which is similar in
algorithm to the one I'm using in V2. Let me know if anyone finds any
non-randomness in this one.
Note: this test shows how non-random V1's rand() is, if you just
comment out the rand() here and use the system one.
Enjoy!
DJ
---------------
#include <graphics.h>
int rand()
{
static unsigned long long next=0;
next = next * 1103515245L + 12345;
next = (next<<15) ^ (next >> 27);
return next;
}
main()
{
int mx, my, w;
GrSetMode(GR_biggest_graphics);
mx = GrSizeX();
my = GrSizeY();
w = GrWhite();
while (!kbhit())
GrPlot(rand()%mx, rand()%my, w);
getkey();
GrSetMode(GR_default_text);
return 0;
}
- Raw text -