summaryrefslogtreecommitdiff
path: root/engine/src/main.rs
blob: 187ff89a9a08a9591c5449e09fa8ce77aef18551 (plain)
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,
			}),
		},
	);
}