| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Poker::Eval::Badugi; |
|
2
|
1
|
|
|
1
|
|
1491
|
use Algorithm::Combinatorics qw(combinations); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Moo; |
|
4
|
|
|
|
|
|
|
use Poker::Score::Badugi; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Poker::Eval::Badugi - Evaluate and score Badugi poker hands. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.02 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
See Poker::Eval for code examples |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
extends 'Poker::Eval'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub best_hand { |
|
28
|
|
|
|
|
|
|
my ( $self, $hole ) = @_; |
|
29
|
|
|
|
|
|
|
my $best = Poker::Hand->new(cards => $hole); |
|
30
|
|
|
|
|
|
|
my $iter = combinations( $hole, scalar @$hole > 4 ? 4 : scalar @$hole); |
|
31
|
|
|
|
|
|
|
while (my $combo = $iter->next ) { |
|
32
|
|
|
|
|
|
|
my (@list, %seen); |
|
33
|
|
|
|
|
|
|
for my $c (sort { $self->scorer->_rank_map->{$a->rank} <=> $self->scorer->_rank_map->{$b->rank} } @$combo) { |
|
34
|
|
|
|
|
|
|
if ( !$seen{ $c->suit } && !$seen{ $c->rank } ) { |
|
35
|
|
|
|
|
|
|
push @list, $c; |
|
36
|
|
|
|
|
|
|
$seen{ $c->suit }++; |
|
37
|
|
|
|
|
|
|
$seen{ $c->rank }++; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
my $score = $self->scorer->score( [@list] ); |
|
41
|
|
|
|
|
|
|
if ( defined $score && $score >= $best->score ) { |
|
42
|
|
|
|
|
|
|
$best->score($score); |
|
43
|
|
|
|
|
|
|
$best->best_combo(\@list); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
$best->name($self->scorer->hand_name( $best->score )); |
|
47
|
|
|
|
|
|
|
return $best; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 AUTHOR |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
59
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
60
|
|
|
|
|
|
|
copy of the full license at: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |