line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Poker::Eval::Omaha; |
2
|
1
|
|
|
1
|
|
625
|
use Algorithm::Combinatorics qw(combinations); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Poker::Eval::Omaha - Evaluate and score Omaha poker hands. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Version 0.02 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
See Poker::Eval for code example. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 INTRODUCTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
In Omaha style games, the best hand is made using EXACTLY two hole cards and EXACTLY three community cards. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
extends 'Poker::Eval'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has '_combos' => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => sub { die "Not an array ref!" unless ref($_[0]) eq 'ARRAY' }, |
32
|
|
|
|
|
|
|
predicate => 'has_combos', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _build_combos { |
36
|
0
|
|
|
0
|
|
|
my $self = shift; |
37
|
0
|
0
|
0
|
|
|
|
return unless $self->community_cards && scalar @{ $self->community_cards } >= 3; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @combos = combinations( $self->community_cards, 3 ); |
39
|
0
|
|
|
|
|
|
$self->_combos([ @combos ]); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
after 'community_cards' => sub { |
43
|
|
|
|
|
|
|
my ($self, $cards) = @_; |
44
|
|
|
|
|
|
|
return unless $cards && scalar @$cards >= 3; |
45
|
|
|
|
|
|
|
$self->_build_combos; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub best_hand { |
49
|
0
|
|
|
0
|
1
|
|
my ( $self, $hole ) = @_; |
50
|
0
|
|
|
|
|
|
my $hand = Poker::Hand->new(cards => $hole); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return $hand |
53
|
|
|
|
|
|
|
if 5 > |
54
|
0
|
0
|
|
|
|
|
( scalar @$hole + scalar @{ $self->community_cards } ); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $iter = combinations( $hole, 2 ); |
57
|
0
|
|
|
|
|
|
while ( my $hole_combo = $iter->next ) { |
58
|
0
|
|
|
|
|
|
for my $combo (@{$self->_combos}) { |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $combo = [ @$hole_combo, @$combo ]; |
60
|
0
|
|
|
|
|
|
my $score = $self->scorer->score($combo); |
61
|
0
|
0
|
0
|
|
|
|
if (defined $score && $score >= $hand->score) { |
62
|
0
|
|
|
|
|
|
$hand->score($score); |
63
|
0
|
|
|
|
|
|
$hand->best_combo($combo); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
$hand->name($self->scorer->hand_name($hand->score)); |
68
|
0
|
|
|
|
|
|
return $hand; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
after 'BUILD' => sub { |
73
|
|
|
|
|
|
|
my $self = shift; |
74
|
|
|
|
|
|
|
$self->_build_combos; |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Nathaniel Graham, C<< >> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright 2016 Nathaniel Graham. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
86
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
87
|
|
|
|
|
|
|
copy of the full license at: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |