Permalink
Browse files

Fix castling under check from certain knight positions (github bug #3)

Another one found by Ivan Yelizariev.  The patch is faily self
explanitary: the check for the knight on the third row to the left was
neglected while the knight to the right was checked twice.
  • Loading branch information...
1 parent b32c794 commit 7a3b428bb9883ef5e8c1666510d1042cd8650029 @douglasbagnall committed Apr 2, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −1 src/engine.js
  2. +2 −1 src/fen-test.js
View
@@ -454,7 +454,7 @@ function p4_check_castling(board, s, colour, dir, side){
if (board[p + dir - 2] == knight ||
board[p + dir + 2] == knight ||
board[p + 2 * dir + 1] == knight ||
- board[p + 2 * dir + 1] == knight)
+ board[p + 2 * dir - 1] == knight)
return 0;
}
View
@@ -6,7 +6,8 @@ var FEN = [
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 1 1", //beginning
"rn1qkbnr/p1p1pppp/8/1pPp4/3P1B2/8/PP2PPPP/Rb1QKBNR w KQkq b6 0 5",//en passant
"rnbqkbnr/pppppppp/nnnnnnnn/PPPPPPPP/pppppppp/NNNNNNNN/PPPPPPPP/RNBQKBNR w KQkq - 1 1", //excessive
- "8/p2p1N2/8/4p2k/1p2P1Pp/1P1b3K/P6P/n7 b - g3 0 32"
+ "8/p2p1N2/8/4p2k/1p2P1Pp/1P1b3K/P6P/n7 b - g3 0 32",
+ "rnb1r1k1/ppp2ppp/8/8/2PN4/2Nn4/P3BPPP/R3K2R w KQ - 5 14"
];

0 comments on commit 7a3b428

Please sign in to comment.