Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed 70ce436

Achieved full POD coverage.

  • Participants
  • Parent commits 128138e

Comments (0)

Files changed (1)

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

     return;
 }
 
+=head2 get_successful_layouts()
+
+Returns a copy of the successful layouts. Each one of them is a completed
+L<Games::ABC_Path::Solver::Board> the successful layouts. Each one of them is a completed
+L<Games::ABC_Path::Solver::Board> object.
+
+=cut
+
 sub get_successful_layouts {
     my ($self) = @_;
 
     return $letter * ($BOARD_LEN * $BOARD_LEN) + $self->_xy_to_idx($x,$y);
 }
 
-sub get_verdict
+sub _get_verdict
 {
     my ($self, $letter, $x, $y) = @_;
 
     return vec(${$self->_layout}, $self->_calc_offset($letter, $x, $y), 2);
 }
 
-sub set_verdict
+sub _set_verdict
 {
     my ($self, $letter, $x, $y, $verdict) = @_;
 
     return;
 }
 
-sub xy_loop
+sub _xy_loop
 {
     my ($self, $sub_ref) = (@_);
 
 }
 
 
-sub set_verdicts_for_letter_sets
+sub _set_verdicts_for_letter_sets
 {
     my ($self, $letter_list, $maybe_list) = @_;
 
     {
         my $letter = $self->_get_letter_numeric($letter_ascii);
 
-        $self->xy_loop(
+        $self->_xy_loop(
             sub {
                 my ($x, $y) = @_;
 
-                $self->set_verdict($letter, $x, $y,
+                $self->_set_verdict($letter, $x, $y,
                     ((exists $cell_is_maybe{"$x,$y"})
                         ? $ABCP_VERDICT_MAYBE
                         : $ABCP_VERDICT_NO
     return;
 }
 
-sub set_conclusive_verdict_for_letter
+sub _set_conclusive_verdict_for_letter
 {
     my ($self, $letter, $xy) = @_;
 
     my ($l_x, $l_y) = @$xy;
 
-    $self->xy_loop(sub {
+    $self->_xy_loop(sub {
             my ($x, $y) = @_;
 
-            $self->set_verdict($letter, $x, $y,
+            $self->_set_verdict($letter, $x, $y,
                 ((($l_x == $x) && ($l_y == $y))
                     ? $ABCP_VERDICT_YES
                     : $ABCP_VERDICT_NO
         {
             next OTHER_LETTER;
         }
-        $self->set_verdict($other_letter, $l_x, $l_y, $ABCP_VERDICT_NO);
+        $self->_set_verdict($other_letter, $l_x, $l_y, $ABCP_VERDICT_NO);
     }
 
     return;
 
     return 
     [
-        grep { $self->get_verdict($_, $x, $y) != $ABCP_VERDICT_NO }
+        grep { $self->_get_verdict($_, $x, $y) != $ABCP_VERDICT_NO }
         $self->_l_indexes()
     ];
 }
     {
         my @true_cells;
 
-        $self->xy_loop(sub {
+        $self->_xy_loop(sub {
             my @c = @_;
 
-            my $ver = $self->get_verdict($letter, @c);
+            my $ver = $self->_get_verdict($letter, @c);
             if (    ($ver == $ABCP_VERDICT_YES) 
                 || ($ver == $ABCP_VERDICT_MAYBE))
             {
         elsif (@true_cells == 1)
         {
             my $xy = $true_cells[0];
-            if ($self->get_verdict($letter, @$xy) ==
+            if ($self->_get_verdict($letter, @$xy) ==
                 $ABCP_VERDICT_MAYBE)
             {
-                $self->set_conclusive_verdict_for_letter($letter, $xy);
+                $self->_set_conclusive_verdict_for_letter($letter, $xy);
                 $self->_add_move(
                     Games::ABC_Path::Solver::Move->new(
                         {
             (($letter < $ABCP_MAX_LETTER) ? ($letter+1) : ()),
         )
         {
-            $self->xy_loop(sub {
+            $self->_xy_loop(sub {
                 my ($x, $y) = @_;
 
                 if ($neighbourhood[$y][$x])
                 }
 
                 my $existing_verdict =
-                    $self->get_verdict($neighbour_letter, $x, $y);
+                    $self->_get_verdict($neighbour_letter, $x, $y);
 
                 if ($existing_verdict == $ABCP_VERDICT_YES)
                 {
 
                 if ($existing_verdict == $ABCP_VERDICT_MAYBE)
                 {
-                    $self->set_verdict($neighbour_letter, $x, $y, $ABCP_VERDICT_NO);
+                    $self->_set_verdict($neighbour_letter, $x, $y, $ABCP_VERDICT_NO);
                     $self->_add_move(
                         Games::ABC_Path::Solver::Move->new(
                             {
 {
     my ($self) = @_;
 
-    $self->xy_loop(sub {
+    $self->_xy_loop(sub {
         my ($x, $y) = @_;
 
         my $letters_aref = $self->_get_possible_letter_indexes($x, $y);
         {
             my $letter = $letters_aref->[0];
 
-            if ($self->get_verdict($letter, $x, $y) == $ABCP_VERDICT_MAYBE)
+            if ($self->_get_verdict($letter, $x, $y) == $ABCP_VERDICT_MAYBE)
             {
-                $self->set_conclusive_verdict_for_letter($letter, [$x, $y]);
+                $self->_set_conclusive_verdict_for_letter($letter, [$x, $y]);
                 $self->_add_move(
                     Games::ABC_Path::Solver::Move->new(
                         {
         );
 }
 
+=head2 $board->solve()
+
+Performs the actual solution. Should be called after input.
+
+=cut
+
 sub solve
 {
     my ($self) = @_;
     my @min_coords;
     my @min_options;
 
-    $self->xy_loop(sub {
+    $self->_xy_loop(sub {
         my ($x, $y) = @_;
 
         my $letters_aref = $self->_get_possible_letter_indexes($x, $y);
             ),
             );
 
-            $recurse_solver->set_conclusive_verdict_for_letter(
+            $recurse_solver->_set_conclusive_verdict_for_letter(
                 $letter, [$x,$y]
             );
 
 
     push @major_diagonal_letters, $1;
 
-    $self->set_verdicts_for_letter_sets(
+    $self->_set_verdicts_for_letter_sets(
         \@major_diagonal_letters, 
         [map { [$_,$_] } $self->_y_indexes],
     );
 
     push @minor_diagonal_letters, $1;
 
-    $self->set_verdicts_for_letter_sets(
+    $self->_set_verdicts_for_letter_sets(
         \@minor_diagonal_letters,
         [map { [$_, 4-$_] } ($self->_y_indexes)]
     );
 
     foreach my $x ($self->_x_indexes)
     {
-        $self->set_verdicts_for_letter_sets(
+        $self->_set_verdicts_for_letter_sets(
             [substr($top_row, $x+1, 1), substr($bottom_row, $x+1, 1),],
             [map { [$x,$_] } $self->_y_indexes],
         );
     foreach my $y ($self->_y_indexes)
     {
         my $row = $rows->[$y];
-        $self->set_verdicts_for_letter_sets(
+        $self->_set_verdicts_for_letter_sets(
             [substr($row, 0, 1), substr($row, -1),],
             [map { [$_,$y] } $self->_x_indexes],
         );
         confess "Did not find any clue letters inside the layout.";
     }
 
-    $self->set_conclusive_verdict_for_letter(
+    $self->_set_conclusive_verdict_for_letter(
         $self->_get_letter_numeric($clue_letter),
         [$clue_x, $clue_y],
     );
     return;
 }
 
-sub input
+sub _input
 {
     my ($self, $args) = @_;
 
     return $tb;
 }
 
-sub get_successes_text_tables
+sub _get_successes_text_tables
 {
     my ($self) = @_;
 
     return [map { $_->_get_results_text_table() } @{$self->get_successful_layouts()}];
 }
 
-# Input the board.
+=head2 $board->input_from_file($filename)
+
+Inputs the board from the C<$filename> file path containing a representation
+of the initial board.
+
+=cut
 
 sub input_from_file
 {
     }
     close($in_fh);
 
-    $self->input({ layout => $layout_string, version => 1});
+    $self->_input({ layout => $layout_string, version => 1});
 
     return $self;
 }