feat(spiel_bot): cli spiel_bot strategy

This commit is contained in:
Henri Bourcereau 2026-03-12 21:17:14 +01:00
parent e80dade303
commit b2d66ce41e
7 changed files with 281 additions and 4 deletions

View file

@ -3,7 +3,9 @@ name = "trictrac-client_cli"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "client_cli"
path = "src/main.rs"
[dependencies]
anyhow = "1.0.75"
@ -12,7 +14,8 @@ pico-args = "0.5.0"
pretty_assertions = "1.4.0"
renet = "0.0.13"
trictrac-store = { path = "../store" }
trictrac-bot = { path = "../bot" }
trictrac-bot = { path = "../bot" }
spiel_bot = { path = "../spiel_bot" }
itertools = "0.13.0"
env_logger = "0.11.6"
log = "0.4.20"

View file

@ -1,3 +1,4 @@
use spiel_bot::strategy::{AzBotStrategy, DqnSpielBotStrategy};
use trictrac_bot::{
BotStrategy, DefaultStrategy, DqnBurnStrategy, ErroneousStrategy, RandomStrategy,
StableBaselines3Strategy,
@ -56,6 +57,27 @@ impl App {
Some(Box::new(DqnBurnStrategy::new_with_model(&path.to_string()))
as Box<dyn BotStrategy>)
}
"az" => {
Some(Box::new(AzBotStrategy::new_mlp(None)) as Box<dyn BotStrategy>)
}
s if s.starts_with("az:") && !s.starts_with("az-") => {
let path = s.trim_start_matches("az:");
Some(Box::new(AzBotStrategy::new_mlp(Some(path))) as Box<dyn BotStrategy>)
}
"az-resnet" => {
Some(Box::new(AzBotStrategy::new_resnet(None)) as Box<dyn BotStrategy>)
}
s if s.starts_with("az-resnet:") => {
let path = s.trim_start_matches("az-resnet:");
Some(Box::new(AzBotStrategy::new_resnet(Some(path))) as Box<dyn BotStrategy>)
}
"az-dqn" => {
Some(Box::new(DqnSpielBotStrategy::new(None)) as Box<dyn BotStrategy>)
}
s if s.starts_with("az-dqn:") => {
let path = s.trim_start_matches("az-dqn:");
Some(Box::new(DqnSpielBotStrategy::new(Some(path))) as Box<dyn BotStrategy>)
}
_ => None,
})
.collect()

View file

@ -23,8 +23,14 @@ OPTIONS:
- dummy: Default strategy selecting the first valid move
- ai: AI strategy using the default model at models/trictrac_ppo.zip
- ai:/path/to/model.zip: AI strategy using a custom model
- dqn: DQN strategy using native Rust implementation with Burn
- dqn:/path/to/model: DQN strategy using a custom model
- dqnburn: DQN strategy (burn-rl backend)
- dqnburn:/path/to/model: DQN strategy (burn-rl backend) with custom model
- az: AlphaZero MlpNet (random weights)
- az:/path/to/model.mpk: AlphaZero MlpNet checkpoint
- az-resnet: AlphaZero ResNet (random weights)
- az-resnet:/path/to/model.mpk: AlphaZero ResNet checkpoint
- az-dqn: DQN QNet (random weights, first-legal-move fallback)
- az-dqn:/path/to/model.mpk: DQN QNet checkpoint
ARGS:
<INPUT>