| 1 | package Games::ABC_Path::Solver::Move; | ||||||||||||||
| 2 | 14 | $Games::ABC_Path::Solver::Move::VERSION = '0.6.2'; | |||||||||||||
| 3 | 14 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 14 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | |||||||||||||||
| 7 | 14 | ▶ | use parent 'Games::ABC_Path::Solver::Base'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | |||||||||||||||
| 10 | sub get_text | ||||||||||||||
| 11 | { | ||||||||||||||
| 12 | 188 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
get_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 188 | my $text = $self->_format; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 188 | $text =~ s/%\((\w+)\)\{(\w+)\}/ | |||||||||||||
| 17 | 506 | $self->_expand_format($1,$2) | |||||||||||||
| 18 | /ge; | ||||||||||||||
| 19 | |||||||||||||||
| 20 | 188 | return $text; | |||||||||||||
| 21 | } | ||||||||||||||
| 22 | |||||||||||||||
| 23 | sub _depth | ||||||||||||||
| 24 | { | ||||||||||||||
| 25 | 460 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
_depth: called CC=2 SCAR=6.9
| |||||||||||||||
| 26 | |||||||||||||||
| 27 | 460 | ▶ | if (@_) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 28 | { | ||||||||||||||
| 29 | 272 | $self->{_depth} = shift; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 460 | return $self->{_depth}; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | |||||||||||||||
| 36 | sub get_depth | ||||||||||||||
| 37 | { | ||||||||||||||
| 38 | 188 | ▶ | my ($self) = @_; | ||||||||||||
|
Subroutine
get_depth: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 39 | |||||||||||||||
| 40 | 188 | return $self->_depth(); | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | |||||||||||||||
| 43 | sub _init | ||||||||||||||
| 44 | { | ||||||||||||||
| 45 | 272 | ▶ | my ( $self, $args ) = @_; | ||||||||||||
|
Subroutine
_init: called CC=3 SCAR=11.0
| |||||||||||||||
| 46 | |||||||||||||||
| 47 | 272 | $self->{_text} = $args->{text}; | |||||||||||||
| 48 | 272 | ▶ | $self->_depth( $args->{depth} || 0 ); | ||||||||||||
|
Condition100%2/2
$args->{'depth'} || 0
MC/DC100%1/1
$args->{'depth'} || 0
$args->{'depth'}
Truth table100%2/2
A
A= $args->{'depth'}
| |||||||||||||||
| 49 | 272 | ▶ | $self->{_vars} = ( $args->{vars} || {} ); | ||||||||||||
|
Condition50%1/2
$args->{'vars'} || {}
MC/DC0%0/1
$args->{'vars'} || {}
$args->{'vars'}
Truth table50%1/2
A
A= $args->{'vars'}
| |||||||||||||||
| 50 | |||||||||||||||
| 51 | 272 | return; | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | |||||||||||||||
| 55 | sub bump | ||||||||||||||
| 56 | { | ||||||||||||||
| 57 | 7 | ▶ | my ($self) = @_; | ||||||||||||
|
Subroutine
bump: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 58 | |||||||||||||||
| 59 | return ref($self)->new( | ||||||||||||||
| 60 | { | ||||||||||||||
| 61 | text => $self->get_text(), | ||||||||||||||
| 62 | depth => ( $self->get_depth + 1 ), | ||||||||||||||
| 63 | 7 | vars => { %{ $self->{_vars} }, }, | |||||||||||||
| 64 | } | ||||||||||||||
| 65 | ); | ||||||||||||||
| 66 | } | ||||||||||||||
| 67 | |||||||||||||||
| 68 | |||||||||||||||
| 69 | sub get_var | ||||||||||||||
| 70 | { | ||||||||||||||
| 71 | 506 | ▶ | my ( $self, $name ) = @_; | ||||||||||||
|
Subroutine
get_var: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 72 | |||||||||||||||
| 73 | 506 | return $self->{_vars}->{$name}; | |||||||||||||
| 74 | } | ||||||||||||||
| 75 | |||||||||||||||
| 76 | # TODO : duplicate code with ::Board | ||||||||||||||
| 77 | 14 | my @letters = (qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y)); | |||||||||||||
| 78 | |||||||||||||||
| 79 | sub _expand_format | ||||||||||||||
| 80 | { | ||||||||||||||
| 81 | 506 | ▶ | my ( $self, $name, $type ) = @_; | ||||||||||||
|
Subroutine
_expand_format: called CC=3 SCAR=11.2
| |||||||||||||||
| 82 | |||||||||||||||
| 83 | 506 | my $value = $self->get_var($name); | |||||||||||||
| 84 | |||||||||||||||
| 85 | 506 | ▶ | if ( $type eq "letter" ) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 86 | { | ||||||||||||||
| 87 | 318 | return $letters[$value]; | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | elsif ( $type eq "coords" ) | ||||||||||||||
| 90 | { | ||||||||||||||
| 91 | 188 | return sprintf( "(%d,%d)", $value->x() + 1, $value->y() + 1 ); | |||||||||||||
| 92 | } | ||||||||||||||
| 93 | else | ||||||||||||||
| 94 | { | ||||||||||||||
| 95 | 0 | die "Unknown format type '$type'!"; | |||||||||||||
| 96 | } | ||||||||||||||
| 97 | } | ||||||||||||||
| 98 | |||||||||||||||
| 99 | |||||||||||||||
| 100 | 14 | 1; # End of Games::ABC_Path::Solver::Move | |||||||||||||
| 101 | |||||||||||||||
| 102 | __END__ | ||||||||||||||