Improvement Using Heuristic
/* Let <r,c> be coordinates of an unvisited "neighbor" of current <r,c>, or <UNDEFINED,UNDEFINED> if current square has no unvisited neighbors. */
int fewest = 9; // min unvisited neighbors
int neighborR = UNDEFINED;
int neighborC = UNDEFINED;
for (int k = 0; k < 8; k++) {
int Nrow = r + deltaR[k];
int Ncol = c + deltaC[k];
if ( B[Nrow][Ncol] == Blank ){
int n = unvisited(Nrow, Ncol);
neighborR = Nrow; neighborC = Ncol;
- Go where the options are running out, i.e., go to the unvisited neighbor with the fewest unvisited neighbors.