Jump to content

Random Number Generator


Recommended Posts

Most likely random enough..
for i = 1 to 10
	//Official
	display("Method 1 -"+list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).shuffle.first)
	display("Method 2 -"+mid(millisecondClockValue().asString,12).asInteger)
	//Unofficial
	display("Method 3 -"+executeCode("LaggedFibonacciRandom new").seed)
next i

Please sign in to view this quote.

Look who's doing a guest appearance. Nice to see you here again.
What does the ".seed"-thing do?

OnT: Depending on how big you want the random number to be. Something like this:
//Takes some random parameters that are very hard to predict and makes a string of their numerical hashes
LongStringOfNumbers = millisecondClockValue().asString.hash + getPositionCMM().x.asString.hash + getPositionCMM().y.asString.hash+ getPositionCMM().z.asString.hash

//converts the long string to a number
RandomHighValue = val(LongStringOfNumbers)

//If you want a random number between 1 and 100
RandomValueBetween = mod(RandomHighValue,100) +1 

There might be some errors in there. I'm not on the Calypso computer right now so I can't test it.
The good thing about using the actual position of the CMM is that it is like 6 decimals and it always drifts a little so it becomes extremely hard to predict and even harder to replicate.
×
×
  • Create New...