diff options
| author | Simon Tatham <anakin@pobox.com> | 2007-08-18 11:19:29 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2007-08-18 11:19:29 +0000 |
| commit | 333d57bf6ec7def6fa78215a71a2d05476167fc1 (patch) | |
| tree | 591fa4e206fd0c5f6062f711046112684c0a6e84 | |
| parent | cc54c09413a08ea150fd8cc6706ed61ccc8ce47e (diff) | |
| download | puzzles-333d57bf6ec7def6fa78215a71a2d05476167fc1.zip puzzles-333d57bf6ec7def6fa78215a71a2d05476167fc1.tar.gz puzzles-333d57bf6ec7def6fa78215a71a2d05476167fc1.tar.bz2 puzzles-333d57bf6ec7def6fa78215a71a2d05476167fc1.tar.xz | |
Better test-mode diagnostics.
[originally from svn r7691]
| -rw-r--r-- | unfinished/divvy.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/unfinished/divvy.c b/unfinished/divvy.c index 9e6805d..f35afc8 100644 --- a/unfinished/divvy.c +++ b/unfinished/divvy.c @@ -201,6 +201,9 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs) if (j == 0) break; /* all ominoes are complete! */ 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 @@ -263,7 +266,7 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs) * addable to this omino when the omino is * missing a square. To do this it's only * necessary to re-check addremcommon. -~|~ */ + */ if (!addremcommon(w, h, order[i]%w, order[i]/w, own, j)) continue; @@ -282,13 +285,25 @@ int *divvy_rectangle(int w, int h, int k, random_state *rs) * moving squares between ominoes, ending up * expanding our starting omino by one. */ +#ifdef DIVVY_DIAGNOSTICS + printf("(%d,%d)", i%w, i/w); +#endif while (1) { own[i] = j; +#ifdef DIVVY_DIAGNOSTICS + printf(" -> %d", j); +#endif if (tmp[2*j] == -2) break; i = tmp[2*j+1]; 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. @@ -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 * give up? */ +#ifdef DIVVY_DIAGNOSTICS + printf("FAIL!\n"); +#endif retdsf = NULL; 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. */ |