File size: 1,200 Bytes
806d4b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
U0 RandPts()
{
I64 i;
F64 t0=tS;
do {
for (i=0;i<1024;i++) {
gr.dc->color=RandU16&15;
GrPlot(gr.dc,RandU32%GR_WIDTH,RandU32%GR_HEIGHT);
}
Yield;
} while (tS-t0<1);
DCFill;
}
U0 RandDemo()
{
I64 i;
"Seed(0) will do timer XORed random numbers. "
"A task starts with Seed(0) by dft.\n";
PressAKey;
Seed;
RandPts;
DCFill;
"\nSeed(num) will do deterministic, non-timer random numbers starting at "
"a specific seed. You can run a specific video game over and over "
"by typing Seed(num) at the cmd line before the game.\n";
PressAKey;
Seed(1);
RandPts;
DCFill;
"\n\n\nWatch when we specify specific seeds:";
"\n\nSeed(1);\n";
Seed(1);
for (i=0;i<5;i++)
"%d: %d\n",i,RandI16;
"\nSeed(2); Different, right?\n";
Seed(2);
for (i=0;i<5;i++)
"%d: %d\n",i,RandI16;
"\nSeed(1); Repeats earlier values.\n";
Seed(1);
for (i=0;i<5;i++)
"%d: %d\n",i,RandI16;
"\nSeed(0); Zero is special.\n";
Seed(0);
for (i=0;i<5;i++)
"%d: %d\n",i,RandI16;
"\nSeed(0); Non-repeating.\n";
Seed(0);
for (i=0;i<5;i++)
"%d: %d\n",i,RandI16;
Seed; //Dft should be kept to zero.
}
RandDemo;
|