line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Poker::Eval::Badugi; |
2
|
1
|
|
|
1
|
|
2132
|
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.01 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
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 = { score => 0 }; |
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 = { |
43
|
|
|
|
|
|
|
score => $score, |
44
|
|
|
|
|
|
|
hand => \@list, |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
$best->{name} = $self->scorer->hand_name( $best->{score} ); |
49
|
|
|
|
|
|
|
return $best; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 AUTHOR |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
61
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
62
|
|
|
|
|
|
|
copy of the full license at: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |