add proper cmd args for program

This commit is contained in:
2025-04-06 15:30:58 -04:00
parent 166c2d50f4
commit 9fa864e6eb
3 changed files with 134 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
use clap::Parser;
use game::Game;
use logic::FutureMoveConfig;
use repr::Piece;
@@ -8,29 +9,50 @@ mod complexagent;
mod elo;
mod game;
mod game_inner;
mod logic;
pub mod logic;
pub mod repr;
// TODO! make this agent configuration a config option via `clap-rs`
// or maybe even like a TUI menu?
fn main() {
// elo::run();
// return;
let player1 = complexagent::ComplexAgent::new(
Piece::Black,
FutureMoveConfig {
max_depth: 20,
min_arena_depth: 14,
top_k_children: 2,
up_to_minus: 10,
max_arena_size: 100_000_000,
do_prune: true,
print: true,
children_eval_method: Default::default(),
},
);
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Agent for Black (c=complex, m=manual, r=random) [default: c]
#[arg(short = 'b', long = "black", default_value = "c", value_parser = ["c", "m", "r"])]
black_agent: String,
let player2 = agent::ManualAgent::new(Piece::White);
let mut game = Game::new(Box::new(player1), Box::new(player2));
/// Agent for White (c=complex, m=manual, r=random) [default: m]
#[arg(short = 'w', long = "white", default_value = "m", value_parser = ["c", "m", "r"])]
white_agent: String,
}
fn main() {
let args = Args::parse();
let future_config = FutureMoveConfig {
max_depth: 20,
min_arena_depth: 14,
top_k_children: 2,
up_to_minus: 10,
max_arena_size: 100_000_000,
do_prune: true,
print: true,
children_eval_method: Default::default(),
};
// Create agents
let black_agent: Box<dyn agent::Agent> = match args.black_agent.as_str() {
"c" => Box::new(complexagent::ComplexAgent::new(Piece::Black, future_config)),
"m" => Box::new(agent::ManualAgent::new(Piece::Black)),
"r" => Box::new(agent::RandomAgent::new(Piece::Black)),
_ => panic!("Invalid agent type for Black - use c/m/r"),
};
let white_agent: Box<dyn agent::Agent> = match args.white_agent.as_str() {
"c" => Box::new(complexagent::ComplexAgent::new(Piece::White, future_config)),
"m" => Box::new(agent::ManualAgent::new(Piece::White)),
"r" => Box::new(agent::RandomAgent::new(Piece::White)),
_ => panic!("Invalid agent type for White - use c/m/r"),
};
let mut game = Game::new(black_agent, white_agent);
game.game_loop();
}