Commits

Anonymous committed 0f6bbb8

Added the _expected_totals() functionality.

Comments (0)

Files changed (2)

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

 
 __PACKAGE__->mk_accessors(qw(
     _cells
+    _expected_totals
+    _found_totals
     _height
     _islands
     _moves
     return $ret;
 }
 
+sub _num_expected_cells
+{
+    my $self = shift;
+    my $color = shift;
+
+    return $self->_expected_totals()->{$color};
+}
+
 sub _exist_verdict_marked_cells
 {
     my $self = shift;
 
     $self->_moves([]);
 
+    $self->_expected_totals
+    (
+        {
+            $NK_BLACK => ($self->_width()*$self->_height()),
+            $NK_WHITE => 0,
+        },
+    );
+
+    $self->_found_totals(
+        {
+            $NK_UNKNOWN => ($self->_width()*$self->_height()),
+            $NK_BLACK => 0,
+            $NK_WHITE => 0,
+        }
+    );
+
     return 0;
 }
 
                             order => $num_cells,
                         },
                     );
-                
+
+                $self->_expected_totals()->{$NK_WHITE} += $num_cells;
+                $self->_expected_totals()->{$NK_BLACK} -= $num_cells;
+
                 $cell_obj =
                     Games::Nurikabe::Solver::Cell->new(
                         {
                             island => $index,
                         }
                     );
+                # TODO :
+                # Mark the _found_totals().
             }
             push @{$cells[$y]}, $cell_obj;
         }

nurikabe-solver/Games-Nurikabe-Solver/t/solve1.t

 use strict;
 use warnings;
 
-use Test::More tests => 66;
+use Test::More tests => 68;
 
 use Test::Differences;
 
             $string_representation
         );
 
+    # TEST
+    is ($board->_num_expected_cells($NK_WHITE), 1, "Expecting 1 White Cell");
+
+    # TEST
+    is ($board->_num_expected_cells($NK_BLACK), 3, "Expecting 3 Black Cells");
+
     {
         my $moves = $board->_solve_using(
             {