aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-21 09:26:14 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-21 09:26:14 +0100
commit20606f0fea14fecae55efa7fef4314a2f999ddc3 (patch)
tree0018bf7aacfdc3dcfdd34c59cedca625262e8844
parentce203c12efe0e10445a3be56c4308db42d9086c8 (diff)
downloadpuzzles-20606f0fea14fecae55efa7fef4314a2f999ddc3.zip
puzzles-20606f0fea14fecae55efa7fef4314a2f999ddc3.tar.gz
puzzles-20606f0fea14fecae55efa7fef4314a2f999ddc3.tar.bz2
puzzles-20606f0fea14fecae55efa7fef4314a2f999ddc3.tar.xz
Filling: switch to using dsf_minimal in minimize_clue_set.
Turns out that was another case where we were assuming the canonical dsf element was also the minimal one, because we process the clues in order and expect to start a linked list at the canonical element of each region and then add the rest of the cells to the existing one. Easily fixed by using the minimal element again.
-rw-r--r--filling.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/filling.c b/filling.c
index c14fae4..61060b4 100644
--- a/filling.c
+++ b/filling.c
@@ -1135,7 +1135,7 @@ static DSF *make_dsf(DSF *dsf, int *board, const int w, const int h) {
int i;
if (!dsf)
- dsf = dsf_new(w * h);
+ dsf = dsf_new_min(w * h);
else
dsf_reinit(dsf);
@@ -1174,14 +1174,14 @@ static void minimize_clue_set(int *board, int w, int h, random_state *rs)
dsf = make_dsf(NULL, board, w, h);
next = snewn(sz, int);
for (i = 0; i < sz; ++i) {
- int j = dsf_canonify(dsf, i);
+ int j = dsf_minimal(dsf, i);
if (i == j) {
/* First cell of a region; set next[i] = -1 to indicate
* end-of-list. */
next[i] = -1;
} else {
/* Add this cell to a region which already has a
- * linked-list head, by pointing the canonical element j
+ * linked-list head, by pointing the minimal element j
* at this one, and pointing this one in turn at wherever
* j previously pointed. (This should end up with the
* elements linked in the order 1,n,n-1,n-2,...,2, which
@@ -1209,7 +1209,7 @@ static void minimize_clue_set(int *board, int w, int h, random_state *rs)
* if we can.
*/
for (i = 0; i < sz; ++i) {
- int j = dsf_canonify(dsf, shuf[i]);
+ int j = dsf_minimal(dsf, shuf[i]);
if (next[j] != -2) {
int tmp = board[j];
int k;