diff options
| author | Simon Tatham <anakin@pobox.com> | 2023-04-20 15:32:10 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2023-04-20 18:39:35 +0100 |
| commit | 14e1e05510ac02a5502823bafe46d98c6fab3e5c (patch) | |
| tree | d7e99ac9bb574bc62a324cf3bb435b485c1113b3 /bridges.c | |
| parent | 088fdeee38599b1711ba8766d36c652f1355e36e (diff) | |
| download | puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.zip puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.tar.gz puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.tar.bz2 puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.tar.xz | |
Introduce a new dsf_equivalent() function.
Not very interesting, but the idiom for checking equivalence via two
calls to dsf_canonify is cumbersome enough to be worth abbreviating.
Diffstat (limited to 'bridges.c')
| -rw-r--r-- | bridges.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1167,7 +1167,7 @@ static void map_group(game_state *state) if (!is_join) continue; d2 = DINDEX(is_join->x, is_join->y); - if (dsf_canonify(dsf,d1) == dsf_canonify(dsf,d2)) { + if (dsf_equivalent(dsf, d1, d2)) { ; /* we have a loop. See comment in map_hasloops. */ /* However, we still want to merge all squares joining * this side-that-makes-a-loop. */ @@ -1291,7 +1291,7 @@ static void solve_join(struct island *is, int direction, int n, bool is_max) if (n > 0 && !is_max) { d1 = DINDEX(is->x, is->y); d2 = DINDEX(is_orth->x, is_orth->y); - if (dsf_canonify(dsf, d1) != dsf_canonify(dsf, d2)) + if (!dsf_equivalent(dsf, d1, d2)) dsf_merge(dsf, d1, d2); } } @@ -1410,7 +1410,7 @@ static bool solve_island_checkloop(struct island *is, int direction) d1 = DINDEX(is->x, is->y); d2 = DINDEX(is_orth->x, is_orth->y); - if (dsf_canonify(dsf, d1) == dsf_canonify(dsf, d2)) { + if (dsf_equivalent(dsf, d1, d2)) { /* two islands are connected already; don't join them. */ return true; } |