int line_solve(Puzzle *puz, Solution *sol, int contradicting) { extern dir_t cont_dir; extern line_t cont_line; dir_t dir; line_t i; int depth; while (next_job(puz, &dir, &i, &depth)) { nlines++; if ((VB && !VC) || WL(dir,i)) printf("*** %s %d\n",CLUENAME(puz->type,dir), i); if (VB || WL(dir,i)) dump_line(stdout,puz,sol,dir,i); if (contradicting && depth >= contradepth) { /* At max depth we just check if the line is solvable */ line_t *pos, *bcl; if (!left_solve(puz, sol, dir, i, 0, &pos, &bcl)) { if ((VC&&VV) || WL(dir,i)) printf("C: %s %d OK AT DEPTH %d\n", cluename(puz->type,dir),i,depth); } else { if ((VC&&VV) || WL(dir,i)) printf("C: %s %d FAILED AT DEPTH %d\n", cluename(puz->type,dir),i,depth); if (contradicting) { cont_dir= dir; cont_line= i; } return 0; } } else if (apply_lro(puz, sol, dir, i, depth + 1)) { /* Found a contradiction */ if (contradicting) { cont_dir= dir; cont_line= i; } return 0; } if (VJ) { printf("CURRENT JOBS:\n"); dump_jobs(stdout,puz); } } return 1; }
void add_jobs(Puzzle *puz, Solution *sol, int except, Cell *cell, int depth, bit_type *old) { dir_t k; line_t i, j; int lwork, rwork; /* While probing, we OR all bits set into our scratchpad. These values * should not be probed on later during this sequence. */ if (probing) fbit_or(propad(cell),cell->bit); if (!maylinesolve) return; for (k= 0; k < puz->nset; k++) if (k != except) { i= cell->line[k]; j= cell->index[k]; /* We only add the job only if either the saved left or right * solution for the line has been invalidated. */ if (VL || WL(puz->clue[k][i])) printf ("L: CHECK OLD SOLN FOR %s %d CELL %d\n", CLUENAME(puz->type,k),i,j); lwork= left_check(&puz->clue[k][i], j, cell->bit); rwork= right_check(&puz->clue[k][i], j, cell->bit); if (lwork || rwork) { add_job(puz, k, i, depth, newedge(puz, sol->line[k][i], j, old, cell->bit) ); if (!VJ && WL(puz->clue[k][i])) dump_jobs(stdout,puz); } } }