line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::RNG::Microsoft; |
2
|
|
|
|
|
|
|
$Math::RNG::Microsoft::VERSION = '0.2.0'; |
3
|
1
|
|
|
1
|
|
89737
|
use 5.006; |
|
1
|
|
|
|
|
14
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Class::XSAccessor { |
11
|
1
|
|
|
|
|
8
|
constructor => 'new', |
12
|
|
|
|
|
|
|
accessors => [qw(seed)], |
13
|
1
|
|
|
1
|
|
972
|
}; |
|
1
|
|
|
|
|
2423
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub rand |
16
|
|
|
|
|
|
|
{ |
17
|
12
|
|
|
12
|
1
|
124
|
my $self = shift; |
18
|
12
|
|
|
|
|
36
|
$self->seed( ( $self->seed() * 214013 + 2531011 ) & (0x7FFF_FFFF) ); |
19
|
12
|
|
|
|
|
34
|
return ( ( $self->seed >> 16 ) & 0x7fff ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub max_rand |
23
|
|
|
|
|
|
|
{ |
24
|
9
|
|
|
9
|
1
|
13
|
my ( $self, $max ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
9
|
|
|
|
|
13
|
return ( $self->rand() % $max ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub shuffle |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
|
|
1
|
1
|
539
|
my ( $self, $deck ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
5
|
if (@$deck) |
34
|
|
|
|
|
|
|
{ |
35
|
1
|
|
|
|
|
2
|
my $i = @$deck; |
36
|
1
|
|
|
|
|
3
|
while ( --$i ) |
37
|
|
|
|
|
|
|
{ |
38
|
9
|
|
|
|
|
19
|
my $j = $self->max_rand( $i + 1 ); |
39
|
9
|
|
|
|
|
22
|
@$deck[ $i, $j ] = @$deck[ $j, $i ]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
3
|
return $deck; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; # End of Math::RNG::Microsoft |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |