diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-12-26 11:26:34 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-12-26 11:26:34 +0000 |
| commit | 74f45138aeb6608137344c7d5245ff6e3ec12572 (patch) | |
| tree | 7cfa2acd8fd3a35e2d0bd39ee04570e908c2459f | |
| parent | f0ec00fb4cfc11b82ceb8adb54dc3460102448ac (diff) | |
| download | puzzles-74f45138aeb6608137344c7d5245ff6e3ec12572.zip puzzles-74f45138aeb6608137344c7d5245ff6e3ec12572.tar.gz puzzles-74f45138aeb6608137344c7d5245ff6e3ec12572.tar.bz2 puzzles-74f45138aeb6608137344c7d5245ff6e3ec12572.tar.xz | |
I've just noticed a bug in the Inertia solver: if you call it on an
already-solved grid (i.e. no gems), it will still attempt to show
you a move you can make. Eliminate that special case.
[originally from svn r6507]
| -rw-r--r-- | inertia.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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. |