mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Better test-mode diagnostics.
[originally from svn r7691]
This commit is contained in:
@ -201,6 +201,9 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs)
|
|||||||
if (j == 0)
|
if (j == 0)
|
||||||
break; /* all ominoes are complete! */
|
break; /* all ominoes are complete! */
|
||||||
j = tmp[random_upto(rs, j)];
|
j = tmp[random_upto(rs, j)];
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
printf("Trying to extend %d\n", j);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* So we're trying to expand omino j. We breadth-first
|
* So we're trying to expand omino j. We breadth-first
|
||||||
@ -263,7 +266,7 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs)
|
|||||||
* addable to this omino when the omino is
|
* addable to this omino when the omino is
|
||||||
* missing a square. To do this it's only
|
* missing a square. To do this it's only
|
||||||
* necessary to re-check addremcommon.
|
* necessary to re-check addremcommon.
|
||||||
~|~ */
|
*/
|
||||||
if (!addremcommon(w, h, order[i]%w, order[i]/w,
|
if (!addremcommon(w, h, order[i]%w, order[i]/w,
|
||||||
own, j))
|
own, j))
|
||||||
continue;
|
continue;
|
||||||
@ -282,13 +285,25 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs)
|
|||||||
* moving squares between ominoes, ending up
|
* moving squares between ominoes, ending up
|
||||||
* expanding our starting omino by one.
|
* expanding our starting omino by one.
|
||||||
*/
|
*/
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
printf("(%d,%d)", i%w, i/w);
|
||||||
|
#endif
|
||||||
while (1) {
|
while (1) {
|
||||||
own[i] = j;
|
own[i] = j;
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
printf(" -> %d", j);
|
||||||
|
#endif
|
||||||
if (tmp[2*j] == -2)
|
if (tmp[2*j] == -2)
|
||||||
break;
|
break;
|
||||||
i = tmp[2*j+1];
|
i = tmp[2*j+1];
|
||||||
j = tmp[2*j];
|
j = tmp[2*j];
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
printf("; (%d,%d)", i%w, i/w);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Increment the size of the starting omino.
|
* Increment the size of the starting omino.
|
||||||
@ -365,11 +380,26 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs)
|
|||||||
* FIXME: or should we loop over all ominoes before we
|
* FIXME: or should we loop over all ominoes before we
|
||||||
* give up?
|
* give up?
|
||||||
*/
|
*/
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
printf("FAIL!\n");
|
||||||
|
#endif
|
||||||
retdsf = NULL;
|
retdsf = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DIVVY_DIAGNOSTICS
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
printf("SUCCESS! Final grid:\n");
|
||||||
|
for (y = 0; y < h; y++) {
|
||||||
|
for (x = 0; x < w; x++)
|
||||||
|
printf("%3d", own[y*w+x]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct the output dsf.
|
* Construct the output dsf.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user