aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/board.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/board.rs b/src/board.rs
index 659f447..eea60fe 100644
--- a/src/board.rs
+++ b/src/board.rs
@@ -383,7 +383,7 @@ impl Board {
}
let mut total = 0;
- let mut tactical = 0;
+ let mut captures = 0;
let mut checks = 0;
let mut en_passants = 0;
@@ -392,26 +392,29 @@ impl Board {
let captured_piece = self.make_move(mov);
// King can not be in check after our own move
if !self.is_king_in_check(color) {
- match mov.kind {
- MoveKind::Capture => {
- tactical += 1;
+ if depth == 1 {
+ match mov.kind {
+ MoveKind::Capture => {
+ captures += 1;
+ }
+ MoveKind::EnPassant => {
+ en_passants += 1;
+ captures += 1;
+ }
+ _ => {}
}
- MoveKind::EnPassant => {
- en_passants += 1;
+ if self.is_king_in_check(color.flip()) {
+ checks += 1;
}
- _ => {}
}
- if self.is_king_in_check(color.flip()) {
- checks += 1;
- }
if print {
println!("{:?}", mov);
self.print();
}
let (children_total, children_tactical, children_checks, children_ep) = self.perft(depth - 1, print);
total += children_total;
- tactical += children_tactical;
+ captures += children_tactical;
checks += children_checks;
en_passants += children_ep;
@@ -423,7 +426,7 @@ impl Board {
println!("Found {} nodes in this subtree (depth {})", total, depth);
}
- (total, tactical, checks, en_passants)
+ (total, captures, checks, en_passants)
}
fn is_square_attacked(&self, square: Square, attacker_color: Color) -> bool {
@@ -611,7 +614,8 @@ mod tests {
assert_eq!(board.perft(2, false), (400, 0, 0, 0));
assert_eq!(board.perft(3, false), (8902, 34, 12, 0));
assert_eq!(board.perft(4, false), (197281, 1576, 469, 0));
- // assert_eq!(board.perft(5, false), (4865609, 82719, 27351));
+ // assert_eq!(board.perft(5, false), (4865609, 82719, 27351, 258));
+ // assert_eq!(board.perft(6, false), (119060324 , 2812008, 809099 , 5248));
}
#[test]