| 1 | package Games::ABC_Path::Solver::App; | ||||||||||||||||||
| 2 | 4 | $Games::ABC_Path::Solver::App::VERSION = '0.6.1'; | |||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 4 | ▶ | use parent 'Games::ABC_Path::Solver::Base'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | 4 | ▶ | use Carp; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | 4 | ▶ | use Getopt::Long; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 4 | ▶ | use Pod::Usage; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 4 | ▶ | use Games::ABC_Path::Solver::Board; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | sub _argv | ||||||||||||||||||
| 16 | { | ||||||||||||||||||
| 17 | 6 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
_argv: called CC=2 SCAR=6.9
| |||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | 6 | ▶ | if (@_) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 20 | 3 | $self->{_argv} = shift; | |||||||||||||||||
| 21 | } | ||||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 6 | return $self->{_argv}; | |||||||||||||||||
| 24 | } | ||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | sub _init | ||||||||||||||||||
| 27 | { | ||||||||||||||||||
| 28 | 3 | ▶ | my ($self, $args) = @_; | ||||||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | 3 | $self->_argv([@{$args->{argv}}]); | |||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 3 | return; | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | sub run | ||||||||||||||||||
| 36 | { | ||||||||||||||||||
| 37 | 3 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
run: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 3 | local @ARGV = @{$self->_argv}; | |||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 3 | my $man = 0; | |||||||||||||||||
| 42 | 3 | my $help = 0; | |||||||||||||||||
| 43 | 3 | my $gen_template = 0; | |||||||||||||||||
| 44 | 3 | ▶ | GetOptions( | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 45 | 'help|h' => \$help, | ||||||||||||||||||
| 46 | man => \$man, | ||||||||||||||||||
| 47 | 'gen-v1-template' => \$gen_template, | ||||||||||||||||||
| 48 | ) | ||||||||||||||||||
| 49 | or pod2usage(2); | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | 3 | ▶ | if ($help) | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 52 | { | ||||||||||||||||||
| 53 | 0 | pod2usage(1); | |||||||||||||||||
| 54 | } | ||||||||||||||||||
| 55 | elsif ($man) | ||||||||||||||||||
| 56 | { | ||||||||||||||||||
| 57 | 0 | pod2usage(-verbose => 2); | |||||||||||||||||
| 58 | } | ||||||||||||||||||
| 59 | elsif ($gen_template) | ||||||||||||||||||
| 60 | { | ||||||||||||||||||
| 61 | 1 | print <<'EOF'; | |||||||||||||||||
| 62 | ABC Path Solver Layout Version 1: | ||||||||||||||||||
| 63 | ??????? | ||||||||||||||||||
| 64 | ? ? | ||||||||||||||||||
| 65 | ? ? | ||||||||||||||||||
| 66 | ? ? | ||||||||||||||||||
| 67 | ? A ? | ||||||||||||||||||
| 68 | ? ? | ||||||||||||||||||
| 69 | ??????? | ||||||||||||||||||
| 70 | EOF | ||||||||||||||||||
| 71 | } | ||||||||||||||||||
| 72 | else | ||||||||||||||||||
| 73 | { | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | 2 | my $board_fn = shift(@ARGV); | |||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | 2 | ▶ | if (!defined ($board_fn)) | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 78 | { | ||||||||||||||||||
| 79 | 0 | die "Filename not specified - usage: abc-path-solver.pl [filename]!"; | |||||||||||||||||
| 80 | } | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | 2 | my $solver = Games::ABC_Path::Solver::Board->input_from_file($board_fn); | |||||||||||||||||
| 83 | # Now let's do a neighbourhood inferring of the board. | ||||||||||||||||||
| 84 | |||||||||||||||||||
| 85 | 2 | $solver->solve; | |||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | 2 | foreach my $move (@{$solver->get_moves}) | |||||||||||||||||
| 88 | { | ||||||||||||||||||
| 89 | 181 | print +(' => ' x $move->get_depth()), $move->get_text(), "\n"; | |||||||||||||||||
| 90 | } | ||||||||||||||||||
| 91 | |||||||||||||||||||
| 92 | 2 | print @{$solver->get_successes_text_tables}; | |||||||||||||||||
| 93 | } | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | 3 | exit(0); | |||||||||||||||||
| 96 | } | ||||||||||||||||||
| 97 | |||||||||||||||||||
| 98 | |||||||||||||||||||
| 99 | 4 | 1; # End of Games::ABC_Path::Solver::App | |||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||