pub struct GrowingTree { /* private fields */ }
Expand description
The “Growing Tree” algorithm for generating mazes
The algorithm appears to be the most flexible and customizable. Configured one way, it mimics the behavior of the Recursive Backtracking algorithm. Configured another, it works almost exactly like Prim’s algorithm. Another trivial change and you can combine two or more methods with some probability and generate mazes with mixed attributes.
You can find plenty of supported methods in the Method enum.
Implementations§
Source§impl GrowingTree
impl GrowingTree
Sourcepub const fn new(method: Method) -> GrowingTree
pub const fn new(method: Method) -> GrowingTree
Create a new instance of the algorithm with a given method
§Example
use knossos::maze::{GrowingTree, Method};
let algorithm = GrowingTree::new(Method::Newest);
Trait Implementations§
Source§impl Algorithm for GrowingTree
An implementation of the “Growing Tree” algorithm for generating mazes
impl Algorithm for GrowingTree
An implementation of the “Growing Tree” algorithm for generating mazes
Despite the method you selected, the algorithm steps remain the same and pretty slick. Here is how it works:
-
Initializes an empty list of cells (hereinafter the C).
-
Adds one cell to the C, at random.
-
Chooses a cell from the C and carves a passage to any unvisited neighbor of that cell adding that neighbor to the C as well. If there are no unvisited neighbors, removes the cell from the C.
-
Repeats #3 until the C is empty.
Auto Trait Implementations§
impl Freeze for GrowingTree
impl RefUnwindSafe for GrowingTree
impl Send for GrowingTree
impl Sync for GrowingTree
impl Unpin for GrowingTree
impl UnwindSafe for GrowingTree
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> 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>
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>
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