Skip to content

Commit 0b2370c

Browse files
committed
Fixed castling bug
1 parent 7956081 commit 0b2370c

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ Cargo.lock
1212

1313
# MSVC Windows builds of rustc generate these, which store debugging information
1414
*.pdb
15+
16+
sharpener/

src/board.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,27 @@ impl Board {
313313
self.color_bitboards[0] ^= 1;
314314
self.color_bitboards[0] ^= 1 << 3;
315315
}
316-
} else if data.from == 0
317-
|| data.to == 0 {
316+
}
317+
318+
if data.from == 0 {
318319
self.castling_rights.current &= !BLACK_CASTLE_LONG;
319-
} else if data.from == 7
320-
|| data.to == 7 {
320+
} else if data.from == 7 {
321321
self.castling_rights.current &= !BLACK_CASTLE_SHORT;
322-
} else if data.from == 56
323-
|| data.to == 56 {
322+
} else if data.from == 56 {
324323
self.castling_rights.current &= !WHITE_CASTLE_LONG;
325-
} else if data.from == 63
326-
|| data.to == 63 {
324+
} else if data.from == 63 {
327325
self.castling_rights.current &= !WHITE_CASTLE_SHORT;
328326
}
329327

328+
if data.to == 0 {
329+
self.castling_rights.current &= !BLACK_CASTLE_LONG;
330+
} else if data.to == 7 {
331+
self.castling_rights.current &= !BLACK_CASTLE_SHORT;
332+
} else if data.to == 56 {
333+
self.castling_rights.current &= !WHITE_CASTLE_LONG;
334+
} else if data.to == 63 {
335+
self.castling_rights.current &= !WHITE_CASTLE_SHORT;
336+
}
330337

331338
if data.capture == NO_PIECE as u8
332339
&& get_piece_type(data.piece as usize) != PAWN {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn main() {
9292
// UCI protocol
9393

9494
"uci" => {
95-
println!("id name Maxwell v3.0.8-1");
95+
println!("id name Maxwell v3.0.8-2");
9696
println!("id author eboatwright");
9797

9898
println!("uciok");

0 commit comments

Comments
 (0)