Commits

Anonymous committed 63f27cc

Add ::Move::ResultsInAnError.

Comments (0)

Files changed (3)

abc-path/Games-ABC_Path-Solver/MANIFEST

 lib/Games/ABC_Path/Solver/Move/LastRemainingLetterForCell.pm
 lib/Games/ABC_Path/Solver/Move/LettersNotInVicinity.pm
 lib/Games/ABC_Path/Solver/Move.pm
+lib/Games/ABC_Path/Solver/Move/ResultsInAnError.pm
 lib/Games/ABC_Path/Solver/Move/TryingLetterForCell.pm
 lib/Games/ABC_Path/Solver.pm
 Makefile.PL

abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Board.pm

 use Games::ABC_Path::Solver::Move::LastRemainingCellForLetter;
 use Games::ABC_Path::Solver::Move::LastRemainingLetterForCell;
 use Games::ABC_Path::Solver::Move::LettersNotInVicinity;
+use Games::ABC_Path::Solver::Move::ResultsInAnError;
 use Games::ABC_Path::Solver::Move::TryingLetterForCell;
 
 my $ABCP_VERDICT_NO = 0;
             if ($recurse_solver->_error())
             {
                 $self->_add_move(
-                    Games::ABC_Path::Solver::Move->new(
+                    Games::ABC_Path::Solver::Move::ResultsInAnError->new(
                     {
-                        text => 
-                        sprintf(
-                            "Trying %s for (%d,%d) results in an error.", 
-                            $letters[$letter],
-                            $x+1,
-                            $y+1
-                        ),
+                        vars =>
+                        {
+                            letter => $letter,
+                            coords => [$x,$y],
+                        },
                     }
                     )
                 );

abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Move/ResultsInAnError.pm

+package Games::ABC_Path::Solver::Move::ResultsInAnError;
+
+use strict;
+use warnings;
+
+use base 'Games::ABC_Path::Solver::Move';
+
+=head1 NAME
+
+Games::ABC_Path::Solver::Move::ResultsInAnError - indicates that a trial
+selection resulted in an error.
+
+=head1 VERSION
+
+Version 0.0.1
+
+=cut
+
+our $VERSION = '0.0.1';
+
+=head1 SYNOPSIS
+
+    use Games::ABC_Path::Solver::Move::ResultsInAnError;
+
+    my $move = Games::ABC_Path::Solver::Move::ResultsInAnError->new(
+        {
+            vars =>
+            {
+                letter => $letter,
+                coords => [$x,$y],
+            },
+        }
+    );
+
+=head1 DESCRIPTION
+
+This is a move that a branch resulted in an error.
+
+=cut
+
+sub _get_text {
+    my $self = shift;
+
+    my $text = $self->_format;
+
+    $text =~ s/%\((\w+)\)\{(\w+)\}/
+        $self->_expand_format($1,$2)
+        /ge;
+
+    return $text;
+}
+
+sub _format {
+    return "Trying %(letter){letter} for %(coords){coords} results in an error.";
+}
+
+1;
+