Scanning the rank (as is done because of FRC) assigned castling rights
to the rightmost King. Even scanning the opposite direction would not
work, as it is not always the eftmost King that can castle. So we now
explicitly test for a King on e1/e8 in TwoKings and assign it rights,
relying on the Rook rights received from the ICS to control castling.
for(k=BOARD_LEFT; k<BOARD_RGHT; k++)
if(board[BOARD_HEIGHT-1][k] == bKing)
initialRights[5] = boards[moveNum][CASTLING][5] = k;
+ if(gameInfo.variant == VariantTwoKings) {
+ // In TwoKings looking for a King does not work, so always give castling rights to a King on e1/e8
+ if(board[0][4] == wKing) initialRights[2] = boards[moveNum][CASTLING][2] = 4;
+ if(board[BOARD_HEIGHT-1][4] == bKing) initialRights[5] = boards[moveNum][CASTLING][5] = 4;
+ }
} else { int r;
r = boards[moveNum][CASTLING][0] = initialRights[0];
if(board[0][r] != WhiteRook) boards[moveNum][CASTLING][0] = NoRights;