Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed d031476

More conversion to the Coords object.

  • Participants
  • Parent commits 3b9821b

Comments (0)

Files changed (2)

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

 {
     my ($board, $coords, $callback) = @_;
 
-    my $cell = $board->get_cell(
-        Games::Nurikabe::Solver::Coords->new(
-            { y => $coords->[0], x => $coords->[1]}
-        )
-    );
+    my $cell = $board->get_cell($coords);
 
     foreach my $off_coords (
         grep { $board->_is_in_bounds($_) }
-        map { $board->add_offset($coords, $_) }
+        map { $board->add_offset($coords->_to_pair, $_) }
         ([-1,0],[0,-1],[0,1],[1,0])
     )
     {
 
     $self->_cells_loop(
         sub {
-            my ($cell_coords, $cell) = @_;
+            my ($cell_pair, $cell) = @_;
+
+            my $cell_coords = Games::Nurikabe::Solver::Coords->new(
+                {
+                    y => $cell_pair->[0], x => $cell_pair->[1]
+                }
+            );
 
             if (($cell->status() eq $NK_BLACK) && (! $cell->already_processed))
             {
                 QUEUE_LOOP:
                 while (my $coords = shift(@queue))
                 {
-                    my $q_c = $self->get_cell(
-                        Games::Nurikabe::Solver::Coords->new({y => $coords->[0], x => $coords->[1]}));
+                    my $q_c = $self->get_cell($coords);
+
                     if ($q_c->already_processed)
                     {
                         next QUEUE_LOOP;
                             {
                                 if (! $c->already_processed())
                                 {
-                                    push @queue, $to_check->_to_pair;
+                                    push @queue, $to_check;
                                 }
                             }
                             elsif ($c->status() eq $NK_UNKNOWN)

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

         );
 
     my @ret;
-    foreach my $cell (@{$self->known_cells()})
+    foreach my $cell_pair (@{$self->known_cells()})
     {
+        my $cell_coords = Games::Nurikabe::Solver::Coords->new(
+            {
+                y => $cell_pair->[0], x => $cell_pair->[1]
+            }
+        );
+
         $board->_vicinity_loop(
-            $cell,
+            $cell_coords,
             sub {
                 my $to_check = shift;
                 my $s = $to_check->to_s;
     {
         return;
     }
+
+    my $coords = Games::Nurikabe::Solver::Coords->new(
+        {y => $c->[0], x => $c->[1], }
+    );
     
-    $board->_vicinity_loop($c,
+    $board->_vicinity_loop($coords,
         sub {
             my $to_check = shift;