Skip to content

Commit

Permalink
chore: manually iterate over movelist in perft
Browse files Browse the repository at this point in the history
  • Loading branch information
raklaptudirm committed May 26, 2024
1 parent f93b1fb commit 144f073
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ataxx/src/perft.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Position;
use crate::{MoveStore, Position};

/// perft is a function to walk the move generation tree of strictly legal moves
/// to count all the leaf nodes of a certain depth.
Expand Down Expand Up @@ -26,7 +26,13 @@ pub fn perft<const SPLIT: bool, const BULK: bool>(position: Position, depth: u8)
let mut nodes: u64 = 0;
let movelist = position.generate_moves();

for m in movelist {
// MoveList implements IntoIterator, so it should be possible to use it
// directly in the for loop, but manual iterations seems to be faster.
for i in 0..movelist.len() {
let m = movelist.at(i);

// Find the next position without updating the Hash, which is unnecessary
// inside perft given uniquely identifying positions here is unnecessary.
let new_position = position.after_move::<false>(m);

// Spilt should always be disabled for child perft calls, and a child perft
Expand Down

0 comments on commit 144f073

Please sign in to comment.