line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::ABC_Path::MicrosoftRand; |
2
|
|
|
|
|
|
|
$Games::ABC_Path::MicrosoftRand::VERSION = '0.4.3'; |
3
|
3
|
|
|
3
|
|
89553
|
use 5.006; |
|
3
|
|
|
|
|
22
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
101
|
|
5
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
107
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
15
|
use integer; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Class::XSAccessor { |
11
|
3
|
|
|
|
|
87
|
constructor => 'new', |
12
|
|
|
|
|
|
|
accessors => [qw(seed)], |
13
|
3
|
|
|
3
|
|
1564
|
}; |
|
3
|
|
|
|
|
7177
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub rand |
16
|
|
|
|
|
|
|
{ |
17
|
101
|
|
|
101
|
1
|
237
|
my $self = shift; |
18
|
101
|
|
|
|
|
213
|
$self->seed( ( $self->seed() * 214013 + 2531011 ) & (0x7FFF_FFFF) ); |
19
|
101
|
|
|
|
|
211
|
return ( ( $self->seed >> 16 ) & 0x7fff ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub max_rand |
23
|
|
|
|
|
|
|
{ |
24
|
98
|
|
|
98
|
1
|
167
|
my ( $self, $max ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
98
|
|
|
|
|
150
|
return ( $self->rand() % $max ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub shuffle |
30
|
|
|
|
|
|
|
{ |
31
|
53
|
|
|
53
|
1
|
627
|
my ( $self, $deck ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
53
|
100
|
|
|
|
106
|
if (@$deck) |
34
|
|
|
|
|
|
|
{ |
35
|
52
|
|
|
|
|
89
|
my $i = @$deck; |
36
|
52
|
|
|
|
|
100
|
while ( --$i ) |
37
|
|
|
|
|
|
|
{ |
38
|
97
|
|
|
|
|
177
|
my $j = $self->max_rand( $i + 1 ); |
39
|
97
|
|
|
|
|
245
|
@$deck[ $i, $j ] = @$deck[ $j, $i ]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
53
|
|
|
|
|
153
|
return $deck; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; # End of Games::ABC_Path::MicrosoftRand |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |