mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
`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]
This commit is contained in:
@ -200,14 +200,15 @@ char *new_game_seed(game_params *params)
|
|||||||
* This is the XOR of:
|
* This is the XOR of:
|
||||||
*
|
*
|
||||||
* - The chessboard parity ((x^y)&1) of the gap square. The
|
* - The chessboard parity ((x^y)&1) of the gap square. The
|
||||||
* bottom right, and therefore also the top left, count as
|
* bottom right counts as even.
|
||||||
* even.
|
|
||||||
*
|
*
|
||||||
* - The parity of n. (The target permutation is 1,...,n-1,0
|
* - The parity of n. (The target permutation is 1,...,n-1,0
|
||||||
* rather than 0,...,n-1; this is a cyclic permutation of
|
* rather than 0,...,n-1; this is a cyclic permutation of
|
||||||
* the starting point and hence is odd iff n is even.)
|
* 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
|
* Try the last two tiles one way round. If that fails, swap
|
||||||
|
Reference in New Issue
Block a user