mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Improve connectedness-error highlighting in Singles.
Using exactly the same policy as I did for Range the other day: if multiple regions exist, then one is taken to be canonical and all the others are marked as errors. [originally from svn r10233]
This commit is contained in:
24
singles.c
24
singles.c
@ -535,18 +535,30 @@ static int check_complete(game_state *state, unsigned flags)
|
|||||||
for (y = 0; y < h; y++) /* check rows from (0,y) */
|
for (y = 0; y < h; y++) /* check rows from (0,y) */
|
||||||
error += check_rowcol(state, y*w, 1, w, flags);
|
error += check_rowcol(state, y*w, 1, w, flags);
|
||||||
|
|
||||||
/* mark (all) white regions as an error if there is more than one.
|
/* If there's more than one white region, pick the largest one to
|
||||||
* may want to make this less in-your-face (by only marking
|
* be the canonical one (arbitrarily tie-breaking towards lower
|
||||||
* the smallest region as an error, for example -- but what if we
|
* array indices), and mark all the others as erroneous. */
|
||||||
* have two regions of identical size?) */
|
{
|
||||||
for (i = 0; i < state->n; i++) {
|
int largest = 0, canonical = -1;
|
||||||
|
for (i = 0; i < state->n; i++)
|
||||||
|
if (!(state->flags[i] & F_BLACK)) {
|
||||||
|
int size = dsf_size(dsf, i);
|
||||||
|
if (largest < size) {
|
||||||
|
largest = size;
|
||||||
|
canonical = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (largest < nwhite) {
|
||||||
|
for (i = 0; i < state->n; i++)
|
||||||
if (!(state->flags[i] & F_BLACK) &&
|
if (!(state->flags[i] & F_BLACK) &&
|
||||||
dsf_size(dsf, i) < nwhite) {
|
dsf_canonify(dsf, i) != canonical) {
|
||||||
error += 1;
|
error += 1;
|
||||||
if (flags & CC_MARK_ERRORS)
|
if (flags & CC_MARK_ERRORS)
|
||||||
state->flags[i] |= F_ERROR;
|
state->flags[i] |= F_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sfree(dsf);
|
sfree(dsf);
|
||||||
return (error > 0) ? 0 : 1;
|
return (error > 0) ? 0 : 1;
|
||||||
|
Reference in New Issue
Block a user