summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/src/eval.rs6
-rw-r--r--cli/src/main.rs24
2 files changed, 29 insertions, 1 deletions
diff --git a/cli/src/eval.rs b/cli/src/eval.rs
index d078c5f..72fa32a 100644
--- a/cli/src/eval.rs
+++ b/cli/src/eval.rs
@@ -1,4 +1,8 @@
-use ai::CheckersBitBoard;
+use ai::{CheckersBitBoard, Move};
pub fn eval(depth: usize) -> f32 {
ai::eval(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
index a550092..d230398 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -31,6 +31,17 @@ fn main() {
.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") {
@@ -59,4 +70,17 @@ fn main() {
)
);
}
+
+ if let Some(matches) = matches.subcommand_matches("best") {
+ println!(
+ "{}",
+ eval::best_move(
+ matches
+ .value_of("depth")
+ .unwrap()
+ .parse()
+ .expect("Error: not a valid number")
+ )
+ )
+ }
}