mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Group: fix loop bounds in the solver.
Applications of the associativity rule were iterating over only n-1 of the group elements, because I started the loops at 1 rather than 0. So the solver was a bit underpowered, and would have had trouble with some perfectly good unambiguous game ids such as 6i:2a5i4a6a1s . (The latin.c system is very confusing for this, because for historical reasons due to its ancestry in Solo, grid coordinates run from 0 to n-1 inclusive, but grid _contents_ run from 1 to n, using 0 as the 'unknown' value. So there's a constant risk of getting confused as to which kind of value you're dealing with.) This solver weakness only affects puzzles in 'identity hidden' mode, because in normal mode, the omitted row and column are those of the group identity, and applications of associativity involving the identity never generate anything interesting.
This commit is contained in:
@ -312,9 +312,9 @@ static int solver_normal(struct latin_solver *solver, void *vctx)
|
||||
* So we pick any a,b,c we like; then if we know ab, bc, and
|
||||
* (ab)c we can fill in a(bc).
|
||||
*/
|
||||
for (i = 1; i < w; i++)
|
||||
for (j = 1; j < w; j++)
|
||||
for (k = 1; k < w; k++) {
|
||||
for (i = 0; i < w; i++)
|
||||
for (j = 0; j < w; j++)
|
||||
for (k = 0; k < w; k++) {
|
||||
if (!grid[i*w+j] || !grid[j*w+k])
|
||||
continue;
|
||||
if (grid[(grid[i*w+j]-1)*w+k] &&
|
||||
|
Reference in New Issue
Block a user