pub struct Generator<C: CoordinateSystem, G: Grid<C>> { /* private fields */ }
Expand description
Model synthesis/WFC generator.
Use a GeneratorBuilder
to get an instance of a Generator
.
Implementations§
Source§impl<C: CoordinateSystem, G: Grid<C>> Generator<C, G>
impl<C: CoordinateSystem, G: Grid<C>> Generator<C, G>
Sourcepub fn builder() -> GeneratorBuilder<Unset, Unset, C, G>
pub fn builder() -> GeneratorBuilder<Unset, Unset, C, G>
Returns a new GeneratorBuilder
Sourcepub fn max_retry_count(&self) -> u32
pub fn max_retry_count(&self) -> u32
Sourcepub fn set_max_retry_count(&mut self, max_retry_count: u32)
pub fn set_max_retry_count(&mut self, max_retry_count: u32)
Sourcepub fn seed(&self) -> u64
pub fn seed(&self) -> u64
Returns the seed that was used to initialize the generator RNG for this generation. See RngMode
for more information.
Sourcepub fn nodes_left(&self) -> usize
pub fn nodes_left(&self) -> usize
Returns how many nodes are left to generate
Sourcepub fn to_grid_data(&self) -> Option<GridData<C, ModelInstance, G>>
pub fn to_grid_data(&self) -> Option<GridData<C, ModelInstance, G>>
Returns a GridData
of ModelInstance
with all the nodes generated if the generation is done
Returns None
if the generation is still ongoing or currently failed
Sourcepub fn generate_grid(
&mut self,
) -> Result<(GenInfo, GridData<C, ModelInstance, G>), GeneratorError>
pub fn generate_grid( &mut self, ) -> Result<(GenInfo, GridData<C, ModelInstance, G>), GeneratorError>
Tries to generate the whole grid. If the generation fails due to a contradiction, it will retry max_retry_count
times before returning the last encountered GeneratorError
If the generation is currently done or failed, calling this method will reinitialize the generator with the next seed before starting the generation.
If the generation was already started by previous calls to Generator::set_and_propagate
or Generator::select_and_propagate
, this will simply continue the current generation.
Sourcepub fn generate(&mut self) -> Result<GenInfo, GeneratorError>
pub fn generate(&mut self) -> Result<GenInfo, GeneratorError>
Same as Generator::generate_grid
but does not return the generated ModelInstance
when successful.
Generator::to_grid_data
can still be called to retrieve a GridData
afterwards.
Sourcepub fn select_and_propagate(
&mut self,
) -> Result<GenerationStatus, GeneratorError>
pub fn select_and_propagate( &mut self, ) -> Result<GenerationStatus, GeneratorError>
Advances the generation by one “step”: select a node and a model via the heuristics and propagate the changes.
- Returns the
GenerationStatus
if the step executed successfully - Returns a
GeneratorError
if the generation fails due to a contradiction.
If the generation is currently done or failed, this method will just return the done or failed status/error.
Note: One call to this method can lead to more than one node generated if the propagation phase forces some other node(s) into a definite state (due to only one possible model remaining on a node)
Sourcepub fn select_and_propagate_collected(
&mut self,
) -> Result<(GenerationStatus, Vec<GeneratedNode>), GeneratorError>
pub fn select_and_propagate_collected( &mut self, ) -> Result<(GenerationStatus, Vec<GeneratedNode>), GeneratorError>
Same as Generator::select_and_propagate
but collects and return the generated GeneratedNode
when successful.
Sourcepub fn set_and_propagate<N: NodeRef<C, G>, M: ModelVariantRef<C>>(
&mut self,
node_ref: N,
model_variant_ref: M,
memorized: bool,
) -> Result<GenerationStatus, NodeSetError>
pub fn set_and_propagate<N: NodeRef<C, G>, M: ModelVariantRef<C>>( &mut self, node_ref: N, model_variant_ref: M, memorized: bool, ) -> Result<GenerationStatus, NodeSetError>
Tries to set the node referenced by node_ref
to the model refrenced by model_variant_ref
. Then tries to propagate the change.
- Returns
Ok
and the currentGenerationStatus
if successful. - Returns a
NodeSetError
if it fails.
If the generation is currently done or failed, this method will just return the done or failed status/error.
Note: One call to this method can lead to more than one node generated if the propagation phase forces some other node(s) into a definite state (due to only one possible model remaining on a node)
Sourcepub fn set_and_propagate_collected<N: NodeRef<C, G>, M: ModelVariantRef<C>>(
&mut self,
node_ref: N,
model_variant_ref: M,
memorized: bool,
) -> Result<(GenerationStatus, Vec<GeneratedNode>), NodeSetError>
pub fn set_and_propagate_collected<N: NodeRef<C, G>, M: ModelVariantRef<C>>( &mut self, node_ref: N, model_variant_ref: M, memorized: bool, ) -> Result<(GenerationStatus, Vec<GeneratedNode>), NodeSetError>
Same as Generator::set_and_propagate
but also returns all the GeneratedNode
generated by this generation operation if successful.
Sourcepub fn reinitialize(&mut self) -> GenerationStatus
pub fn reinitialize(&mut self) -> GenerationStatus
Reinitalizes the generator with the next seed (a seed is generated from the current seed)
Sourcepub fn reinitialize_collected(
&mut self,
) -> (GenerationStatus, Vec<GeneratedNode>)
pub fn reinitialize_collected( &mut self, ) -> (GenerationStatus, Vec<GeneratedNode>)
Same as Generator::reinitialize
but also returns all the GeneratedNode
generated by this generation operation.
Sourcepub fn get_models_on(&self, node_index: NodeIndex) -> Vec<ModelInstance>
pub fn get_models_on(&self, node_index: NodeIndex) -> Vec<ModelInstance>
Returns all the current possible model instances on node_index
Sourcepub fn get_models_variations_on(
&self,
node_index: NodeIndex,
) -> (Vec<ModelVariations>, u32)
pub fn get_models_variations_on( &self, node_index: NodeIndex, ) -> (Vec<ModelVariations>, u32)
Returns all the current possible model on node_index
grouped by variations, as well as the total number of possible models
Auto Trait Implementations§
impl<C, G> Freeze for Generator<C, G>where
G: Freeze,
impl<C, G> RefUnwindSafe for Generator<C, G>where
G: RefUnwindSafe,
C: RefUnwindSafe,
impl<C, G> Send for Generator<C, G>where
G: Send,
impl<C, G> Sync for Generator<C, G>where
G: Sync,
impl<C, G> Unpin for Generator<C, G>where
G: Unpin,
impl<C, G> UnwindSafe for Generator<C, G>where
G: UnwindSafe,
C: RefUnwindSafe,
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.