X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/c823052456548bc19a37e35a0bfae944004ef049..d3a026ed4258c207b6309802cc2c92eb0a812aac:/fifteen.c diff --git a/fifteen.c b/fifteen.c index f7bcc68..04a8f75 100644 --- a/fifteen.c +++ b/fifteen.c @@ -80,19 +80,19 @@ config_item *game_configure(game_params *params) ret = snewn(3, config_item); ret[0].name = "Width"; - ret[0].type = STRING; + ret[0].type = C_STRING; sprintf(buf, "%d", params->w); ret[0].sval = dupstr(buf); ret[0].ival = 0; ret[1].name = "Height"; - ret[1].type = STRING; + ret[1].type = C_STRING; sprintf(buf, "%d", params->h); ret[1].sval = dupstr(buf); ret[1].ival = 0; ret[2].name = NULL; - ret[2].type = ENDCFG; + ret[2].type = C_END; ret[2].sval = NULL; ret[2].ival = 0; @@ -199,15 +199,16 @@ char *new_game_seed(game_params *params) * Determine the required parity of the overall permutation. * This is the XOR of: * - * - The chessboard parity ((x^y)&1) of the gap square. The - * bottom right, and therefore also the top left, count as - * even. + * - The chessboard parity ((x^y)&1) of the gap square. The + * bottom right counts as even. * * - The parity of n. (The target permutation is 1,...,n-1,0 * rather than 0,...,n-1; this is a cyclic permutation of * the starting point and hence is odd iff n is even.) */ - parity = (X(params, gap) ^ Y(params, gap) ^ (n+1)) & 1; + parity = ((X(params, gap) - (params->w-1)) ^ + (Y(params, gap) - (params->h-1)) ^ + (n+1)) & 1; /* * Try the last two tiles one way round. If that fails, swap