3

Can anyone point me to an example of creating consistent random values in actionscript. I assume this would, be by using a consistent seed value

1 Answer 1

7

I think there is no way doing this using standard Math.random(). But you can write your own generator. Linear congruential generators (like Randu) are fast, and really simple to implement (just few lines of code), but they are not perfect. For games, it is fine, but for some scientific calculations (I don't expect you are doing some in actionscript), you may encounter problems. If you are interested, read for example http://en.wikipedia.org/wiki/Linear_congruential_generator#Advantages_and_disadvantages_of_LCGs

Or I found this implementation of Mersenne Twister generator: http://web.archive.org/web/20080218041026/http://www.devslash.com/?p=97 It is little slower, but it should be more robust than LCG generators.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.