Struct State

Source
pub struct State<'a> { /* private fields */ }
Expand description

A struct representing the current game state. It contains the possible solutions for the verifier selection, the currently selected code (if any), the currently selected verifier (if any), whether a verifier was tested, as well as how many tests were performed.

Implementations§

Source§

impl<'a> State<'a>

Source

pub fn new(game: &'a Game) -> Self

Source

pub fn possible_codes(self) -> Set

Source

pub fn is_solved(self) -> bool

Source

pub fn solution(self) -> Option<Code>

If solved, returns the solution. Otherwise, it returns None.

Source

pub fn after_move( self, move_to_do: Move, ) -> Result<(State<'a>, Option<AfterMoveInfo>), AfterMoveError>

Return the state after performing the given move. If the given move is invalid, this function returns an error. In addition to the state itself, this function will sometimes provide additional information about the transition as the second argument of the tuple.

Source

pub fn is_awaiting_result(&self) -> bool

Returns true if the game is awaiting a verifier answer.

Source

pub fn possible_moves(&self) -> impl Iterator<Item = Move> + '_

Return all possible moves. Notably these are not verified in every way:

  • Verifiers may return impossible results, leading to no solution.
  • Codes or verifiers may be chosen that do not provide information to the player.
Source

pub fn find_best_move(self) -> (GameScore, Move)

Find the best possible move to minimize the maximum amount of codes and verifier checks needed. The game must be at a state where the player chooses a code or a verifier.

§Panics

This function will panic if the state is currently awaiting a verifier answer or if the game has already been solved.

Trait Implementations§

Source§

impl<'a> Clone for State<'a>

Source§

fn clone(&self) -> State<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for State<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Copy for State<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for State<'a>

§

impl<'a> RefUnwindSafe for State<'a>

§

impl<'a> Send for State<'a>

§

impl<'a> Sync for State<'a>

§

impl<'a> Unpin for State<'a>

§

impl<'a> UnwindSafe for State<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.