]> git.scottworley.com Git - pluta-lesnura/blame_incremental - src/main.rs
Use 1-based rank value for victory test
[pluta-lesnura] / src / main.rs
... / ...
CommitLineData
1use clap::{Parser, Subcommand};
2use pluta_lesnura::{play, random_player, Game, Player};
3
4#[derive(Parser)]
5#[command(author, version, about, long_about = None, arg_required_else_help = true)]
6struct Cli {
7 #[command(subcommand)]
8 command: Option<Commands>,
9}
10
11#[derive(Subcommand)]
12enum Commands {
13 /// Runs simulations
14 Sim {
15 /// How many players?
16 #[arg(short, long)]
17 num_players: usize,
18 },
19}
20
21fn main() -> Result<(), &'static str> {
22 let cli = Cli::parse();
23
24 match &cli.command {
25 Some(Commands::Sim { num_players }) => {
26 let players: Vec<_> = std::iter::from_fn(|| Some(Player::new(random_player)))
27 .take(*num_players)
28 .collect();
29 let mut game = Game::default();
30 for _ in 0..*num_players {
31 game.add_player();
32 }
33 let result = play(game, players)?;
34 println!("Result: {result:?}");
35 Ok(())
36 }
37 None => unreachable!(),
38 }
39}