{
int curr = island_countbridges(is), nspc = is->count - curr, nsurrspc;
int i, poss;
- grid_type v;
struct island *is_orth;
if (nspc < 0) {
int ifree, dx = is->adj.points[i].dx;
if (!is->adj.points[i].off) continue;
- v = GRID(is->state, is->adj.points[i].x, is->adj.points[i].y);
poss = POSSIBLES(is->state, dx,
is->adj.points[i].x, is->adj.points[i].y);
if (poss == 0) continue;
int *pkey, *gkey;
float t[3];
float angle;
- game_state *newstate;
int square;
draw_rect(dr, 0, 0, XSIZE(GRID_SCALE, bb, state->solid),
pkey = state->spkey;
gkey = state->sgkey;
}
- newstate = state;
state = oldstate;
for (i = 0; i < state->grid->nsquares; i++) {
game_state *state, int dir, game_ui *ui,
float animtime, float flashtime)
{
- int i, new_move, last_go;
+ int i, new_move;
new_move = (state->next_go != ds->next_go) || !ds->started;
- last_go = (state->next_go == state->params.nguesses-1);
if (!ds->started) {
draw_rect(dr, 0, 0, ds->w, ds->h, COL_BACKGROUND);
/* didn't find a nice one, use a nasty one */
for (i = 0; i < a; i++) {
j = order[i];
- if (singletons[j] & good) {
+ if (singletons[j] & bad) {
clues[j] = clue;
singletons[j] = 0;
break;
{
int w = params->w, a = w*w;
game_state *state = snew(game_state);
- char *err;
const char *p = desc;
int i;
state->clues->refcount = 1;
state->clues->w = w;
state->clues->dsf = snew_dsf(a);
- err = parse_block_structure(&p, w, state->clues->dsf);
+ parse_block_structure(&p, w, state->clues->dsf);
assert(*p == ',');
p++;
}
}
}
+ debug(("Stripped %d unused numbers.\n", n));
return n;
}
char **aux, int interactive)
{
game_state *news = new_state(params), *copys;
- int nsol, i, j, run, x, y, wh = params->w*params->h, num;
+ int i, j, run, x, y, wh = params->w*params->h, num;
char *ret, *p;
int *numindices;
/* Take a copy, remove numbers we didn't use and check there's
* still a unique solution; if so, use the copy subsequently. */
copys = dup_game(news);
- nsol = strip_unused_nums(copys);
- debug(("Stripped %d unused numbers.\n", nsol));
+ strip_unused_nums(copys);
if (!puzzle_is_good(copys, params->difficulty)) {
debug(("Stripped grid is not good, reverting.\n"));
free_game(copys);
grid *g = state->game_grid;
grid_edge *e = g->edges + i;
int x1, x2, y1, y2;
- int xmin, ymin, xmax, ymax;
int line_colour;
if (state->line_errors[i])
grid_to_screen(ds, g, e->dot1->x, e->dot1->y, &x1, &y1);
grid_to_screen(ds, g, e->dot2->x, e->dot2->y, &x2, &y2);
- xmin = min(x1, x2);
- xmax = max(x1, x2);
- ymin = min(y1, y2);
- ymax = max(y1, y2);
-
if (line_colour == COL_FAINT) {
static int draw_faint_lines = -1;
if (draw_faint_lines < 0) {
static int solve_force(game_state *state)
{
- int x, y, i, which, didsth = 0;
+ int i, which, didsth = 0;
unsigned long f;
for (i = 0; i < state->wh; i++) {
if (f == (GS_NOTNEGATIVE|GS_NOTNEUTRAL))
which = POSITIVE;
if (which != -1) {
- x = i%state->w; y = i/state->w;
if (solve_set(state, i, which, "forced by flags", NULL) < 0)
return -1;
didsth = 1;
static int solve_neither(game_state *state)
{
- int x, y, i, j, didsth = 0;
+ int i, j, didsth = 0;
for (i = 0; i < state->wh; i++) {
if (state->flags[i] & GS_SET) continue;
(state->flags[j] & GS_NOTPOSITIVE)) ||
((state->flags[i] & GS_NOTNEGATIVE) &&
(state->flags[j] & GS_NOTNEGATIVE))) {
- x = i%state->w; y = i/state->w;
if (solve_set(state, i, NEUTRAL, "neither tile magnet", NULL) < 0)
return -1;
didsth = 1;
static int lay_dominoes(game_state *state, random_state *rs, int *scratch)
{
- int n, i, ret = 0, x, y, nlaid = 0, n_initial_neutral;
+ int n, i, ret = 0, nlaid = 0, n_initial_neutral;
for (i = 0; i < state->wh; i++) {
scratch[i] = i;
/* ...and lay a domino if we can. */
- x = i%state->w; y = i/state->w;
- debug(("Laying domino at i:%d, (%d,%d)\n", i, x, y));
+ debug(("Laying domino at i:%d, (%d,%d)\n", i, i%state->w, i/state->w));
/* The choice of which type of domino to lay here leads to subtle differences
* in the sorts of boards that get produced. Too much bias towards magnets
int w = state->w, h = state->h;
int ink = print_mono_colour(dr, 0);
int paper = print_mono_colour(dr, 1);
- int x, y, target, count, which, i, j;
+ int x, y, which, i, j;
/* Ick: fake up `ds->tilesize' for macro expansion purposes */
game_drawstate ads, *ds = &ads;
draw_sym(dr, ds, state->w, state->h, NEGATIVE, ink);
for (which = POSITIVE, j = 0; j < 2; which = OPPOSITE(which), j++) {
for (i = 0; i < w; i++) {
- target = state->common->colcount[i*3+which];
- count = count_rowcol(state, i, COLUMN, which);
draw_num_col(dr, ds, COLUMN, which, i, paper, ink,
- state->common->colcount[i*3+which]);
+ state->common->colcount[i*3+which]);
}
for (i = 0; i < h; i++) {
- target = state->common->rowcount[i*3+which];
- count = count_rowcol(state, i, ROW, which);
draw_num_col(dr, ds, ROW, which, i, paper, ink,
- state->common->rowcount[i*3+which]);
+ state->common->rowcount[i*3+which]);
}
}
static game_state *new_game(midend *me, game_params *params, char *desc)
{
game_state *state = snew(game_state);
- int i, wh, x, y, ret, masked;
+ int i, wh, x, y, masked;
unsigned char *bmp;
state->w = params->w;
}
if (x >= 0 && y >= 0)
- ret = open_square(state, x, y);
+ open_square(state, x, y);
sfree(bmp);
}
game_drawstate *ds, int x, int y, int button)
{
int cx, cy;
- int n, dx, dy;
+ int dx, dy;
char buf[80];
button &= ~MOD_MASK;
if (cx == -1) dx = +1;
else if (cx == state->width) dx = -1;
else return NULL;
- n = state->width;
dy = 0;
}
else if (cx >= 0 && cx < state->width && cx != state->cx)
if (cy == -1) dy = +1;
else if (cy == state->height) dy = -1;
else return NULL;
- n = state->height;
dx = 0;
}
else
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
game_state *state, int dir, game_ui *ui, float t, float ft)
{
- int x, y, tx, ty, frame;
+ int x, y, frame;
unsigned char *active;
float xshift = 0.0;
float yshift = 0.0;
t = ANIM_TIME - t;
}
- tx = ty = -1;
if (oldstate && (t < ANIM_TIME)) {
/*
* We're animating a slide, of row/column number
char *soln, struct solver_scratch *sc, int diff)
{
int x, y, d, i, j;
- char *mrow, *mrow1, *mrow2, *trow, *trow1, *trow2;
+ char *mrow, *trow, *trow1, *trow2;
/*
* Set up solver data.
* hasn't been set up yet.
*/
mrow = sc->mrows;
- mrow1 = sc->mrows + len;
- mrow2 = sc->mrows + 2*len;
trow = sc->trows;
trow1 = sc->trows + len;
trow2 = sc->trows + 2*len;
}
for (i = 0; i < 4*w; i++) {
- int start, step, j, k, n, best;
+ int start, step, j, n, best;
STARTSTEP(start, step, i, w);
if (!clues[i])
continue;
best = n = 0;
- k = 0;
for (j = 0; j < w; j++) {
int number = grid[start+j*step];
if (!number)
static char *validate_desc(game_params *params, char *desc)
{
- char *p, *err;
+ char *p;
int w = params->w, h = params->h, wh = w*h;
int i;
p = desc;
- err = NULL;
for (i = 0; i < wh; i++) {
if (*p < '0' || *p > '9')
{
int ls = state->order * state->order * 5;
int maxposs = 0, minclues = 5, best = -1, i, j;
- int nposs, nclues, loc, x, y;
+ int nposs, nclues, loc;
#ifdef STANDALONE_SOLVER
if (solver_show_working) {
if (!gg_place_clue(state, scratch[i], latin, 1)) continue;
loc = scratch[i] / 5;
- x = loc % state->order; y = loc / state->order;
for (j = nposs = 0; j < state->order; j++) {
if (state->hints[loc*state->order + j]) nposs++;
}
(nposs == maxposs && nclues < minclues)) {
best = i; maxposs = nposs; minclues = nclues;
#ifdef STANDALONE_SOLVER
- if (solver_show_working)
+ if (solver_show_working) {
+ int x = loc % state->order, y = loc / state->order;
printf("gg_best_clue: b%d (%d,%d) new best [%d poss, %d clues].\n",
best, x+1, y+1, nposs, nclues);
+ }
#endif
}
}
{
int w = params->w, h = params->h, wh = w*h;
int *active, *link;
- int mains = 0, mpos = -1;
+ int mains = 0;
int i, tx, ty, minmoves;
char *ret;
link[i] = -1;
if (strchr("mM", c) != NULL) {
mains++;
- mpos = i;
}
i++;
}
game_state *s;
char *id = NULL, *desc, *err;
int count = FALSE;
- int ret, really_verbose = FALSE;
+ int ret;
int *moves;
while (--argc > 0) {
char *p = *++argv;
+ /*
if (!strcmp(p, "-v")) {
- really_verbose = TRUE;
- } else if (!strcmp(p, "-c")) {
+ verbose = TRUE;
+ } else
+ */
+ if (!strcmp(p, "-c")) {
count = TRUE;
} else if (*p == '-') {
fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);