aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-05-03 07:56:23 +0000
committerSimon Tatham <anakin@pobox.com>2004-05-03 07:56:23 +0000
commiteb88ee0973c9a19b14e2e0e1579ee17625d73e05 (patch)
treea592349f7fddd85363a033386e94670d8777ef59
parente8f6124996faf0a48a6748532153f5f364992b06 (diff)
downloadpuzzles-eb88ee0973c9a19b14e2e0e1579ee17625d73e05.zip
puzzles-eb88ee0973c9a19b14e2e0e1579ee17625d73e05.tar.gz
puzzles-eb88ee0973c9a19b14e2e0e1579ee17625d73e05.tar.bz2
puzzles-eb88ee0973c9a19b14e2e0e1579ee17625d73e05.tar.xz
`Fifteen' was getting the parity wrong on any size of board where
the top left and bottom right corners didn't have the same chessboard colour. [originally from svn r4185]
-rw-r--r--fifteen.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fifteen.c b/fifteen.c
index 7f6769a..04a8f75 100644
--- a/fifteen.c
+++ b/fifteen.c
@@ -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