Commits

Anonymous committed 7f175f6

More conversion to ::Coords.

  • Participants
  • Parent commits 932fbb1

Comments (0)

Files changed (2)

nurikabe-solver/Games-Nurikabe-Solver/lib/Games/Nurikabe/Solver/Board.pm

         $island->mark_reachable_brfs_scan({board => $self});
     }
 
-    my @island_reachable_cells = (map { [] } @{$self->_islands()});
+    my @island_reachable_coords = (map { [] } @{$self->_islands()});
 
     # Now mark the unreachable states.
     $self->_cells_loop(
                 {
                     if (defined($cell->_island_reachable->[$idx]))
                     {
-                        push @{$island_reachable_cells[$idx]}, [@$coords];
+                        push @{$island_reachable_coords[$idx]}, 
+                            Games::Nurikabe::Solver::Coords->new(
+                                {
+                                    y => $coords->[0],
+                                    x => $coords->[1],
+                                }
+                            )
+                            ;
                     }
                 }
             }
     {
         my $island = $self->_islands->[$idx];
 
-        my $count = @{$island_reachable_cells[$idx]} + @{$island->known_cells};
+        my $count = @{$island_reachable_coords[$idx]} + @{$island->known_cells};
 
         # We can mark all these cells as white, since the island is full.
         if ($count == $island->order())
         {
             $moved = 1;
-            $island->add_white_cells({
+            $island->add_white_coords({
                     board => $self,
-                    cells => $island_reachable_cells[$idx]
+                    coords => $island_reachable_coords[$idx]
                 }
             );
         }

nurikabe-solver/Games-Nurikabe-Solver/lib/Games/Nurikabe/Solver/Island.pm

     return;
 }
 
-=head2 $island->add_white_cells( { board => $board, cells => [@list],} )
+=head2 $island->add_white_coords( { board => $board, coords => [@list],} )
 
-Add these cells now known as white to the island.
+Add these coords now known as white to the island.
 
 =cut
 
-sub add_white_cells
+sub add_white_coords
 {
     my ($self, $args) = @_;
 
     my $board = $args->{'board'};
-    my $new_cells = $args->{'cells'};
+    my $new_coords = $args->{'coords'};
 
-    foreach my $coord (@$new_cells)
+    foreach my $coord (@$new_coords)
     {
-        my $c = Games::Nurikabe::Solver::Coords->new(
-            {
-                y => $coord->[0], x => $coord->[1]
-            }
-        );
+        push @{$self->known_cells()}, $coord;
 
-        push @{$self->known_cells()}, $c;
-
-        $board->_mark_as_white($c, $self->idx);
+        $board->_mark_as_white($coord, $self->idx);
     }
 
     $self->known_cells($self->_sort_coords($self->known_cells()));