« blib/lib/Games/ABC_Path/Generator/RiddleObj.pm
↑ Summary
blib/lib/Games/ABC_Path/MicrosoftRand.pm »
| 1 | package Games::ABC_Path::Generator::App; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 5 | ▶ | use 5.006; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 5 | ▶ | use base 'Games::ABC_Path::Generator::Base'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 5 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | 5 | ▶ | use Games::ABC_Path::Generator; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 NAME | ||||||||||||||
| 14 | |||||||||||||||
| 15 | Games::ABC_Path::Generator::App - command line application for the ABC Path generator. | ||||||||||||||
| 16 | |||||||||||||||
| 17 | =head1 VERSION | ||||||||||||||
| 18 | |||||||||||||||
| 19 | Version 0.1.0 | ||||||||||||||
| 20 | |||||||||||||||
| 21 | =cut | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 5 | our $VERSION = '0.1.0'; | |||||||||||||
| 24 | |||||||||||||||
| 25 | |||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||
| 27 | |||||||||||||||
| 28 | use Games::ABC_Path::Generator::App; | ||||||||||||||
| 29 | |||||||||||||||
| 30 | my $app = Games::ABC_Path::Generator::App->new({ argv => [@ARGV], },); | ||||||||||||||
| 31 | $app->run(); | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =head1 SUBROUTINES/METHODS | ||||||||||||||
| 34 | |||||||||||||||
| 35 | =head2 Games::ABC_Path::Generator::App->new({ argv => [@ARGV], },); | ||||||||||||||
| 36 | |||||||||||||||
| 37 | Initialize from @ARGV . | ||||||||||||||
| 38 | |||||||||||||||
| 39 | =cut | ||||||||||||||
| 40 | |||||||||||||||
| 41 | sub _argv | ||||||||||||||
| 42 | { | ||||||||||||||
| 43 | 6 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
_argv: called CC=2 SCAR=6.9
| |||||||||||||||
| 44 | |||||||||||||||
| 45 | 6 | ▶ | if (@_) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | { | ||||||||||||||
| 47 | 3 | $self->{_argv} = shift; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | 6 | return $self->{_argv}; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | sub _init | ||||||||||||||
| 54 | { | ||||||||||||||
| 55 | 3 | ▶ | my ($self, $args) = @_; | ||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||
| 56 | |||||||||||||||
| 57 | 3 | $self->_argv($args->{argv}); | |||||||||||||
| 58 | |||||||||||||||
| 59 | 3 | return; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =head2 $app->run() | ||||||||||||||
| 63 | |||||||||||||||
| 64 | Runs the application. | ||||||||||||||
| 65 | |||||||||||||||
| 66 | =cut | ||||||||||||||
| 67 | |||||||||||||||
| 68 | sub run | ||||||||||||||
| 69 | { | ||||||||||||||
| 70 | 3 | ▶ | my ($self) = @_; | ||||||||||||
|
Subroutine
run: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||
| 71 | |||||||||||||||
| 72 | 3 | my $seed; | |||||||||||||
| 73 | 3 | my $mode = 'riddle'; | |||||||||||||
| 74 | 3 | ▶ | if (!GetOptionsFromArray( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 75 | $self->_argv(), | ||||||||||||||
| 76 | 'seed=i' => \$seed, | ||||||||||||||
| 77 | 'mode=s' => \$mode, | ||||||||||||||
| 78 | )) | ||||||||||||||
| 79 | { | ||||||||||||||
| 80 | 0 | die "Could not get options for program!"; | |||||||||||||
| 81 | } | ||||||||||||||
| 82 | |||||||||||||||
| 83 | 3 | ▶ | if (!defined($seed)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 84 | { | ||||||||||||||
| 85 | 0 | die "Seed not specified!"; | |||||||||||||
| 86 | } | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 3 | my $gen = Games::ABC_Path::Generator->new({ seed => $seed, }); | |||||||||||||
| 89 | |||||||||||||||
| 90 | 3 | ▶ | if ($mode eq 'final') | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 91 | { | ||||||||||||||
| 92 | 1 | print $gen->calc_final_layout()->as_string({}); | |||||||||||||
| 93 | } | ||||||||||||||
| 94 | elsif ($mode eq 'riddle') | ||||||||||||||
| 95 | { | ||||||||||||||
| 96 | 2 | my $riddle = $gen->calc_riddle(); | |||||||||||||
| 97 | |||||||||||||||
| 98 | 2 | my $layout_string = $riddle->get_final_layout_as_string({}); | |||||||||||||
| 99 | |||||||||||||||
| 100 | 2 | my $riddle_string = $riddle->get_riddle_v1_string; | |||||||||||||
| 101 | |||||||||||||||
| 102 | 2 | print sprintf( | |||||||||||||
| 103 | "ABC Path Solver Layout Version 1:\n%s", | ||||||||||||||
| 104 | $riddle_string, | ||||||||||||||
| 105 | ); | ||||||||||||||
| 106 | } | ||||||||||||||
| 107 | |||||||||||||||
| 108 | 3 | return; | |||||||||||||
| 109 | } | ||||||||||||||
| 110 | |||||||||||||||
| 111 | =head1 AUTHOR | ||||||||||||||
| 112 | |||||||||||||||
| 113 | Shlomi Fish, L<http://www.shlomifish.org/> . | ||||||||||||||
| 114 | |||||||||||||||
| 115 | =head1 BUGS | ||||||||||||||
| 116 | |||||||||||||||
| 117 | Please report any bugs or feature requests to C<bug-games-abc_path-generator at rt.cpan.org>, or through | ||||||||||||||
| 118 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-ABC_Path-Generator>. I will be notified, and then you'll | ||||||||||||||
| 119 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||
| 120 | |||||||||||||||
| 121 | |||||||||||||||
| 122 | |||||||||||||||
| 123 | |||||||||||||||
| 124 | =head1 SUPPORT | ||||||||||||||
| 125 | |||||||||||||||
| 126 | You can find documentation for this module with the perldoc command. | ||||||||||||||
| 127 | |||||||||||||||
| 128 | perldoc Games::ABC_Path::Generator::App | ||||||||||||||
| 129 | |||||||||||||||
| 130 | |||||||||||||||
| 131 | You can also look for information at: | ||||||||||||||
| 132 | |||||||||||||||
| 133 | =over 4 | ||||||||||||||
| 134 | |||||||||||||||
| 135 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||
| 136 | |||||||||||||||
| 137 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-ABC_Path-Generator> | ||||||||||||||
| 138 | |||||||||||||||
| 139 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||
| 140 | |||||||||||||||
| 141 | L<http://annocpan.org/dist/Games-ABC_Path-Generator> | ||||||||||||||
| 142 | |||||||||||||||
| 143 | =item * CPAN Ratings | ||||||||||||||
| 144 | |||||||||||||||
| 145 | L<http://cpanratings.perl.org/d/Games-ABC_Path-Generator> | ||||||||||||||
| 146 | |||||||||||||||
| 147 | =item * Search CPAN | ||||||||||||||
| 148 | |||||||||||||||
| 149 | L<http://search.cpan.org/dist/Games-ABC_Path-Generator/> | ||||||||||||||
| 150 | |||||||||||||||
| 151 | =back | ||||||||||||||
| 152 | |||||||||||||||
| 153 | |||||||||||||||
| 154 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||
| 155 | |||||||||||||||
| 156 | |||||||||||||||
| 157 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 158 | |||||||||||||||
| 159 | Copyright 2011 Shlomi Fish. | ||||||||||||||
| 160 | |||||||||||||||
| 161 | This program is distributed under the MIT (X11) License: | ||||||||||||||
| 162 | L<http://www.opensource.org/licenses/mit-license.php> | ||||||||||||||
| 163 | |||||||||||||||
| 164 | Permission is hereby granted, free of charge, to any person | ||||||||||||||
| 165 | obtaining a copy of this software and associated documentation | ||||||||||||||
| 166 | files (the "Software"), to deal in the Software without | ||||||||||||||
| 167 | restriction, including without limitation the rights to use, | ||||||||||||||
| 168 | copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||||||||||
| 169 | copies of the Software, and to permit persons to whom the | ||||||||||||||
| 170 | Software is furnished to do so, subject to the following | ||||||||||||||
| 171 | conditions: | ||||||||||||||
| 172 | |||||||||||||||
| 173 | The above copyright notice and this permission notice shall be | ||||||||||||||
| 174 | included in all copies or substantial portions of the Software. | ||||||||||||||
| 175 | |||||||||||||||
| 176 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||||||||||||
| 177 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||||||||||||||
| 178 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||||||||||||
| 179 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||||||||||||||
| 180 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||||||||||||||
| 181 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||||||||||||
| 182 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||||||||||||||
| 183 | OTHER DEALINGS IN THE SOFTWARE. | ||||||||||||||
| 184 | |||||||||||||||
| 185 | |||||||||||||||
| 186 | =cut | ||||||||||||||
| 187 | |||||||||||||||
| 188 | 5 | 1; # End of Games::ABC_Path::Generator::App | |||||||||||||