line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::RNG::Microsoft; |
2
|
|
|
|
|
|
|
$Math::RNG::Microsoft::VERSION = '0.0.5'; |
3
|
1
|
|
|
1
|
|
87454
|
use 5.006; |
|
1
|
|
|
|
|
15
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Class::XSAccessor { |
11
|
1
|
|
|
|
|
8
|
constructor => 'new', |
12
|
|
|
|
|
|
|
accessors => [qw(seed)], |
13
|
1
|
|
|
1
|
|
514
|
}; |
|
1
|
|
|
|
|
2678
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub rand |
16
|
|
|
|
|
|
|
{ |
17
|
12
|
|
|
12
|
1
|
124
|
my $self = shift; |
18
|
12
|
|
|
|
|
33
|
$self->seed( ( $self->seed() * 214013 + 2531011 ) & (0x7FFF_FFFF) ); |
19
|
12
|
|
|
|
|
36
|
return ( ( $self->seed >> 16 ) & 0x7fff ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub max_rand |
23
|
|
|
|
|
|
|
{ |
24
|
9
|
|
|
9
|
1
|
13
|
my ( $self, $max ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
9
|
|
|
|
|
15
|
return ( $self->rand() % $max ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub shuffle |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
|
|
1
|
1
|
533
|
my ( $self, $deck ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
4
|
if (@$deck) |
34
|
|
|
|
|
|
|
{ |
35
|
1
|
|
|
|
|
3
|
my $i = @$deck; |
36
|
1
|
|
|
|
|
4
|
while ( --$i ) |
37
|
|
|
|
|
|
|
{ |
38
|
9
|
|
|
|
|
18
|
my $j = $self->max_rand( $i + 1 ); |
39
|
9
|
|
|
|
|
21
|
@$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__ |