line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Poker::Eval::Community; |
2
|
1
|
|
|
1
|
|
1446
|
use Algorithm::Combinatorics qw(combinations); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
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.02 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
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
|
0
|
|
|
0
|
|
|
return 5; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub best_hand { |
36
|
0
|
|
|
0
|
1
|
|
my ( $self, $hole ) = @_; |
37
|
0
|
|
|
|
|
|
my $hand = Poker::Hand->new(cards => $hole); |
38
|
|
|
|
|
|
|
return $hand |
39
|
|
|
|
|
|
|
if $self->card_count > |
40
|
0
|
0
|
|
|
|
|
( scalar @$hole + scalar @{ $self->community_cards } ); |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $iter = $self->make_iter($hole); |
42
|
0
|
|
|
|
|
|
while ( my $combo = $iter->next ) { |
43
|
0
|
|
|
|
|
|
my $score = $self->scorer->score($combo); |
44
|
0
|
0
|
0
|
|
|
|
if ( defined $score && $score >= $hand->score ) { |
45
|
0
|
|
|
|
|
|
$hand->score($score); |
46
|
0
|
|
|
|
|
|
$hand->best_combo($combo); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
$hand->name($self->scorer->hand_name( $hand->score )); |
50
|
0
|
|
|
|
|
|
return $hand; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub make_iter { |
54
|
0
|
|
|
0
|
0
|
|
my ( $self, $hole ) = @_; |
55
|
|
|
|
|
|
|
my $iter = |
56
|
0
|
|
|
|
|
|
combinations( [ @$hole, @{ $self->community_cards } ], $self->card_count ); |
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $iter; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
69
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
70
|
|
|
|
|
|
|
copy of the full license at: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |