| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Poker::Score::Bring::Wild; |
|
2
|
1
|
|
|
1
|
|
647
|
use Moo; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
3
|
|
|
3
|
1
|
|
|
1
|
|
165
|
use Algorithm::Combinatorics qw(combinations combinations_with_repetition); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use List::Util qw(max); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1041
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Poker::Score::Bring::Wild - Scoring system used in highball Stud with wildcards to decide which player starts the action. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.01 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
See Poker::Score for code example. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
extends 'Poker::Score::Bring::High'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub score { |
|
28
|
0
|
|
|
0
|
1
|
|
my ( $self, $hole ) = @_; |
|
29
|
0
|
|
|
|
|
|
my $score = 0; |
|
30
|
0
|
|
|
|
|
|
my ( @wild, @normal ); |
|
31
|
0
|
|
|
|
|
|
for my $card (@$hole) { |
|
32
|
0
|
0
|
|
|
|
|
if ( $card->is_wild ) { |
|
33
|
0
|
|
|
|
|
|
push @wild, $card; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
else { |
|
36
|
0
|
|
|
|
|
|
push @normal, $card; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
0
|
|
|
|
|
|
my $wild_count = scalar @wild; |
|
40
|
0
|
|
|
|
|
|
my $norm_count = scalar @normal; |
|
41
|
0
|
|
|
|
|
|
my @wild_combos; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if ( $norm_count == 0 ) { |
|
|
|
0
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $flat_hand = '14' x $wild_count; |
|
45
|
0
|
|
|
|
|
|
$score = $self->hand_score($flat_hand); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
elsif ( $wild_count == 3 ) { |
|
49
|
0
|
|
|
|
|
|
my @ranks = sort { $a <=> $b } |
|
50
|
0
|
|
|
|
|
|
map { $self->rank_val( $_->rank ) } @normal; |
|
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $high_rank = sprintf( "%02d", pop @ranks ); |
|
52
|
0
|
|
|
|
|
|
my $flat_hand = join '', ($high_rank) x 4; |
|
53
|
0
|
|
|
|
|
|
$score = $self->hand_score($flat_hand); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
else { |
|
57
|
|
|
|
|
|
|
@wild_combos = |
|
58
|
0
|
|
|
|
|
|
combinations_with_repetition( [ map { sprintf( "%02d", $_ ) } 2 .. 14 ], |
|
|
0
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$wild_count ); |
|
60
|
0
|
|
|
|
|
|
my $norm_iter = combinations( [@normal], $norm_count ); |
|
61
|
0
|
|
|
|
|
|
while ( my $norm_combo = $norm_iter->next ) { |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my @norm_ranks = map { $self->rank_val( $_->rank ) } @$norm_combo; |
|
|
0
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
for my $wild_combo (@wild_combos) { |
|
65
|
|
|
|
|
|
|
my $flat_combo = |
|
66
|
0
|
|
|
|
|
|
join( '', sort { $b <=> $a } ( @$wild_combo, @norm_ranks ) ); |
|
|
0
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $temp_score = $self->hand_score($flat_combo); |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
0
|
0
|
|
|
|
if ( defined $temp_score && $temp_score >= $score ) { |
|
71
|
0
|
|
|
|
|
|
$score = $temp_score; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
|
return $score . '.05'; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _build_hands { # generates all possible bring hands |
|
80
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# one card |
|
83
|
0
|
|
|
|
|
|
my @hands = @{ $self->unpaired1 }; |
|
|
0
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# two cards |
|
86
|
0
|
|
|
|
|
|
push( @hands, @{ $self->unpaired2 } ); |
|
|
0
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
push( @hands, @{ $self->one_pair2 } ); |
|
|
0
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# three cards |
|
90
|
0
|
|
|
|
|
|
push( @hands, @{ $self->unpaired3 } ); |
|
|
0
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
push( @hands, @{ $self->one_pair3 } ); |
|
|
0
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
push( @hands, @{ $self->threes3 } ); |
|
|
0
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# four cards |
|
95
|
0
|
|
|
|
|
|
push( @hands, @{ $self->unpaired4 } ); |
|
|
0
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
push( @hands, @{ $self->one_pair4 } ); |
|
|
0
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
push( @hands, @{ $self->two_pair4 } ); |
|
|
0
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
push( @hands, @{ $self->threes4 } ); |
|
|
0
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
push( @hands, @{ $self->fours4 } ); |
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$self->hands( [@hands] ); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
############ |
|
105
|
|
|
|
|
|
|
# one card # |
|
106
|
|
|
|
|
|
|
############ |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# unpaired |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub unpaired1 { |
|
111
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
112
|
0
|
|
|
|
|
|
for my $card ( 2 .. 14 ) { |
|
113
|
0
|
|
|
|
|
|
push @temp, join( '', sprintf( "%02d", $card ) ); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
0
|
|
|
|
|
|
return [@temp]; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
############# |
|
119
|
|
|
|
|
|
|
# two cards # |
|
120
|
|
|
|
|
|
|
############# |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# unpaired |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub unpaired2 { |
|
125
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
126
|
0
|
|
|
|
|
|
my @scores; |
|
127
|
0
|
|
|
|
|
|
my $iter = combinations( [ reverse( 2 .. 14 ) ], 2 ); |
|
128
|
0
|
|
|
|
|
|
while ( my $c = $iter->next ) { |
|
129
|
|
|
|
|
|
|
push( @scores, |
|
130
|
0
|
|
|
|
|
|
join( "", map { sprintf( "%02d", $_ ) } sort { $b <=> $a } @$c ) ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
|
132
|
0
|
|
|
|
|
|
return [ sort { $a <=> $b } @scores ]; |
|
|
0
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# one pair |
|
136
|
|
|
|
|
|
|
sub one_pair2 { |
|
137
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
138
|
0
|
|
|
|
|
|
for my $card ( 2 .. 14 ) { |
|
139
|
|
|
|
|
|
|
push @temp, |
|
140
|
|
|
|
|
|
|
join( '', |
|
141
|
0
|
|
|
|
|
|
map { sprintf( "%02d", $_ ) } |
|
142
|
0
|
|
|
|
|
|
sort { $b <=> $a } ( ($card) x 2 ) ); |
|
|
0
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
} |
|
144
|
0
|
|
|
|
|
|
return [@temp]; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
############### |
|
148
|
|
|
|
|
|
|
# three cards # |
|
149
|
|
|
|
|
|
|
############### |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# unpaired |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub unpaired3 { |
|
154
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
155
|
0
|
|
|
|
|
|
my @scores; |
|
156
|
0
|
|
|
|
|
|
my $iter = combinations( [ reverse( 2 .. 14 ) ], 3 ); |
|
157
|
0
|
|
|
|
|
|
while ( my $c = $iter->next ) { |
|
158
|
|
|
|
|
|
|
push( @scores, |
|
159
|
0
|
|
|
|
|
|
join( "", map { sprintf( "%02d", $_ ) } sort { $b <=> $a } @$c ) ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
} |
|
161
|
0
|
|
|
|
|
|
return [ sort { $a <=> $b } @scores ]; |
|
|
0
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# one pair |
|
165
|
|
|
|
|
|
|
sub one_pair3 { |
|
166
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
167
|
0
|
|
|
|
|
|
for my $card1 ( 2 .. 14 ) { |
|
168
|
0
|
|
|
|
|
|
for my $card2 ( grep { $_ != $card1 } ( 2 .. 14 ) ) { |
|
|
0
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
push @temp, |
|
170
|
|
|
|
|
|
|
join( '', |
|
171
|
0
|
|
|
|
|
|
map { sprintf( "%02d", $_ ) } |
|
172
|
0
|
|
|
|
|
|
sort { $b <=> $a } ( ($card1) x 2, $card2 ) ); |
|
|
0
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
} |
|
175
|
0
|
|
|
|
|
|
return [@temp]; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# three-of-a-kind |
|
179
|
|
|
|
|
|
|
sub threes3 { |
|
180
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
181
|
0
|
|
|
|
|
|
for my $card1 ( 2 .. 14 ) { |
|
182
|
|
|
|
|
|
|
push @temp, |
|
183
|
|
|
|
|
|
|
join( |
|
184
|
0
|
|
|
|
|
|
'', map { sprintf( "%02d", $_ ) } |
|
185
|
0
|
|
|
|
|
|
sort { $b <=> $a } ($card1) x 3 |
|
|
0
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
0
|
|
|
|
|
|
return [@temp]; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
############## |
|
192
|
|
|
|
|
|
|
# four cards # |
|
193
|
|
|
|
|
|
|
############## |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# unpaired |
|
196
|
|
|
|
|
|
|
sub unpaired4 { |
|
197
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
198
|
0
|
|
|
|
|
|
my @scores; |
|
199
|
0
|
|
|
|
|
|
my $iter = combinations( [ reverse( 2 .. 14 ) ], 4 ); |
|
200
|
0
|
|
|
|
|
|
while ( my $c = $iter->next ) { |
|
201
|
|
|
|
|
|
|
push( @scores, |
|
202
|
0
|
|
|
|
|
|
join( "", map { sprintf( "%02d", $_ ) } sort { $b <=> $a } @$c ) ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
} |
|
204
|
0
|
|
|
|
|
|
return [ sort { $a <=> $b } @scores ]; |
|
|
0
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# one pair |
|
208
|
|
|
|
|
|
|
sub one_pair4 { |
|
209
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
210
|
0
|
|
|
|
|
|
for my $card1 ( 2 .. 14 ) { |
|
211
|
0
|
|
|
|
|
|
for my $card2 ( |
|
212
|
0
|
|
|
|
|
|
reverse combinations( [ reverse grep { $_ != $card1 } ( 2 .. 14 ) ], 2 ) ) |
|
213
|
|
|
|
|
|
|
{ |
|
214
|
|
|
|
|
|
|
push @temp, |
|
215
|
|
|
|
|
|
|
join( '', |
|
216
|
0
|
|
|
|
|
|
map { sprintf( "%02d", $_ ) } |
|
217
|
0
|
|
|
|
|
|
sort { $b <=> $a } ( ($card1) x 2, @$card2 ) ); |
|
|
0
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
} |
|
220
|
0
|
|
|
|
|
|
return [@temp]; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# two pair |
|
224
|
|
|
|
|
|
|
sub two_pair4 { |
|
225
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
226
|
0
|
|
|
|
|
|
for my $card1 ( reverse combinations( [ reverse( 2 .. 14 ) ], 2 ) ) { |
|
227
|
|
|
|
|
|
|
push @temp, |
|
228
|
|
|
|
|
|
|
join( '', |
|
229
|
0
|
|
|
|
|
|
map { sprintf( "%02d", $_ ) } |
|
230
|
0
|
|
|
|
|
|
sort { $b <=> $a } ( ( $card1->[0] ) x 2, ( $card1->[1] ) x 2 ) ); |
|
|
0
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
} |
|
232
|
0
|
|
|
|
|
|
return [@temp]; |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# three-of-a-kind |
|
236
|
|
|
|
|
|
|
sub threes4 { |
|
237
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
238
|
0
|
|
|
|
|
|
for my $card1 ( 2 .. 14 ) { |
|
239
|
0
|
|
|
|
|
|
for my $card2 ( grep { $_ != $card1 } ( 2 .. 14 ) ) { |
|
|
0
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
push @temp, |
|
241
|
|
|
|
|
|
|
join( '', |
|
242
|
0
|
|
|
|
|
|
map { sprintf( "%02d", $_ ) } |
|
243
|
0
|
|
|
|
|
|
sort { $b <=> $a } ($card1) x 3, ($card2) ); |
|
|
0
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
} |
|
246
|
0
|
|
|
|
|
|
return [@temp]; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
# four-of-a-kind |
|
250
|
|
|
|
|
|
|
sub fours4 { |
|
251
|
0
|
|
|
0
|
0
|
|
my @temp; |
|
252
|
0
|
|
|
|
|
|
for my $card ( 2 .. 14 ) { |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
#for my $suit ( qw(c d h s) ) { |
|
255
|
0
|
|
|
|
|
|
push @temp, join( '', map { sprintf( "%02d", $_ ) } ($card) x 4 ); |
|
|
0
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
#($card) x 4 ) . $suit; |
|
258
|
|
|
|
|
|
|
#} |
|
259
|
|
|
|
|
|
|
} |
|
260
|
0
|
|
|
|
|
|
return [@temp]; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 AUTHOR |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
272
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
273
|
|
|
|
|
|
|
copy of the full license at: |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
L |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=cut |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
1; |