turing-machine-ai 0.1.0

Tools and an AI for the Turing Machine board game
Documentation
  • Coverage
  • 58.82%
    50 out of 85 items documented13 out of 67 items with examples
  • Size
  • Source code size: 82.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 7.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ThomasdenH/turing-machine-ai
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ThomasdenH

Turing Machine AI

An AI for the Turing Machine board game!

Currently, you can

  • Easily construct games from its verifiers.
  • Do all deductions: find all possible verifier combinations and codes
  • Find the best sequence of moves that will get you to the solution the quickest.

Example

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(())
}

License

Licensed under either of

at your option.

Contribution

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.