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