add proper cmd args for program
This commit is contained in:
parent
166c2d50f4
commit
9fa864e6eb
90
Cargo.lock
generated
90
Cargo.lock
generated
@ -38,12 +38,56 @@ version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.6"
|
||||
@ -114,6 +158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -122,8 +167,22 @@ version = "4.5.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -132,6 +191,12 @@ version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.15.11"
|
||||
@ -277,6 +342,12 @@ dependencies = [
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.5.0"
|
||||
@ -308,6 +379,12 @@ dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
@ -390,6 +467,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"allocative",
|
||||
"arrayvec",
|
||||
"clap",
|
||||
"console",
|
||||
"const-str",
|
||||
"const_for",
|
||||
@ -614,6 +692,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
@ -658,6 +742,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
|
@ -34,6 +34,7 @@ rand = "0.9"
|
||||
rayon = "1.10"
|
||||
skillratings = "0.27"
|
||||
static_assertions = "1.1"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.5", features = [ "html_reports" ] }
|
||||
|
64
src/main.rs
64
src/main.rs
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user