aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml4
-rw-r--r--benches/perft.rs11
-rw-r--r--src/board.rs2
-rw-r--r--src/lib.rs5
-rw-r--r--src/main.rs6
5 files changed, 21 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index f47bb6e..59aa9d6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,3 +7,7 @@ edition = "2021"
[dependencies]
num_enum = "0.5.7"
+
+[[bench]]
+name = "perft"
+harness = false
diff --git a/benches/perft.rs b/benches/perft.rs
new file mode 100644
index 0000000..c73208f
--- /dev/null
+++ b/benches/perft.rs
@@ -0,0 +1,11 @@
+use std::time::Instant;
+use chessnost::board::Board;
+
+fn main() {
+ let fen = String::from("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - ");
+ let mut board = Board::from_FEN(fen);
+
+ let start = Instant::now();
+ let result = board.perft(5, false);
+ println!("Perft finished in {:?}: {:?}", start.elapsed(), result);
+}
diff --git a/src/board.rs b/src/board.rs
index 3343702..9ff81b1 100644
--- a/src/board.rs
+++ b/src/board.rs
@@ -501,7 +501,7 @@ impl Board {
self.ply -= 1;
}
- fn perft(&mut self, depth: u8, print: bool) -> (u64, u64, u64, u64, u64) {
+ pub fn perft(&mut self, depth: u8, print: bool) -> (u64, u64, u64, u64, u64) {
if depth == 0 {
return (1, 0, 0, 0, 0) // This a leaf, exactly one node
}
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..2eaef2b
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,5 @@
+pub mod square;
+pub mod bitboard;
+pub mod board;
+pub mod attacks;
+pub mod moves;
diff --git a/src/main.rs b/src/main.rs
index 9a38593..e7a11a9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,3 @@
-mod square;
-mod bitboard;
-mod board;
-mod attacks;
-mod moves;
-
fn main() {
println!("Hello, world!");
}