Crates.io | turing-machine-ai |
lib.rs | turing-machine-ai |
version | 0.1.0 |
source | src |
created_at | 2023-08-19 07:16:29.132576 |
updated_at | 2023-08-19 07:16:29.132576 |
description | Tools and an AI for the Turing Machine board game |
homepage | |
repository | https://github.com/ThomasdenH/turing-machine-ai |
max_upload_size | |
id | 948528 |
size | 82,514 |
An AI for the Turing Machine board game!
Currently, you can
The following example solves the first game in the booklet:
use std::error::Error;
use turing_machine_ai::{
game::Game,
code::Code,
gametree::{Move, State, AfterMoveError, VerifierSolution::*}
};
/// Solve the first puzzle from the booklet.
fn main() -> Result<(), Box<dyn Error>> {
let game = Game::new_from_verifier_numbers([4, 9, 11, 14].iter().copied());
let state = State::new(&game);
let (game_score, next_move) = state.find_best_move();
assert_eq!(game_score.codes_guessed, 1);
assert_eq!(game_score.verifiers_checked, 1);
assert_eq!(next_move, Move::ChooseNewCode(Code::from_digits(1, 1, 1)?));
let (state, _) = state.after_move(next_move)?;
let (game_score, next_move) = state.find_best_move();
assert_eq!(game_score.codes_guessed, 1);
assert_eq!(game_score.verifiers_checked, 1);
assert_eq!(next_move, Move::ChooseVerifier(0.into()));
let (state, _) = state.after_move(next_move)?;
assert!(state.is_awaiting_result());
let (state, _) = state.after_move(Move::VerifierSolution(Cross))?;
assert!(state.is_solved());
assert_eq!(state.solution(), Some(Code::from_digits(2, 4, 1)?));
Ok(())
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.