2020-02-15 20:01:48 +00:00
|
|
|
U0 RandPts()
|
|
|
|
{
|
2020-02-20 23:40:10 +00:00
|
|
|
I64 i;
|
2020-12-23 23:27:18 +00:00
|
|
|
F64 t0 = tS;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
for (i = 0; i < 1024; i++)
|
|
|
|
{
|
|
|
|
gr.dc->color = RandU16 & 15;
|
|
|
|
GrPlot(gr.dc, RandU32 % GR_WIDTH, RandU32 % GR_HEIGHT);
|
2020-02-20 23:40:10 +00:00
|
|
|
}
|
|
|
|
Yield;
|
2020-12-23 23:27:18 +00:00
|
|
|
}
|
|
|
|
while (tS - t0 < 1);
|
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
DCFill;
|
2020-02-15 20:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
U0 RandDemo()
|
|
|
|
{
|
2020-02-20 23:40:10 +00:00
|
|
|
I64 i;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-03-01 01:59:50 +00:00
|
|
|
"Seed(0) will do timer XORed random numbers. "
|
2021-12-11 11:21:22 +00:00
|
|
|
"A task starts with $LK,"Seed(0)",A="FF:::/Kernel/KTask.ZC,Seed("$ by default.\n";
|
2020-02-20 23:40:10 +00:00
|
|
|
PressAKey;
|
|
|
|
Seed;
|
|
|
|
RandPts;
|
|
|
|
DCFill;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\nSeed(num) will do deterministic, non-timer random numbers starting at "
|
2020-12-23 23:27:18 +00:00
|
|
|
"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";
|
2020-02-20 23:40:10 +00:00
|
|
|
PressAKey;
|
|
|
|
Seed(1);
|
|
|
|
RandPts;
|
|
|
|
DCFill;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\n\n\nWatch when we specify specific seeds:";
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\n\nSeed(1);\n";
|
|
|
|
Seed(1);
|
2020-12-23 23:27:18 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
"%d: %d\n", i, RandI16;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\nSeed(2); Different, right?\n";
|
|
|
|
Seed(2);
|
2020-12-23 23:27:18 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
"%d: %d\n", i, RandI16;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\nSeed(1); Repeats earlier values.\n";
|
|
|
|
Seed(1);
|
2020-12-23 23:27:18 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
"%d: %d\n", i, RandI16;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\nSeed(0); Zero is special.\n";
|
|
|
|
Seed(0);
|
2020-12-23 23:27:18 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
"%d: %d\n", i, RandI16;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
"\nSeed(0); Non-repeating.\n";
|
|
|
|
Seed(0);
|
2020-12-23 23:27:18 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
"%d: %d\n", i, RandI16;
|
2020-02-15 20:01:48 +00:00
|
|
|
|
2020-02-20 23:40:10 +00:00
|
|
|
Seed; //Default should be kept to zero.
|
2020-02-15 20:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RandDemo;
|