groupsolver: fix assertion failure.

Reproduced via 'groupsolver -v 5i:p1g4' (thanks to Arun Giridhar for
the report).

The Group-specific solver_hard() function ruled out a bunch of
possibilities by deducing various things that couldn't be the group
identity, but forgot to set done_something = true, so that it return 0
claiming it hadn't done anything.

So latin_solver_top progressed to the next difficulty level and tried
recursion. And latin_solver_recurse failed an assertion because it was
surprised to find a cell with only one possibility - it expected that
the _simple_ deductions would have ruled out any of those, which they
would have if solver_hard() had returned >0, because the loop would
have reset to the top and tried the easy deductions again after
solver_hard() had given them something to work with.
This commit is contained in:
Simon Tatham
2024-12-22 20:08:14 +00:00
parent 59954d67f5
commit 5eea14c6c3

View File

@ -519,6 +519,7 @@ static int solver_hard(struct latin_solver *solver, void *vctx)
} }
#endif #endif
cube(i, j, j+1) = false; cube(i, j, j+1) = false;
done_something = true;
} }
if (cube(j, i, j+1)) { if (cube(j, i, j+1)) {
#ifdef STANDALONE_SOLVER #ifdef STANDALONE_SOLVER
@ -533,6 +534,7 @@ static int solver_hard(struct latin_solver *solver, void *vctx)
} }
#endif #endif
cube(j, i, j+1) = false; cube(j, i, j+1) = false;
done_something = true;
} }
} }
} }