//! Use the [`MaxN`] algorithm for all players in a 3-player dots & boxes game. use ncpig::prelude::*; use ncpig_testing::dots_and_boxes::*; fn main() -> anyhow::Result<()> { env_logger::init(); let game: DotsAndBoxes<3, 5, 5> = DotsAndBoxes::new([ DotsAndBoxesPlayer::Red, DotsAndBoxesPlayer::Blue, DotsAndBoxesPlayer::Green, ]); let mut state = DotsAndBoxesState::default(); let search = MaxN::builder().pruning(game.n_boxes()).max_depth(3).build(); while !game.is_complete(&state)? { log::info!("choosing action for {}", game.active_player(&state)?); let action = search.choose_action(&game, &state)?.unwrap(); state = game.do_action(&action, state)?; println!("{}\n", state); } for player in game.players() { println!("{player}: {}", game.score(player, &state)?) } Ok(()) }