Game/Holdem.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 81.6% 40 / 49 CC 4 SCAR 8.6
CC
4
Cov
86%
__ANON__
4.7
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« Score/High.pm ↑ Summary Game/Omaha.pm »
1 package Poker::Game::Holdem;
2 4 our $VERSION = '0.12';
3  
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Poker::Eval::Community;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Poker::Score::High;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 =head1 NAME
12  
13 Poker::Game::Holdem - Texas Hold'em
14  
15 =head1 VERSION
16  
17 Version 0.12
18  
19 =cut
20  
21  
22 =head1 SYNOPSIS
23  
24 use Poker::Game::Holdem;
25 use feature qw(say);
26  
27 my $game = Poker::Game::Holdem->new( iterations => 1000 );
28  
29 my $hero = $game->deal_hole(['As', 'Kd']);
30 my $villain = $game->deal_hole(['7h', '7c']);
31  
32 $game->flop(['Ah', 'Kc', '2d']);
33 $game->turn('9s');
34 $game->river('3c');
35  
36 $game->evaluate($hero);
37 $game->evaluate($villain);
38  
39 say $hero->name; # Two Pair
40 say $hero->best_combo_flat;
41  
42 # Or equity from an earlier street:
43 $game->reset;
44 $hero = $game->deal_hole(['As', 'Kd']);
45 $villain = $game->deal_hole(['7h', '7c']);
46 $game->equity([ $hero, $villain ]);
47 say $hero->ev; # approx preflop equity %
48  
49 =head1 DESCRIPTION
50  
51 Texas Hold'em: two hole cards, five community cards. Any combination
52 of hole and community cards may be used to make the best five-card
53 hand. Standard highball ranking.
54  
55 =cut
56  
57 4 extends 'Poker::Game';
58  
59 12 ▶has '+hole_count' => ( default => sub { 2 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
60 12 ▶has '+board_size' => ( default => sub { 5 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
61  
62 # Build scorer and eval_engine before calling the parent constructor
63 # so required attributes are always defined.
64 12 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=4 SCAR=15.5
65 12 my ( $orig, $class, @args ) = @_;
66 12 my $args = $class->$orig(@args);
67 12 ▶ $args = {} unless ref $args eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 12 12
68  
69 12 ▶ $args->{scorer} //= Poker::Score::High->new;
Condition33%1/3
$args->{"scorer"} //= "Poker::Score::High"->new
l!l&&r!l&&!r
0120
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
ABresult
1X1
011
000
70 $args->{eval_engine} //= Poker::Eval::Community->new(
71 scorer => $args->{scorer},
72 12 ▶ );
Condition33%1/3
$args->{"eval_engine"} //= "Poker::Eval::Community"->new("scorer", $args->{"scorer"})
l!l&&r!l&&!r
0120
MC/DC0%0/2
$args->{"eval_engine"} //= "Poker::Eval::Community"->new("scorer", $args->{"scorer"})
$args->{"eval_engine"} "Poker::Eval::Community"->new("scorer", $args->{"scorer"})
Truth table33%1/3
A //= B
A= $args->{"eval_engine"}B= "Poker::Eval::Community"->new("scorer", $args->{"scorer"})
ABresult
1X1
011
000
73  
74 12 return $args;
75 4 };
76  
77 =head1 AUTHOR
78  
79 Nathaniel Graham, C<< <ngraham at cpan.org> >>
80  
81 =head1 LICENSE AND COPYRIGHT
82  
83 Copyright 2016-2026 Nathaniel Graham.
84  
85 =cut
86  
87 4 1;
« Score/High.pm ↑ Summary Game/Omaha.pm »