mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
latin_solver_alloc: handle clashing numbers in input grid.
In the setup phase of the centralised latin.c solver, we start by going over the input grid containing already-placed clue numbers, and calling latin_solver_place to enter each on into the solver's data structure. This has the side effect of ruling out each number from the rest of the row and column, and _also_ checking by assertion that the number being placed is not ruled out. Those are a bad combination, because it means that if you give an obviously inconsistent input grid to latin_solver_alloc (e.g. with two identical numbers in a row already), it will fail an assertion. In that situation, you want the solver run as a whole to return diff_impossible so that the error is reported cleanly. This assertion failure could be provoked by giving either Towers or Group a manually-constructed game description inconsistent in that way, and hitting Solve. Worse, it could be provoked during live play in Unequal, by filling in a number clashing with a clue and then pressing 'h' to get hints.
This commit is contained in:
9
latin.h
9
latin.h
@ -61,10 +61,13 @@ int latin_solver_forcing(struct latin_solver *solver,
|
||||
/* --- Solver allocation --- */
|
||||
|
||||
/* Fills in (and allocates members for) a latin_solver struct.
|
||||
* Will allocate members of snew, but not snew itself
|
||||
* Will allocate members of solver, but not solver itself
|
||||
* (allowing 'struct latin_solver' to be the first element in a larger
|
||||
* struct, for example). */
|
||||
void latin_solver_alloc(struct latin_solver *solver, digit *grid, int o);
|
||||
* struct, for example).
|
||||
*
|
||||
* latin_solver_alloc returns false if the digits already in the grid
|
||||
* could not be legally placed. */
|
||||
bool latin_solver_alloc(struct latin_solver *solver, digit *grid, int o);
|
||||
void latin_solver_free(struct latin_solver *solver);
|
||||
|
||||
/* Allocates scratch space (for _set and _forcing) */
|
||||
|
Reference in New Issue
Block a user