home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Puzzle
/
HexiomConnect.swf
/
scripts
/
RandomNumber.as
< prev
next >
Wrap
Text File
|
2008-08-29
|
2KB
|
69 lines
package
{
public class RandomNumber
{
private static var MT:Array = new Array();
private static var currentIndex:int = 0;
public function RandomNumber()
{
super();
}
public static function initialize(param1:int) : void
{
MT[0] = param1;
var _loc2_:int = 1;
while(_loc2_ < 624)
{
MT[_loc2_] = 1812433253 * (MT[_loc2_ - 1] ^ MT[_loc2_ - 1] >> 30) + _loc2_;
_loc2_++;
}
generateNumbers();
}
public static function random() : Number
{
var _loc1_:int = extractNumber(currentIndex);
++currentIndex;
if(currentIndex >= 624)
{
generateNumbers();
}
return _loc1_ / int.MAX_VALUE;
}
private static function generateNumbers() : void
{
var _loc2_:int = 0;
var _loc1_:int = 0;
while(_loc1_ < 624)
{
_loc2_ = (MT[_loc1_] & 1) + (MT[(_loc1_ + 1) % 624] & 2147483647);
if(_loc2_ % 2 == 0)
{
MT[_loc1_] = MT[(_loc1_ + 397) % 624] ^ _loc2_ >> 1;
}
else
{
MT[_loc1_] = MT[(_loc1_ + 397) % 624] ^ _loc2_ >> 1 ^ 2567483615;
}
_loc1_++;
}
currentIndex = 0;
}
private static function extractNumber(param1:int) : int
{
var _loc2_:* = int(MT[param1]);
_loc2_ ^= _loc2_ >> 11;
_loc2_ ^= _loc2_ << 7 & 2636928640;
_loc2_ ^= _loc2_ << 15 & 4022730752;
return _loc2_ ^ _loc2_ >> 18;
}
}
}