public function mt($index = null, $min = 0, $max = 1000)
    {
        static $op = array(0x0, 0x9908b0df); // Used for efficiency below to eliminate if statement
        static $mt = array(); // 624 element array used to get random numbers
     
        // Regenerate when reseeding or seeding initially
        if($this->seed !== $this->ps)
        {
            $s = $this->seed & 0xffffffff;
            $mt = array(&$s, 624 => &$s);
            $this->ps = $this->seed;
     
            for($i = 1; $i < 624; ++$i)
                $mt[$i] = (0x6c078965 * ($mt[$i - 1] ^ ($mt[$i - 1] >> 30)) + $i) & 0xffffffff;
     
            // This has been tweaked for maximum speed and elegance
            // Explanation of possibly confusing variables:
            //   $p = previous index
            //   $sp = split parts of array - the numbers at which to stop and continue on
            //   $n = number to iterate to - we loop up to 227 adding 397 after which we finish looping up to 624 subtracting 227 to continue getting out 397 indices ahead reference
            //   $m = 397 or -227 to add to $i to keep our 397 index difference
            //   $i = the previous element in $sp, our starting index in this iteration
            for($j = 1, $sp = array(0, 227, 397); $j < count($sp); ++$j)
            {
                for($p = $j - 1, $i = $sp[$p], $m = ((624 - $sp[$j]) * ($p ? -1 : 1)), $n = ($sp[$j] + $sp[$p]); $i < $n; ++$i)
                {
                    $y = ($mt[$i] & 0x80000000) | ($mt[$i + 1] & 0x7fffffff);
                    $mt[$i] = $mt[$i + $m] ^ ($y >> 1) ^ $op[$y & 0x1];
                }
            }
        }
     
        // Select a number from the array and randomize it
        $y = $mt[$this->index = $this->index % 624];
        $y ^= $y >> 11;
        $y ^= ($y << 7) & 0x9d2c5680;
        $y ^= ($y << 15) & 0xefc60000;
        $y ^= $y >> 18;
     
        return $y % ($max - $min + 1) + $min;
    }