- /* Check all tiles are associated with something, and all shapes
- * are the correct symmetry (i.e. all tiles have a matching tile
- * the opposite direction from the dot) */
-static int cccb_assoc(game_state *state, space *tile, void *unused)
-{
- assert(tile->type == s_tile);
-
- if (!(tile->flags & F_TILE_ASSOC)) return -1;
- return 0;
-}
-
-struct dgs_ctx {
- space *dot;
- int ndots;
-};
-
-static int dgs_cb_check(game_state *state, space *tile, void *vctx)
-{
- struct dgs_ctx *ctx = (struct dgs_ctx *)vctx;
- space *opp;
-
- if (!(tile->flags & F_TILE_ASSOC)) return 0;
- if (tile->dotx != ctx->dot->x ||
- tile->doty != ctx->dot->y) return 0;
-
- ctx->ndots += 1;
-
- /* Check this tile has an opposite associated with same dot. */
- opp = tile_opposite(state, tile);
- if (!opp || !(opp->flags & F_TILE_ASSOC)) return -1;
- if (opp->dotx != tile->dotx || opp->doty != tile->doty) return -1;
-
- /* Check its edges are correct */
- if (outline_tile_fordot(state, tile, 0) == 1)
- return -1; /* there was some fixing required, we're wrong. */
-
- return 0;
-}
-
-static int dot_good_shape(game_state *state, space *dot, int mark)
-{
- struct dgs_ctx ctx;
-
- ctx.dot = dot;
- ctx.ndots = 0;
-
- if (mark) dot->flags &= ~F_GOOD;
-
- if (foreach_tile(state, dgs_cb_check, 0, &ctx) == -1)
- return 0;
- if (ctx.ndots == 0) return 0; /* no dots assoc. with tile. */
-
- if (mark) {
- debug(("marking dot %d,%d good tile.\n", dot->x, dot->y));
- dot->flags |= F_GOOD;
- }
- return 1;
-}
-
-static int check_complete(game_state *state, int mark_errors)
-{
- int i, complete = 1;
-
- /* Are all tiles associated? */
- if (foreach_tile(state, cccb_assoc, 0, NULL) == -1)
- complete = 0;
-
- /* Check all dots are associated, and their tiles are well-formed. */
- for (i = 0; i < state->ndots; i++) {
- if (!dot_good_shape(state, state->dots[i], mark_errors))
- complete = 0;
- }
-
- /*if (complete == 1) printf("Complete!\n");*/
- return complete;
-}
-
-/* Returns a move string for use by 'solve'; if you don't want the
- * initial 'S;' use ret[2]. */