<commit_before><commit_msg>add perft test<commit_after>#[cfg(test)]
fn perft(position: &mut Position, depth: usize) -> usize {
  if depth == 0 {
    let mut counter = MoveCounter::new();
    legal_moves(&position, &mut counter);
    return counter.moves as usize;
  }

  let mut moves = MoveVec::new();
  legal_moves(&position, &mut moves);

  let state = position.state().clone();
  let key = position.hash_key();
  let mut count = 0;
  for &mv in moves.iter() {
    let capture = position.make(mv);

    count += perft(position, depth - 1);

    position.unmake(mv, capture, &state, key);
  }

  count
}

#[test]
fn perft_test() {
  let mut position = Position::from_fen(STARTING_POSITION_FEN).unwrap();

  assert_eq!(perft(&mut position, 3), 197281);
}

#[bench]
fn perft_bench_starting_position(b: &mut test::Bencher) {
  let mut position = Position::from_fen(STARTING_POSITION_FEN).unwrap();

  b.iter(|| -> usize { perft(&mut position, 2) });
}
{'fraction_non_alphanumeric': 0.15894736842105264, 'fraction_numerical': 0.011578947368421053, 'mean_word_length': 4.254143646408839, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1297781', 'n_tokens_mistral': 342, 'n_tokens_neox': 333, 'n_words': 82}