Struct wavefc::Wave

source ·
pub struct Wave {
    pub flags: Vec<Flags>,
    /* private fields */
}
Expand description

Encapsulation for the Wave Function Collapse implementation.

Fields§

§flags: Vec<Flags>

Implementations§

Sets the debug mode for the wave. This will print some extra output helpful for debugging.

Collapses continuously until the wave function either completely collapses or the max number of contradictions (attempts has been reached).

Arguments
  • callback: An optional function which accepts the number of iterations and failures occured, as well as the current state of the wave function. This can be used for logging or print purposes.
Notes
  • The number of iterations resets after a failed attempt. The number of failures is never reset.
  • The current representation (Vec<Vec<Vec<usize>>>) is provided in the callback as its not available while the function is borrowing the Wave.
  • No final perfect result is returned from a successful run as to avoid doing extra work in case the caller doesn’t need the final representation.
  • When an error is returned, the final state at which the error occurred is preserved in the wave.

Causing the wave to perform one collapse. This will also cause consequent propagation.

Notes
  • The wave doesn’t stop propogating until its completely iterated over the entire superposition grid. It does this as, although on the first run it doesn’t make much sense, on future runs it will propagate out changes between the sites of different collapses.
  • After this function is called, it saves what it did to a private history log.
    • This can be disabled using the NoHistory flag.
  • If the internal superposition grid is empty, this function will do nothing.

Please note, the flag Flag::NoTransforms must be set at this point for it to be registered.

Clears the wave’s internal history log.

Undo’s the last collapse undertaken by the algorithm.

Parameters:
  • remove_record: Determines whether the operation being undone should be forgotten in the internal history log or remembered.
Notes:
  • If the internal history log for the Wave is empty, this function does nothing.
  • If remove_record is set to true, if an error is returned, DO NOT attempt another undo.
    • In this situation, the last undo will have been marked as undone but an error occurred during this process. Undoing again will likely result in an error for a variety of reasons.

Redos the previous undo if one occured. Otherwise, this function does nothing.

Notes:

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.