From 1b379403ab971e188483df5d580c39695db7f44a Mon Sep 17 00:00:00 2001 From: Micha White Date: Wed, 27 Sep 2023 09:35:50 -0400 Subject: Big changes --- cli/src/eval.rs | 8 ------ cli/src/main.rs | 86 -------------------------------------------------------- cli/src/perft.rs | 26 ----------------- 3 files changed, 120 deletions(-) delete mode 100644 cli/src/eval.rs delete mode 100644 cli/src/main.rs delete mode 100644 cli/src/perft.rs (limited to 'cli/src') diff --git a/cli/src/eval.rs b/cli/src/eval.rs deleted file mode 100644 index 8076af1..0000000 --- a/cli/src/eval.rs +++ /dev/null @@ -1,8 +0,0 @@ -use ai::{CheckersBitBoard, Move}; -pub fn eval(depth: usize) -> f32 { - ai::eval_multithreaded(depth, 0.0, 1.0, CheckersBitBoard::starting_position()) -} - -pub fn best_move(depth: usize) -> Move { - ai::best_move(depth, CheckersBitBoard::starting_position()) -} diff --git a/cli/src/main.rs b/cli/src/main.rs deleted file mode 100644 index d230398..0000000 --- a/cli/src/main.rs +++ /dev/null @@ -1,86 +0,0 @@ -use ai::CheckersBitBoard; -use clap::{App, Arg, SubCommand}; - -mod eval; -mod perft; - -fn main() { - let matches = App::new("Ampere") - .version("0.1") - .author("Botahamec ") - .about("An American Checkers AI") - .subcommand( - SubCommand::with_name("perft") - .about("Calculate the number of possible moves") - .arg( - Arg::with_name("depth") - .required(true) - .short("d") - .takes_value(true) - .help("The depth to go to"), - ), - ) - .subcommand( - SubCommand::with_name("eval") - .about("Calculate the advantage") - .arg( - Arg::with_name("depth") - .required(true) - .short("d") - .takes_value(true) - .help("The depth to go to"), - ), - ) - .subcommand( - SubCommand::with_name("best") - .about("Calculate the best move") - .arg( - Arg::with_name("depth") - .required(true) - .short("d") - .takes_value(true) - .help("The depth to go to"), - ), - ) - .get_matches(); - - if let Some(matches) = matches.subcommand_matches("perft") { - println!( - "{}", - perft::positions( - CheckersBitBoard::starting_position(), - matches - .value_of("depth") - .unwrap() - .parse::() - .expect("Error: not a valid number") - ) - ); - } - - if let Some(matches) = matches.subcommand_matches("eval") { - println!( - "{}", - eval::eval( - matches - .value_of("depth") - .unwrap() - .parse::() - .expect("Error: not a valid number") - ) - ); - } - - if let Some(matches) = matches.subcommand_matches("best") { - println!( - "{}", - eval::best_move( - matches - .value_of("depth") - .unwrap() - .parse() - .expect("Error: not a valid number") - ) - ) - } -} diff --git a/cli/src/perft.rs b/cli/src/perft.rs deleted file mode 100644 index 535aec0..0000000 --- a/cli/src/perft.rs +++ /dev/null @@ -1,26 +0,0 @@ -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