| 1 | package Poker::Game::OmahaHiLo; | ||||||||||||||||||||||||||||
| 2 | 2 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Poker::Eval::Omaha; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Poker::Score::High; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Poker::Score::Low8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Poker::Game::OmahaHiLo - Omaha Hold'em high/low 8-or-better | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 VERSION | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | Version 0.12 | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | use Poker::Game::OmahaHiLo; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | my $game = Poker::Game::OmahaHiLo->new; | ||||||||||||||||||||||||||||
| 28 | my $hero = $game->deal_hole(['As', '2d', '3c', 'Kd']); | ||||||||||||||||||||||||||||
| 29 | $game->runout(['4h', '5c', '9s', 'Jh', 'Kc']); | ||||||||||||||||||||||||||||
| 30 | $game->evaluate($hero); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | say $hero->name; # high hand name | ||||||||||||||||||||||||||||
| 33 | say $hero->low_name; # low hand name (if qualifies), or undef | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | Omaha Hi-Lo: four hole cards, five community cards. Exactly two hole | ||||||||||||||||||||||||||||
| 38 | and three community cards for each direction. High uses standard | ||||||||||||||||||||||||||||
| 39 | highball; low uses 8-or-better. A hand that does not qualify for low | ||||||||||||||||||||||||||||
| 40 | leaves C<low_score> / C<low_name> undefined. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2 | extends 'Poker::Game'; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | ▶ | has '+hole_count' => ( default => sub { 4 } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 3 | ▶ | has '+board_size' => ( default => sub { 5 } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | has 'low_scorer' => ( | ||||||||||||||||||||||||||||
| 50 | is => 'ro', | ||||||||||||||||||||||||||||
| 51 | lazy => 1, | ||||||||||||||||||||||||||||
| 52 | 3 | ▶ | builder => sub { Poker::Score::Low8->new }, | ||||||||||||||||||||||||||
|
Subroutine
_build_low_scorer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 2 | ); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | has 'low_eval' => ( | ||||||||||||||||||||||||||||
| 56 | is => 'ro', | ||||||||||||||||||||||||||||
| 57 | lazy => 1, | ||||||||||||||||||||||||||||
| 58 | 2 | ▶ | builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
_build_low_eval: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 60 | 2 | Poker::Eval::Omaha->new( scorer => $self->low_scorer ); | |||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||
| 62 | 2 | ); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 3 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.5
| |||||||||||||||||||||||||||||
| 65 | 3 | my ( $orig, $class, @args ) = @_; | |||||||||||||||||||||||||||
| 66 | 3 | my $args = $class->$orig(@args); | |||||||||||||||||||||||||||
| 67 | 3 | ▶ | $args = {} unless ref $args eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 3 | ▶ | $args->{scorer} //= Poker::Score::High->new; | ||||||||||||||||||||||||||
|
Condition33%1/3
$args->{"scorer"} //= "Poker::Score::High"->new
MC/DC0%0/2
$args->{"scorer"} //= "Poker::Score::High"->new
$args->{"scorer"}
"Poker::Score::High"->new
Truth table33%1/3
A //= B
A= $args->{"scorer"}B= "Poker::Score::High"->new
| |||||||||||||||||||||||||||||
| 70 | $args->{eval_engine} //= Poker::Eval::Omaha->new( | ||||||||||||||||||||||||||||
| 71 | scorer => $args->{scorer}, | ||||||||||||||||||||||||||||
| 72 | 3 | ▶ | ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$args->{"eval_engine"} //= "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
MC/DC0%0/2
$args->{"eval_engine"} //= "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
$args->{"eval_engine"}
"Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
Truth table33%1/3
A //= B
A= $args->{"eval_engine"}B= "Poker::Eval::Omaha"->new("scorer", $args->{"scorer"})
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | return $args; | |||||||||||||||||||||||||||
| 75 | 2 | }; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 evaluate | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Sets high result on C<score>/C<name>/C<best_combo>, and low result on | ||||||||||||||||||||||||||||
| 80 | C<low_score>/C<low_name>/C<low_combo> when the hand qualifies for low. | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 3 | ▶ | around evaluate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=24.0
| |||||||||||||||||||||||||||||
| 85 | 3 | my ( $orig, $self, $arg ) = @_; | |||||||||||||||||||||||||||
| 86 | 3 | my $hand = $self->$orig($arg); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 3 | ▶ | my $hole = | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 89 | ref $arg eq 'ARRAY' ? $arg | ||||||||||||||||||||||||||||
| 90 | : $arg->isa('Poker::Hand') ? $arg->cards | ||||||||||||||||||||||||||||
| 91 | : $hand->cards; | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 3 | $self->low_eval->community_cards( $self->board ); | |||||||||||||||||||||||||||
| 94 | 3 | my $low = $self->low_eval->best_hand($hole); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # Low8 returns undef/0 score when no qualifying low | ||||||||||||||||||||||||||||
| 97 | 3 | ▶ | my $qualified = defined $low->score && $low->score > 0; | ||||||||||||||||||||||||||
|
Condition66%2/3
defined $low->score && $low->score > 0
MC/DC50%1/2
defined $low->score && $low->score > 0
defined $low->score
$low->score > 0
Truth table66%2/3
A && B
A= defined $low->scoreB= $low->score > 0
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 3 | ▶ | if ( ref $arg && $arg->isa('Poker::Hand') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $arg and $arg->isa("Poker::Hand")
MC/DC0%0/2
ref $arg and $arg->isa("Poker::Hand")
ref $arg
$arg->isa("Poker::Hand")
Truth table33%1/3
A and B
A= ref $argB= $arg->isa("Poker::Hand")
| |||||||||||||||||||||||||||||
| 100 | 3 | ▶ | if ($qualified) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 2 | $arg->low_score( $low->score ); | |||||||||||||||||||||||||||
| 102 | 2 | $arg->low_name( $low->name ); | |||||||||||||||||||||||||||
| 103 | 2 | $arg->low_combo( $low->best_combo ); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||
| 106 | 1 | $arg->low_score(undef); | |||||||||||||||||||||||||||
| 107 | 1 | $arg->low_name(undef); | |||||||||||||||||||||||||||
| 108 | 1 | $arg->low_combo([]); | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 3 | return $arg; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ($qualified) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | $hand->low_score( $low->score ); | |||||||||||||||||||||||||||
| 115 | 0 | $hand->low_name( $low->name ); | |||||||||||||||||||||||||||
| 116 | 0 | $hand->low_combo( $low->best_combo ); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | 0 | return $hand; | |||||||||||||||||||||||||||
| 119 | 2 | }; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | Nathaniel Graham, C<< <ngraham at cpan.org> >> | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | Copyright 2016-2026 Nathaniel Graham. | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =cut | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 2 | 1; | |||||||||||||||||||||||||||