In Manual 2, under the 'Random' command, is stated:
"On computers a changing quantity (such as the date/time) is used as the start of the calculation, so that each random command is different. The PICAXE does not contain such date functionality, and so the sequence it generates will always be identical unless the value of the word variable is set to a different value before the random command is used."
In using the simulator (08M), I notice that if the same seed is repeatedly used, DIFFERENT random numbers are generated, not the same 'random' number as the text indicates would be the case in an operating 08M with the same algorithm always operating on that same seed.
Try this (leave the seed at 0 in the analog input field in the simulator, and you will see that W5 takes on different values, over and over again):
RndCalc:
W5=W6
ReadADC10 1,W6
Random W6
Pause 1000
If W6<>W5 then Goto RndCalc
I watched for perhaps 10 iterations and did not notice any repeat sequences, nor did W6 ever equal W5 (although, eventually this is bound to occur).
Is the simulator working differently than the hardware does, or has the PicBasic 'Random' command been updated to operate as the simulator does? Perhaps the command might now use an internal timer running asynchronously to the command, thus producing a modified algorithm on each iteration even though the seed remains the same?
Thanks, Odessa.
PS I know I could run tests to determine this, however, before doing so, if necessary, I am trying to find out if anyone may have already done that, or otherwise determined the answer to this issue.
Thanks, Odessa
"On computers a changing quantity (such as the date/time) is used as the start of the calculation, so that each random command is different. The PICAXE does not contain such date functionality, and so the sequence it generates will always be identical unless the value of the word variable is set to a different value before the random command is used."
In using the simulator (08M), I notice that if the same seed is repeatedly used, DIFFERENT random numbers are generated, not the same 'random' number as the text indicates would be the case in an operating 08M with the same algorithm always operating on that same seed.
Try this (leave the seed at 0 in the analog input field in the simulator, and you will see that W5 takes on different values, over and over again):
RndCalc:
W5=W6
ReadADC10 1,W6
Random W6
Pause 1000
If W6<>W5 then Goto RndCalc
I watched for perhaps 10 iterations and did not notice any repeat sequences, nor did W6 ever equal W5 (although, eventually this is bound to occur).
Is the simulator working differently than the hardware does, or has the PicBasic 'Random' command been updated to operate as the simulator does? Perhaps the command might now use an internal timer running asynchronously to the command, thus producing a modified algorithm on each iteration even though the seed remains the same?
Thanks, Odessa.
PS I know I could run tests to determine this, however, before doing so, if necessary, I am trying to find out if anyone may have already done that, or otherwise determined the answer to this issue.
Thanks, Odessa