mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Retire the YTRANS and YUNTRANS macros in latin.[ch]. They were
introduced to mimic similar macros in solo.c, in case Solo ever moved over to being based on the latin.c solver framework; but even Solo has long since lost those macros, so latin.c has no need to keep them. [originally from svn r8827]
This commit is contained in:
26
latin.c
26
latin.c
@ -62,7 +62,7 @@ void latin_solver_place(struct latin_solver *solver, int x, int y, int n)
|
|||||||
/*
|
/*
|
||||||
* Enter the number in the result grid.
|
* Enter the number in the result grid.
|
||||||
*/
|
*/
|
||||||
solver->grid[YUNTRANS(y)*o+x] = n;
|
solver->grid[y*o+x] = n;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cross out this number from the list of numbers left to place
|
* Cross out this number from the list of numbers left to place
|
||||||
@ -104,7 +104,7 @@ int latin_solver_elim(struct latin_solver *solver, int start, int step
|
|||||||
x = y / o;
|
x = y / o;
|
||||||
y %= o;
|
y %= o;
|
||||||
|
|
||||||
if (!solver->grid[YUNTRANS(y)*o+x]) {
|
if (!solver->grid[y*o+x]) {
|
||||||
#ifdef STANDALONE_SOLVER
|
#ifdef STANDALONE_SOLVER
|
||||||
if (solver_show_working) {
|
if (solver_show_working) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -114,7 +114,7 @@ int latin_solver_elim(struct latin_solver *solver, int start, int step
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
printf(":\n%*s placing %s at (%d,%d)\n",
|
printf(":\n%*s placing %s at (%d,%d)\n",
|
||||||
solver_recurse_depth*4, "", names[n-1],
|
solver_recurse_depth*4, "", names[n-1],
|
||||||
x+1, YUNTRANS(y)+1);
|
x+1, y+1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
latin_solver_place(solver, x, y, n);
|
latin_solver_place(solver, x, y, n);
|
||||||
@ -307,7 +307,7 @@ int latin_solver_set(struct latin_solver *solver,
|
|||||||
|
|
||||||
printf("%*s ruling out %s at (%d,%d)\n",
|
printf("%*s ruling out %s at (%d,%d)\n",
|
||||||
solver_recurse_depth*4, "",
|
solver_recurse_depth*4, "",
|
||||||
names[pn-1], px+1, YUNTRANS(py)+1);
|
names[pn-1], px+1, py+1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
progress = TRUE;
|
progress = TRUE;
|
||||||
@ -508,7 +508,7 @@ int latin_solver_forcing(struct latin_solver *solver,
|
|||||||
yl = yy;
|
yl = yy;
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("%s(%d,%d)", sep, xl+1,
|
printf("%s(%d,%d)", sep, xl+1,
|
||||||
YUNTRANS(yl)+1);
|
yl+1);
|
||||||
xl = bfsprev[yl*o+xl];
|
xl = bfsprev[yl*o+xl];
|
||||||
if (xl < 0)
|
if (xl < 0)
|
||||||
break;
|
break;
|
||||||
@ -519,7 +519,7 @@ int latin_solver_forcing(struct latin_solver *solver,
|
|||||||
printf("\n%*s ruling out %s at (%d,%d)\n",
|
printf("\n%*s ruling out %s at (%d,%d)\n",
|
||||||
solver_recurse_depth*4, "",
|
solver_recurse_depth*4, "",
|
||||||
names[orign-1],
|
names[orign-1],
|
||||||
xt+1, YUNTRANS(yt)+1);
|
xt+1, yt+1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cube(xt, yt, orign) = FALSE;
|
cube(xt, yt, orign) = FALSE;
|
||||||
@ -580,7 +580,7 @@ void latin_solver_alloc(struct latin_solver *solver, digit *grid, int o)
|
|||||||
for (x = 0; x < o; x++)
|
for (x = 0; x < o; x++)
|
||||||
for (y = 0; y < o; y++)
|
for (y = 0; y < o; y++)
|
||||||
if (grid[y*o+x])
|
if (grid[y*o+x])
|
||||||
latin_solver_place(solver, x, YTRANS(y), grid[y*o+x]);
|
latin_solver_place(solver, x, y, grid[y*o+x]);
|
||||||
|
|
||||||
#ifdef STANDALONE_SOLVER
|
#ifdef STANDALONE_SOLVER
|
||||||
solver->names = NULL;
|
solver->names = NULL;
|
||||||
@ -611,7 +611,7 @@ int latin_solver_diff_simple(struct latin_solver *solver)
|
|||||||
#ifdef STANDALONE_SOLVER
|
#ifdef STANDALONE_SOLVER
|
||||||
, "positional elimination,"
|
, "positional elimination,"
|
||||||
" %s in row %d", names[n-1],
|
" %s in row %d", names[n-1],
|
||||||
YUNTRANS(y)+1
|
y+1
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
@ -636,11 +636,11 @@ int latin_solver_diff_simple(struct latin_solver *solver)
|
|||||||
*/
|
*/
|
||||||
for (x = 0; x < o; x++)
|
for (x = 0; x < o; x++)
|
||||||
for (y = 0; y < o; y++)
|
for (y = 0; y < o; y++)
|
||||||
if (!solver->grid[YUNTRANS(y)*o+x]) {
|
if (!solver->grid[y*o+x]) {
|
||||||
ret = latin_solver_elim(solver, cubepos(x,y,1), 1
|
ret = latin_solver_elim(solver, cubepos(x,y,1), 1
|
||||||
#ifdef STANDALONE_SOLVER
|
#ifdef STANDALONE_SOLVER
|
||||||
, "numeric elimination at (%d,%d)",
|
, "numeric elimination at (%d,%d)",
|
||||||
x+1, YUNTRANS(y)+1
|
x+1, y+1
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
@ -664,7 +664,7 @@ int latin_solver_diff_set(struct latin_solver *solver,
|
|||||||
for (y = 0; y < o; y++) {
|
for (y = 0; y < o; y++) {
|
||||||
ret = latin_solver_set(solver, scratch, cubepos(0,y,1), o*o, 1
|
ret = latin_solver_set(solver, scratch, cubepos(0,y,1), o*o, 1
|
||||||
#ifdef STANDALONE_SOLVER
|
#ifdef STANDALONE_SOLVER
|
||||||
, "set elimination, row %d", YUNTRANS(y)+1
|
, "set elimination, row %d", y+1
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
@ -734,7 +734,7 @@ static int latin_solver_recurse
|
|||||||
*/
|
*/
|
||||||
count = 0;
|
count = 0;
|
||||||
for (n = 1; n <= o; n++)
|
for (n = 1; n <= o; n++)
|
||||||
if (cube(x,YTRANS(y),n))
|
if (cube(x,y,n))
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -770,7 +770,7 @@ static int latin_solver_recurse
|
|||||||
|
|
||||||
/* Make a list of the possible digits. */
|
/* Make a list of the possible digits. */
|
||||||
for (j = 0, n = 1; n <= o; n++)
|
for (j = 0, n = 1; n <= o; n++)
|
||||||
if (cube(x,YTRANS(y),n))
|
if (cube(x,y,n))
|
||||||
list[j++] = n;
|
list[j++] = n;
|
||||||
|
|
||||||
#ifdef STANDALONE_SOLVER
|
#ifdef STANDALONE_SOLVER
|
||||||
|
8
latin.h
8
latin.h
@ -30,14 +30,6 @@ struct latin_solver {
|
|||||||
#define gridpos(x,y) ((y)*solver->o+(x))
|
#define gridpos(x,y) ((y)*solver->o+(x))
|
||||||
#define grid(x,y) (solver->grid[gridpos(x,y)])
|
#define grid(x,y) (solver->grid[gridpos(x,y)])
|
||||||
|
|
||||||
/* A solo solver using this code would need these defined. See solo.c. */
|
|
||||||
#ifndef YTRANS
|
|
||||||
#define YTRANS(y) (y)
|
|
||||||
#endif
|
|
||||||
#ifndef YUNTRANS
|
|
||||||
#define YUNTRANS(y) (y)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* --- Solver individual strategies --- */
|
/* --- Solver individual strategies --- */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user