summaryrefslogtreecommitdiff
path: root/cli/src/perft.rs
diff options
context:
space:
mode:
authormrw1593 <botahamec@outlook.com>2021-07-13 17:54:25 -0400
committermrw1593 <botahamec@outlook.com>2021-07-13 17:54:25 -0400
commitbf9e9af7f45433def26d2d2094a04798cb0282c0 (patch)
tree786e145253a329c4da28edc94eae68b719b6d45d /cli/src/perft.rs
parentd2b28aa31a84f43bf5c4f375357e0f013337cdaf (diff)
Updated docs and tests
Diffstat (limited to 'cli/src/perft.rs')
-rw-r--r--cli/src/perft.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/cli/src/perft.rs b/cli/src/perft.rs
index eba640e..535aec0 100644
--- a/cli/src/perft.rs
+++ b/cli/src/perft.rs
@@ -1,26 +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
- }
-}
+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
+ }
+}