X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/3fba56cbf5cad13401f183ca7e38a512e7090ae3..3938499711227354698c84c7d5b36b8c606ea3c3:/inertia.c diff --git a/inertia.c b/inertia.c index d45ecc8..10ea538 100644 --- a/inertia.c +++ b/inertia.c @@ -735,6 +735,18 @@ static char *solve_game(game_state *state, game_state *currstate, char *err, *soln, *p; /* + * Before anything else, deal with the special case in which + * all the gems are already collected. + */ + for (i = 0; i < wh; i++) + if (currstate->grid[i] == GEM) + break; + if (i == wh) { + *error = "Game is already solved"; + return NULL; + } + + /* * Solving Inertia is a question of first building up the graph * of where you can get to from where, and secondly finding a * tour of the graph which takes in every gem. @@ -1160,7 +1172,7 @@ static char *solve_game(game_state *state, game_state *currstate, } } -#ifndef TSP_DIAGNOSTICS +#ifdef TSP_DIAGNOSTICS printf("before reduction, moves are "); x = nodes[circuit[0]] / DP1 % w; y = nodes[circuit[0]] / DP1 / w; @@ -1246,7 +1258,7 @@ static char *solve_game(game_state *state, game_state *currstate, p = min(i, j); q = max(i, j); -#ifndef TSP_DIAGNOSTICS +#ifdef TSP_DIAGNOSTICS printf("optimising section from %d - %d\n", p, q); #endif @@ -1280,7 +1292,7 @@ static char *solve_game(game_state *state, game_state *currstate, if (dir > 0) i = q; /* resume loop from the right place */ -#ifndef TSP_DIAGNOSTICS +#ifdef TSP_DIAGNOSTICS printf("new section runs from %d - %d\n", p, q); #endif @@ -1316,7 +1328,7 @@ static char *solve_game(game_state *state, game_state *currstate, j = i; -#ifndef TSP_DIAGNOSTICS +#ifdef TSP_DIAGNOSTICS printf("during reduction, circuit is"); for (k = 0; k < circuitlen; k++) { int nc = nodes[circuit[k]]; @@ -1345,7 +1357,7 @@ static char *solve_game(game_state *state, game_state *currstate, } } -#ifndef TSP_DIAGNOSTICS +#ifdef TSP_DIAGNOSTICS printf("after reduction, moves are "); x = nodes[circuit[0]] / DP1 % w; y = nodes[circuit[0]] / DP1 / w; @@ -1692,7 +1704,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds, ds->player_background = blitter_new(dr, TILESIZE, TILESIZE); } -static float *game_colours(frontend *fe, game_state *state, int *ncolours) +static float *game_colours(frontend *fe, int *ncolours) { float *ret = snewn(3 * NCOLOURS, float); int i; @@ -1899,12 +1911,12 @@ static void draw_tile(drawing *dr, game_drawstate *ds, int x, int y, int v) int coords[8]; coords[0] = tx+TILESIZE/2; - coords[1] = ty+TILESIZE*1/7; - coords[2] = tx+TILESIZE*1/7; + coords[1] = ty+TILESIZE/2-TILESIZE*5/14; + coords[2] = tx+TILESIZE/2-TILESIZE*5/14; coords[3] = ty+TILESIZE/2; coords[4] = tx+TILESIZE/2; - coords[5] = ty+TILESIZE-TILESIZE*1/7; - coords[6] = tx+TILESIZE-TILESIZE*1/7; + coords[5] = ty+TILESIZE/2+TILESIZE*5/14; + coords[6] = tx+TILESIZE/2+TILESIZE*5/14; coords[7] = ty+TILESIZE/2; draw_polygon(dr, coords, 4, COL_GEM, COL_OUTLINE); @@ -2122,11 +2134,6 @@ static float game_flash_length(game_state *oldstate, game_state *newstate, return 0.0F; } -static int game_wants_statusbar(void) -{ - return TRUE; -} - static int game_timing_state(game_state *state, game_ui *ui) { return TRUE; @@ -2145,7 +2152,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize) #endif const struct game thegame = { - "Inertia", "games.inertia", + "Inertia", "games.inertia", "inertia", default_params, game_fetch_preset, decode_params, @@ -2176,7 +2183,7 @@ const struct game thegame = { game_anim_length, game_flash_length, FALSE, FALSE, game_print_size, game_print, - game_wants_statusbar, + TRUE, /* wants_statusbar */ FALSE, game_timing_state, - 0, /* mouse_priorities */ + 0, /* flags */ };