Hi Craig,
The random numbers in LiveCode are comparable with a table of true random numbers. The random seed is where you start reading in the table. If the table is "5,4,3,6,2,8,1,9,7,8,0" and the randomseed is 4, then you start reading at 6 in the table and the next number is 2. This means that the randomseed changes while you read from the table, following the pattern 4,5,6...,1,2,3... Each time when you finish the table, you just continue counting at the start. This way, you make sure that you preserve the randomness of the table.
I know that this doesn't seem random to most people, but the purpose is to have a statistically random list of numbers, rather than an intuitively list of numbers. For most purposes in programming, statistical randomness is sufficient. If it isn't, then you should ask the user to throw dice, draw a card or something similar from the real world.
Key to randomness is to remember the randomseed. If you always start with the same randomseed 4 in the example above, then your list will always be 6,2,8,1,9,7,8,0,5,4,3, 6... and your numbers are no longer statistically random. Once upon a time in the past someone decided purely randomly to set the randomseed to a starting number and from that moment on LiveCode just kept counting each time when you use the random function. Because the first randomseed was a random number and the table itself consists of random numbers, you're always getting statistically random numbers.
(Just to be complete: I don't think that the random table is an actual table. I think it is a function, which the processor can executing directly, simulating the table and hence isn't completely random after all, but it is sufficient for programming).
Here's a simple demo:
Code: Select all
on mouseUp
set the randomseed to 1234567890
repeat 10
put random(10) & comma after myList
end repeat
put item 1 to -2 of myList
end mouseUp
This script always returns the same "random" numbers. They are still statistically random, but because they are always the same they are probably not suitable for programming.
Kind regards,
Mark