mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Couple of small changes to Singles from James H which missed my main
commit: tweak the grid generation a bit, and fix the use of the Solve function on a grid containing errors. [originally from svn r8835]
This commit is contained in:
14
singles.c
14
singles.c
@ -1164,11 +1164,11 @@ static char *solve_game(game_state *state, game_state *currstate,
|
|||||||
game_state *solved = dup_game(currstate);
|
game_state *solved = dup_game(currstate);
|
||||||
char *move = NULL;
|
char *move = NULL;
|
||||||
|
|
||||||
if (solve_specific(solved, DIFF_ANY, 0)) goto solved;
|
if (solve_specific(solved, DIFF_ANY, 0) > 0) goto solved;
|
||||||
free_game(solved);
|
free_game(solved);
|
||||||
|
|
||||||
solved = dup_game(state);
|
solved = dup_game(state);
|
||||||
if (solve_specific(solved, DIFF_ANY, 0)) goto solved;
|
if (solve_specific(solved, DIFF_ANY, 0) > 0) goto solved;
|
||||||
free_game(solved);
|
free_game(solved);
|
||||||
|
|
||||||
*error = "Unable to solve puzzle.";
|
*error = "Unable to solve puzzle.";
|
||||||
@ -1256,7 +1256,7 @@ static int best_black_col(game_state *state, random_state *rs, int *scratch,
|
|||||||
for (i = 0; i < o; i++) {
|
for (i = 0; i < o; i++) {
|
||||||
j = scratch[i] + 1;
|
j = scratch[i] + 1;
|
||||||
if (rownums[y*o + j-1] == 1 && colnums[x*o + j-1] == 1)
|
if (rownums[y*o + j-1] == 1 && colnums[x*o + j-1] == 1)
|
||||||
return j;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then try each number in turn returning the first one that's
|
/* Then try each number in turn returning the first one that's
|
||||||
@ -1264,10 +1264,16 @@ static int best_black_col(game_state *state, random_state *rs, int *scratch,
|
|||||||
for (i = 0; i < o; i++) {
|
for (i = 0; i < o; i++) {
|
||||||
j = scratch[i] + 1;
|
j = scratch[i] + 1;
|
||||||
if (rownums[y*o + j-1] != 0 || colnums[x*o + j-1] != 0)
|
if (rownums[y*o + j-1] != 0 || colnums[x*o + j-1] != 0)
|
||||||
return j;
|
goto found;
|
||||||
}
|
}
|
||||||
assert(!"unable to place number under black cell.");
|
assert(!"unable to place number under black cell.");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
found:
|
||||||
|
/* Update column and row counts assuming this number will be placed. */
|
||||||
|
rownums[y*o + j-1] += 1;
|
||||||
|
colnums[x*o + j-1] += 1;
|
||||||
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *new_game_desc(game_params *params, random_state *rs,
|
static char *new_game_desc(game_params *params, random_state *rs,
|
||||||
|
Reference in New Issue
Block a user