diff --git a/position/src/perft.rs b/position/src/perft.rs index a9ae169..97b3c51 100644 --- a/position/src/perft.rs +++ b/position/src/perft.rs @@ -18,14 +18,18 @@ impl Position { let legal_moves: Vec = self.all_legal_moves(None).collect(); - for ply in legal_moves { - let ply = ply.ply(); + for generated_ply in legal_moves { + let ply = generated_ply.ply(); - let _has_seen_position = self + let has_seen_position = self .make_move(ply, ValidateMove::No) .expect("unable to make generated move"); - let nodes_counted = self.perft_recursive(depth - 1, depth); + let nodes_counted = if has_seen_position { + 1 + } else { + self.perft_recursive(depth - 1, max_depth) + }; total_nodes_counted += nodes_counted;