Commits

Anonymous committed 0ffafd3

Add TryingLetterForCell.

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/TryingLetterForCell.pm
 lib/Games/ABC_Path/Solver.pm
 Makefile.PL
 MANIFEST

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::TryingLetterForCell;
 
 my $ABCP_VERDICT_NO = 0;
 my $ABCP_VERDICT_MAYBE = 1;
             my $recurse_solver = $self->_clone;
 
             $self->_add_move(
-                Games::ABC_Path::Solver::Move->new(
-                {
-                    text => sprintf(
-                        "We have non-conclusive cells. Trying %s for (%d,%d)",
-                        $letters[$letter], $x+1, $y+1,
-                    ),
-                }
-            ),
+                Games::ABC_Path::Solver::Move::TryingLetterForCell->new(
+                    {
+                        vars => { letter => $letter, coords => [$x, $y], },
+                    }
+                ),
             );
 
             $recurse_solver->_set_conclusive_verdict_for_letter(

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

+package Games::ABC_Path::Solver::Move::TryingLetterForCell;
+
+use strict;
+use warnings;
+
+use base 'Games::ABC_Path::Solver::Move';
+
+=head1 NAME
+
+Games::ABC_Path::Solver::Move::TryingLetterForCell - an ABC Path move
+of trying a letter for a certain cell.
+
+=head1 VERSION
+
+Version 0.0.1
+
+=cut
+
+our $VERSION = '0.0.1';
+
+=head1 SYNOPSIS
+
+    use Games::ABC_Path::Solver::Move::TryingLetterForCell;
+
+    my $move = Games::ABC_Path::Solver::Move::TryingLetterForCell->new(
+        {
+            vars =>
+            {
+                coords => [1,2],
+                letter => 5,
+            },
+        }
+    );
+
+=head1 DESCRIPTION
+
+This is a move that indicates that we are attempting to solve the game by
+trying to put the letter C<'letter'> in the coordinate C<'coords'>.
+
+=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 "We have non-conclusive cells. Trying %(letter){letter} for %(coords){coords}";
+}
+
+1;
+