[perft] Add back the block on searching into seen positions

Check if the board position has been seen and stop recursion if so.
This commit is contained in:
Eryn Wells 2025-06-18 08:22:12 -07:00
parent bf17017694
commit c5cc0646ef

View file

@ -18,14 +18,18 @@ impl Position {
let legal_moves: Vec<GeneratedMove> = 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;