pub struct BoardGenerator { /* private fields */ }Expand description
A builder for generating Sudoku puzzles with various constraints and properties.
BoardGenerator provides a unified interface for creating puzzles with specific
clue counts, symmetry types, and difficulty levels.
§Example
use rustoku_lib::{BoardGenerator, Symmetry};
let board = BoardGenerator::new()
.clues(25)
.symmetry(Symmetry::Rotational180)
.generate();
assert!(board.is_ok());Implementations§
Source§impl BoardGenerator
impl BoardGenerator
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new BoardGenerator with default settings (30 clues, no symmetry).
Sourcepub fn clues(self, num_clues: usize) -> Self
pub fn clues(self, num_clues: usize) -> Self
Sets the target number of clues for the generated puzzle.
Sourcepub fn symmetry(self, symmetry: Symmetry) -> Self
pub fn symmetry(self, symmetry: Symmetry) -> Self
Sets the type of symmetry to apply to the generated puzzle.
Sourcepub fn difficulty(self, difficulty: Difficulty) -> Self
pub fn difficulty(self, difficulty: Difficulty) -> Self
Sets the target difficulty for the generated puzzle.
If a difficulty is set, the generator will attempt to find a puzzle of that exact difficulty by repeatedly generating candidates.
Sourcepub fn max_attempts(self, max_attempts: usize) -> Self
pub fn max_attempts(self, max_attempts: usize) -> Self
Sets the maximum number of attempts when generating a puzzle with a specific difficulty.
Sourcepub fn generate(&self) -> Result<Board, RustokuError>
pub fn generate(&self) -> Result<Board, RustokuError>
Generates a new Sudoku puzzle based on the current configuration.
Trait Implementations§
Source§impl Clone for BoardGenerator
impl Clone for BoardGenerator
Source§fn clone(&self) -> BoardGenerator
fn clone(&self) -> BoardGenerator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoardGenerator
impl Debug for BoardGenerator
Source§impl Default for BoardGenerator
impl Default for BoardGenerator
impl Copy for BoardGenerator
Auto Trait Implementations§
impl Freeze for BoardGenerator
impl RefUnwindSafe for BoardGenerator
impl Send for BoardGenerator
impl Sync for BoardGenerator
impl Unpin for BoardGenerator
impl UnsafeUnpin for BoardGenerator
impl UnwindSafe for BoardGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more