| 1 | package Games::Tournament::BlackJack::Player::ExamplePlayer2; | ||||||||||||
| 2 | # (very simple) example player module for blackjack | ||||||||||||
| 3 | # this player will hit on a 16 or less by default, or the theshold | ||||||||||||
| 4 | # he is sent in the initialization parameter "hit_threshold". | ||||||||||||
| 5 | |||||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | use Games::Tournament::BlackJack::Player; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use Games::Tournament::BlackJack::Utilities; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | @ISA = qw(Games::Tournament::BlackJack::Player); | |||||||||||
| 10 | |||||||||||||
| 11 | # decide_simple returns true for hit, false for stand. | ||||||||||||
| 12 | 0 | ▶ | sub decide_simple { | ||||||||||
|
Subroutine
decide_simple: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 13 | 0 | my $self = shift; | |||||||||||
| 14 | 0 | ▶ | my $hit_threshold = $self->{'hit_threshold'} || 16; # hit on 16 or less _by_default_ | ||||||||||
|
Condition0%0/2
$self->{'hit_threshold'} || 16
MC/DC0%0/1
$self->{'hit_threshold'} || 16
$self->{'hit_threshold'}
Truth table0%0/2
A
A= $self->{'hit_threshold'}
| |||||||||||||
| 15 | 0 | return (handValue($self->{'hand'}) <= $hit_threshold); | |||||||||||
| 16 | } | ||||||||||||
| 17 | |||||||||||||
| 18 | 1 | 1; | |||||||||||