| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Poker::Eval::Community; |
|
2
|
1
|
|
|
1
|
|
2025
|
use Algorithm::Combinatorics qw(combinations); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Moo; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Poker::Eval::Community - Evaluate and score hand using any combination of hole and community cards. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Version 0.01 |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
See Poker::Eval for example code. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
extends 'Poker::Eval'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'card_count' => ( |
|
27
|
|
|
|
|
|
|
is => 'rw', |
|
28
|
|
|
|
|
|
|
builder => '_build_card_count', |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _build_card_count { |
|
32
|
|
|
|
|
|
|
return 5; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub best_hand { |
|
36
|
|
|
|
|
|
|
my ( $self, $hole ) = @_; |
|
37
|
|
|
|
|
|
|
my $best = { score => 0 }; |
|
38
|
|
|
|
|
|
|
return $best |
|
39
|
|
|
|
|
|
|
if $self->card_count > |
|
40
|
|
|
|
|
|
|
( scalar @$hole + scalar @{ $self->community_cards } ); |
|
41
|
|
|
|
|
|
|
my $iter = $self->make_iter($hole); |
|
42
|
|
|
|
|
|
|
while ( my $combo = $iter->next ) { |
|
43
|
|
|
|
|
|
|
my $score = $self->scorer->score($combo); |
|
44
|
|
|
|
|
|
|
if ( defined $score && $score >= $best->{score} ) { |
|
45
|
|
|
|
|
|
|
$best = { |
|
46
|
|
|
|
|
|
|
score => $score, |
|
47
|
|
|
|
|
|
|
hand => $combo, |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
$best->{name} = $self->scorer->hand_name( $best->{score} ); |
|
52
|
|
|
|
|
|
|
return $best; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub make_iter { |
|
56
|
|
|
|
|
|
|
my ( $self, $hole ) = @_; |
|
57
|
|
|
|
|
|
|
my $iter = |
|
58
|
|
|
|
|
|
|
combinations( [ @$hole, @{ $self->community_cards } ], $self->card_count ); |
|
59
|
|
|
|
|
|
|
return $iter; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
71
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
72
|
|
|
|
|
|
|
copy of the full license at: |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |