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>
impl<'a> State<'a>
pub fn new(game: &'a Game) -> Self
pub fn possible_codes(self) -> Set
pub fn is_solved(self) -> bool
Sourcepub fn solution(self) -> Option<Code>
pub fn solution(self) -> Option<Code>
If solved, returns the solution. Otherwise, it returns None
.
Sourcepub fn after_move(
self,
move_to_do: Move,
) -> Result<(State<'a>, Option<AfterMoveInfo>), AfterMoveError>
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.
Sourcepub fn is_awaiting_result(&self) -> bool
pub fn is_awaiting_result(&self) -> bool
Returns true if the game is awaiting a verifier answer.
Sourcepub fn possible_moves(&self) -> impl Iterator<Item = Move> + '_
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.
Sourcepub fn find_best_move(self) -> (GameScore, Move)
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.