summaryrefslogtreecommitdiff
path: root/engine/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/main.rs')
-rwxr-xr-x[-rw-r--r--]engine/src/main.rs141
1 files changed, 83 insertions, 58 deletions
diff --git a/engine/src/main.rs b/engine/src/main.rs
index d4bcc48..187ff89 100644..100755
--- a/engine/src/main.rs
+++ b/engine/src/main.rs
@@ -1,58 +1,83 @@
-use std::num::NonZeroU8;
-
-use engine::{ActualLimit, Engine, EvaluationSettings, Frontend};
-use mimalloc::MiMalloc;
-use model::CheckersBitBoard;
-
-#[global_allocator]
-static ALLOCATOR: MiMalloc = MiMalloc;
-
-const DEPTH: u8 = 19;
-
-struct BasicFrontend;
-
-impl Frontend for BasicFrontend {
- fn debug(&self, msg: &str) {
- println!("{msg}");
- }
-
- fn report_best_move(&self, best_move: model::Move) {
- println!("{best_move}");
- }
-}
-
-fn main() {
- let engine = Box::leak(Box::new(Engine::new(1_000_000, &BasicFrontend)));
- let (_, best) = engine.evaluate(
- None,
- EvaluationSettings {
- restrict_moves: None,
- ponder: false,
- clock: engine::Clock::Unlimited,
- search_until: engine::SearchLimit::Limited(ActualLimit {
- nodes: None,
- depth: Some(NonZeroU8::new(DEPTH).unwrap()),
- time: None,
- }),
- },
- );
- engine.set_position(CheckersBitBoard::new(
- 4294967295,
- 2206409603,
- 3005432691,
- model::PieceColor::Light,
- ));
- engine.evaluate(
- None,
- EvaluationSettings {
- restrict_moves: None,
- ponder: false,
- clock: engine::Clock::Unlimited,
- search_until: engine::SearchLimit::Limited(ActualLimit {
- nodes: None,
- depth: Some(NonZeroU8::new(DEPTH).unwrap()),
- time: None,
- }),
- },
- );
-}
+use std::{num::NonZeroU8, time::Instant};
+
+use engine::{ActualLimit, Engine, EvalInfo, EvaluationSettings, Frontend};
+use mimalloc::MiMalloc;
+use model::CheckersBitBoard;
+
+#[global_allocator]
+static ALLOCATOR: MiMalloc = MiMalloc;
+
+const DEPTH: u8 = 19;
+
+struct BasicFrontend;
+
+impl Frontend for BasicFrontend {
+ fn debug(&self, msg: &str) {
+ println!("{msg}");
+ }
+
+ fn info(&self, _info: EvalInfo) {}
+
+ fn report_best_move(&self, best_move: model::Move) {
+ println!("{best_move}");
+ }
+}
+
+fn main() {
+ let engine = Box::leak(Box::new(Engine::new(1_000_000, &BasicFrontend)));
+ let start = Instant::now();
+ engine.evaluate(
+ None,
+ EvaluationSettings {
+ restrict_moves: None,
+ ponder: false,
+ clock: engine::Clock::Unlimited,
+ search_until: engine::SearchLimit::Limited(ActualLimit {
+ nodes: None,
+ depth: Some(NonZeroU8::new(DEPTH).unwrap()),
+ time: None,
+ }),
+ },
+ );
+ println!("{} ms", start.elapsed().as_millis());
+ engine.set_position(CheckersBitBoard::new(
+ 4294967295,
+ 2206409603,
+ 3005432691,
+ model::PieceColor::Light,
+ ));
+ engine.evaluate(
+ None,
+ EvaluationSettings {
+ restrict_moves: None,
+ ponder: false,
+ clock: engine::Clock::Unlimited,
+ search_until: engine::SearchLimit::Limited(ActualLimit {
+ nodes: None,
+ depth: Some(NonZeroU8::new(DEPTH).unwrap()),
+ time: None,
+ }),
+ },
+ );
+ // TODO test FEN W:W19,20,21,24,25,26,27,28,29,30,32:B1,2,4,6,7,8,9,11,12,15,17,18
+ println!("test");
+ engine.set_position(CheckersBitBoard::new(
+ 3615436253,
+ 75309505,
+ 0,
+ model::PieceColor::Light,
+ ));
+ engine.evaluate(
+ None,
+ EvaluationSettings {
+ restrict_moves: None,
+ ponder: false,
+ clock: engine::Clock::Unlimited,
+ search_until: engine::SearchLimit::Limited(ActualLimit {
+ nodes: None,
+ depth: Some(NonZeroU8::new(DEPTH).unwrap()),
+ time: None,
+ }),
+ },
+ );
+}