From 7e73782a7d51b40a558b74793c1d6c1abdea857d Mon Sep 17 00:00:00 2001 From: Botahamec Date: Thu, 8 Jul 2021 20:32:44 -0400 Subject: here's what i have so far --- cli/src/perft.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cli/src/perft.rs (limited to 'cli/src/perft.rs') diff --git a/cli/src/perft.rs b/cli/src/perft.rs new file mode 100644 index 0000000..eba640e --- /dev/null +++ b/cli/src/perft.rs @@ -0,0 +1,26 @@ +use ai::{CheckersBitBoard, Move, PossibleMoves}; +use rayon::prelude::*; +use std::fmt::{Display, Formatter}; + +#[derive(Clone)] +struct PerftResult { + result: Vec<(Move, usize)>, +} + +pub fn positions(board: CheckersBitBoard, depth: usize) -> usize { + let moves = PossibleMoves::moves(board); + + if depth == 0 { + 1 + } else { + let mut total = 0; + + for current_move in moves { + // safety: we got this move out of the list of possible moves, so it's definitely valid + let board = unsafe { current_move.apply_to(board) }; + total += positions(board, depth - 1); + } + + total + } +} -- cgit v1.2.3