Commits

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

Refactoring: converted _calc_vicinity to [,]

  • Participants
  • Parent commits aa33494

Comments (0)

Files changed (2)

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

 
 sub _calc_vicinity
 {
-    my ($self, $y, $x) = @_;
+    my $self = shift;
+    my ($y, $x) = @{shift()};
 
     my @ret;
 
             }
 
             if (all { $self->get_cell($_)->status() eq $NK_BLACK }
-                (@{$self->_calc_vicinity(@$coords)})
+                (@{$self->_calc_vicinity($coords)})
             )
             {
                 # We got an unknown cell that's entirely surrounded by blacks -

File nurikabe-solver/Games-Nurikabe-Solver/t/calc-vicinity.t

 
     # TEST
     eq_or_diff(
-        $board->_calc_vicinity(1,1),
+        $board->_calc_vicinity([1,1]),
         [[0,1],[1,0],[1,2],[2,1]],
         "Simple calc vicinity - 1,1",
     );
 
     # TEST
     eq_or_diff(
-        $board->_calc_vicinity(4,3),
+        $board->_calc_vicinity([4,3]),
         [[3,3],[4,2],[4,4]],
         "calc vicinity bottom - 4,3",
     );
 
     # TEST
     eq_or_diff(
-        $board->_calc_vicinity(0,0),
+        $board->_calc_vicinity([0,0]),
         [[0,1],[1,0]],
         "calc vicinity corner - 0,0",
     );
 
     # TEST
     eq_or_diff(
-        $board->_calc_vicinity(0,2),
+        $board->_calc_vicinity([0,2]),
         [[0,1],[0,3],[1,2]],
         "calc vicinity up - 0,2",
     );