use ncpig::prelude::*; use ncpig_testing::dots_and_boxes::*; use ncpig_testing::number_claim::*; use ncpig_testing::tic_tac_toe::*; #[test] fn two_player_number_claim() -> anyhow::Result<()> { let game: NumberClaim<2, 12> = NumberClaim::new(0..12)?; let mut state = NumberClaimState::default(); let search = Random::new(); while !game.is_complete(&state)? { let action = search.choose_action(&game, &state)?.unwrap(); state = game.do_action(&action, state)?; } for player in game.players() { println!("{}: {}", player, game.score(player, &state)?); } Ok(()) } #[test] fn three_player_number_claim() -> anyhow::Result<()> { let game: NumberClaim<3, 12> = NumberClaim::new(0..12)?; let mut state = NumberClaimState::default(); let search = Random::new(); while !game.is_complete(&state)? { let action = search.choose_action(&game, &state)?.unwrap(); state = game.do_action(&action, state)?; } for player in game.players() { println!("{}: {}", player, game.score(player, &state)?); } Ok(()) } #[test] fn tic_tac_toe() -> anyhow::Result<()> { let game = TicTacToe; let mut state = TicTacToeState::default(); let search = Random::new(); while !game.is_complete(&state)? { let action = search.choose_action(&game, &state)?.unwrap(); state = game.do_action(&action, state)?; } for player in game.players() { println!("{}: {}", player, game.score(player, &state)?); } Ok(()) } #[test] fn two_player_dots_and_boxes() -> anyhow::Result<()> { let game: DotsAndBoxes<2, 3, 2> = DotsAndBoxes::new([DotsAndBoxesPlayer::Red, DotsAndBoxesPlayer::Green]); let mut state = DotsAndBoxesState::default(); let search = Random::new(); while !game.is_complete(&state)? { let action = search.choose_action(&game, &state)?.unwrap(); state = game.do_action(&action, state)?; } for player in game.players() { println!("{}: {}", player, game.score(player, &state)?); } Ok(()) } #[test] fn three_player_dots_and_boxes() -> anyhow::Result<()> { let game: DotsAndBoxes<3, 3, 2> = DotsAndBoxes::new([ DotsAndBoxesPlayer::Red, DotsAndBoxesPlayer::Green, DotsAndBoxesPlayer::Blue, ]); let mut state = DotsAndBoxesState::default(); let search = Random::new(); while !game.is_complete(&state)? { let action = search.choose_action(&game, &state)?.unwrap(); state = game.do_action(&action, state)?; } for player in game.players() { println!("{}: {}", player, game.score(player, &state)?); } Ok(()) }