X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/ac9f41c4c8ccbf9364a5d351e4cb134812a9926b..9b185b04d84ce479f224700d1dc83497719e22df:/inertia.c diff --git a/inertia.c b/inertia.c index a1ad50a..6531b98 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.