1. Shlomi Fish
  2. nurikabe

Commits

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

Refactoring : extracted _add_move from one more place

  • Participants
  • Parent commits 757e0a2
  • Branches default

Comments (0)

Files changed (1)

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

View file
  • Ignore whitespace
 {
     my $self = shift;
 
-    my @moves;
-
     foreach my $y (0 .. ($self->_height()-1))
     {
         X_LOOP:
                 # We got an unknown cell that's entirely surrounded by blacks -
                 # let's do our thing.
                 $self->_mark_as_black($y,$x);
-                push @moves,
-                    Games::Nurikabe::Solver::Move->new(
-                        {
-                            reason => "surrounded_by_blacks",
-                            verdict_cells =>
-                                $self->_flush_verdict_marked_cells(),
-                        }
-                    );
+                $self->_add_move(
+                    {
+                        reason => "surrounded_by_blacks",
+                    }
+                );
             }
         }
     }
 
-    return \@moves;
+    return $self->_flush_moves();
 }
 
 sub _solve_using_adjacent_whites