shithub: puzzles

Download patch

ref: 5fb108db00c8ad50b838274c24f7d1afc2cdd19b
parent: 02cd67ecb676cb1296d29630483e786f4f0303f6
author: Simon Tatham <[email protected]>
date: Fri Mar 23 14:08:21 EDT 2007

Kyle Brazell points out that the completion checker considers a
region valid if it has _a_ dot at its centre of symmetry, even if
that dot isn't actually within the region in question.

[originally from svn r7407]

--- a/galaxies.c
+++ b/galaxies.c
@@ -2622,10 +2622,16 @@
      */
     for (i = 0; i < w*h; i++)
         if (sqdata[i].valid) {
-            sqdata[i].cx = sqdata[i].minx + sqdata[i].maxx + 1;
-            sqdata[i].cy = sqdata[i].miny + sqdata[i].maxy + 1;
+            int cx, cy;
+            cx = sqdata[i].cx = sqdata[i].minx + sqdata[i].maxx + 1;
+            cy = sqdata[i].cy = sqdata[i].miny + sqdata[i].maxy + 1;
             if (!(SPACE(state, sqdata[i].cx, sqdata[i].cy).flags & F_DOT))
                 sqdata[i].valid = FALSE;   /* no dot at centre of symmetry */
+            if (dsf_canonify(dsf, (cy-1)/2*w+(cx-1)/2) != i ||
+                dsf_canonify(dsf, (cy)/2*w+(cx-1)/2) != i ||
+                dsf_canonify(dsf, (cy-1)/2*w+(cx)/2) != i ||
+                dsf_canonify(dsf, (cy)/2*w+(cx)/2) != i)
+                sqdata[i].valid = FALSE;   /* dot at cx,cy isn't ours */
             if (SPACE(state, sqdata[i].cx, sqdata[i].cy).flags & F_DOT_BLACK)
                 sqdata[i].colour = 2;
             else