Puzzle

Trait Puzzle 

Source
pub trait Puzzle: Clone {
    type Pos: Copy + Debug;
    type Val: Copy + Debug + PartialEq;

    // Required methods
    fn set(&mut self, pos: Self::Pos, val: Self::Val);
    fn get(&self, pos: Self::Pos) -> Self::Val;
    fn print(&self);
    fn is_solved(&self) -> bool;
    fn remove(&mut self, other: &Self);

    // Provided method
    fn solve_simple<F>(&mut self, _f: F)
       where F: FnMut(&mut Self, Self::Pos, Self::Val) { ... }
}
Expand description

Implemented by puzzles.

A puzzle stores the state of the problem, and can be modified by inserting a value at a position within the puzzle. The solver does not understand the internal structure of the puzzle, but is still able to find a solution (if any exists).

The initial state does not have to empty, and you can get the difference at the end by setting SolveSettings::difference(true).

Required Associated Types§

Source

type Pos: Copy + Debug

The type of position.

Source

type Val: Copy + Debug + PartialEq

The type of values stored in the puzzle.

Required Methods§

Source

fn set(&mut self, pos: Self::Pos, val: Self::Val)

Sets a value at position.

Source

fn get(&self, pos: Self::Pos) -> Self::Val

Gets value at position.

Source

fn print(&self)

Print puzzle out to standard output.

Source

fn is_solved(&self) -> bool

Whether puzzle is solved.

Source

fn remove(&mut self, other: &Self)

Removes values from other puzzle to show changes.

Provided Methods§

Source

fn solve_simple<F>(&mut self, _f: F)
where F: FnMut(&mut Self, Self::Pos, Self::Val),

Solve simple stuff faster. This will reduce the number of steps in solution. If you do not know how to solve this, leave it empty.

Call the closure when making a simple choice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§