Mersenne Twister for ActionScript 3
I tried porting Mersenne Twister to ActionScript.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/mt19937ar.html
overview
- I don't think it will work unless it's Flash Player 11 or later.
- I'm using FlasCC 1.0.1 to build the distribution code as is.
- When you build it, it will be output in SWC.
- as3api.c is the interface part with Flash. I'm not using SWIG.
- The ActionScript sample is in the sample folder.
How to build with FlasCC
I only know about Windows,
- Starting cygwin from FlasCC_1.0.1/run.bat
- export LANG=C
Enter - Move to the directory where the source code is located with cd
- make FLASCC="/path/to/FlasCC_1.0.1/sdk" FLEX="/path/to/flex_sdk_4.6/"
I think make will pass
Operation check environment
- FlashDevelop 4.3.0
- Flex SDK 4.6
- Flash Player 11
- FlasCC 1.0.1
Operating speed
I compared it to Math.random() (when I ran 1 million times with a Debug build).
- Math.random() : 112ms
- genrand_int32() : 250ms
- genrand_int31() : 252ms
- genrand_real1() : 253ms
- genrand_real2() : 255ms
- genrand_real3() : 251ms
- genrand_res53() : 360ms