pub struct GeneratorRuleset<A: DistributionKey> { /* private fields */ }Implementations§
Source§impl<A: DistributionKey> GeneratorRuleset<A>
impl<A: DistributionKey> GeneratorRuleset<A>
Source§impl<K: DistributionKey + Serialize> GeneratorRuleset<K>
impl<K: DistributionKey + Serialize> GeneratorRuleset<K>
Source§impl GeneratorRuleset<i8>
impl GeneratorRuleset<i8>
Source§impl<DK: DistributionKey> GeneratorRuleset<DK>
impl<DK: DistributionKey> GeneratorRuleset<DK>
pub fn default_map_builder<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>( &self, map_size: u32, ) -> Map2D<AG, DK, MP>
Sourcepub fn build_unassigned_map_with_size<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>(
&self,
map_size: Option<u32>,
map_builder: Option<Box<dyn Fn(u32) -> Map2D<AG, DK, MP>>>,
) -> Map2D<AG, DK, MP>
pub fn build_unassigned_map_with_size<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>( &self, map_size: Option<u32>, map_builder: Option<Box<dyn Fn(u32) -> Map2D<AG, DK, MP>>>, ) -> Map2D<AG, DK, MP>
Generates an empty (i.e. ‘un-collapsed’) map. This can be passed to a generate/infill function to collapse the map to a generated state.
Arguments:
map_size- optional u32, size of the map to generate (currently only square maps supported, so this corresponds to both X & Y axes. If None, falls back to the Ruleset value.map_builder- optional function that takes a mapsize and returns a map. If None, uses the default method (allocate mapsize ** 2 unassigned tiles with uniform probability.)
Returns: a new Map2D.
Sourcepub fn build_unassigned_map<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>(
&self,
) -> Map2D<AG, DK, MP>
pub fn build_unassigned_map<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>( &self, ) -> Map2D<AG, DK, MP>
Generates an empty (i.e. ‘uncollapsed’) map using the default algorithm. This can be passed to a generate/infill function to collapse the map to a generated state.
Takes no arguments, effectively a sugar for self.build_unassigned_map_with_size(None, None)
Returns: a new Map2D.
Sourcepub fn generate_with_visualizer<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>(
&self,
init_map: Option<Map2D<AG, DK, MP>>,
visualiser: V,
)
pub fn generate_with_visualizer<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>( &self, init_map: Option<Map2D<AG, DK, MP>>, visualiser: V, )
Creates a filled (i.e. ‘collapsed’) map, either from a partially un-collapsed map or entirely from scratch, and renders it using a provided MapVisualizer.
Arguments:
- init_map - optional; a pre-initialized map to fill out. If None, will create a new map using the provided Ruleset’s rules
- visualizer - MapVisualizer interface to use to render the generated map.
Returns: nothing (i.e. Unit); a render will be created as a side-effect.
Sourcepub fn generate_map<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>>(
&self,
init_map: Option<Map2D<AG, DK, MP>>,
)
pub fn generate_map<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>>( &self, init_map: Option<Map2D<AG, DK, MP>>, )
Creates a filled (i.e. ‘collapsed’) map, either from a partially un-collapsed map or entirely from scratch, and renders it using the default MapVisualizer.
Effectively sugar over self.generate_with_visualizer(init_map, <default visualizer>)
Arguments:
- init_map - optional; a pre-initialized map to fill out. If None, will create a new map using the provided Ruleset’s rules
Returns: nothing (i.e. Unit); a render will be created as a side-effect.
Sourcepub fn generate<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>>(
&self,
)
pub fn generate<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>>( &self, )
Creates a filled (i.e. ‘collapsed’) map from scratch, and renders it using the default MapVisualizer.
Effectively sugar over self.generate_map(None, <default visualizer>)
Arguments - none
Returns: nothing (i.e. Unit); a render will be created as a side-effect.
Source§impl<DK: DistributionKey + Send + Sync> GeneratorRuleset<DK>
impl<DK: DistributionKey + Send + Sync> GeneratorRuleset<DK>
pub fn default_map_builder_par<AG, MP, V>(
&self,
map_size: u32,
) -> Map2D<AG, DK, MP>where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
Sourcepub fn build_unassigned_map_with_size_par<AG, MP, V>(
&self,
map_size: Option<u32>,
map_builder: Option<Box<dyn Fn(u32) -> Map2D<AG, DK, MP>>>,
) -> Map2D<AG, DK, MP>where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
pub fn build_unassigned_map_with_size_par<AG, MP, V>(
&self,
map_size: Option<u32>,
map_builder: Option<Box<dyn Fn(u32) -> Map2D<AG, DK, MP>>>,
) -> Map2D<AG, DK, MP>where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
Generates an empty (i.e. ‘un-collapsed’) map. This can be passed to a generate/infill function to collapse the map to a generated state.
Arguments:
map_size- optional u32, size of the map to generate (currently only square maps supported, so this corresponds to both X & Y axes. If None, falls back to the Ruleset value.map_builder- optional function that takes a mapsize and returns a map. If None, uses the default method (allocate mapsize ** 2 unassigned tiles with uniform probability.)
Returns: a new Map2D.
Sourcepub fn build_unassigned_map_par<AG, MP, V>(&self) -> Map2D<AG, DK, MP>where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
pub fn build_unassigned_map_par<AG, MP, V>(&self) -> Map2D<AG, DK, MP>where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
Generates an empty (i.e. ‘uncollapsed’) map using the default algorithm. This can be passed to a generate/infill function to collapse the map to a generated state.
Takes no arguments, effectively a sugar for self.build_unassigned_map_with_size(None, None)
Returns: a new Map2D.
Sourcepub fn generate_with_visualizer_par<AG, MP, V>(
&self,
init_map: Option<Map2D<AG, DK, MP>>,
visualiser: V,
)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
pub fn generate_with_visualizer_par<AG, MP, V>(
&self,
init_map: Option<Map2D<AG, DK, MP>>,
visualiser: V,
)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
Creates a filled (i.e. ‘collapsed’) map, either from a partially un-collapsed map or entirely from scratch, and renders it using a provided MapVisualizer.
Arguments:
- init_map - optional; a pre-initialized map to fill out. If None, will create a new map using the provided Ruleset’s rules
- visualizer - MapVisualizer interface to use to render the generated map.
Returns: nothing (i.e. Unit); a render will be created as a side-effect.
pub fn regenerate_region<AG, MP, V: MapVisualizer<AG, DK, MP>>(
&self,
src_map: &Map2D<AG, DK, MP>,
start_pos: [MP::Key; 2],
end_pos: [MP::Key; 2],
) -> Arc<RwLock<Map2D<AG, DK, MP>>>where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
Sourcepub fn generate_with_visualizer_par_mib<AG, MP, V>(
&self,
init_map: Option<Map2D<AG, DK, MP>>,
visualiser: V,
)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
V::Args: From<&'static str>,
pub fn generate_with_visualizer_par_mib<AG, MP, V>(
&self,
init_map: Option<Map2D<AG, DK, MP>>,
visualiser: V,
)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
V: MapVisualizer<AG, DK, MP>,
V::Args: From<&'static str>,
Showcase of Modifying In Blocks approach - generates a map, then edits the top-left quadrant by restting it to an unassigned state and filling it in again. The approach here is consistent (i.e. doesn’t violate constraints), but may exhibit directional artifacts on the quadrant edge (usually, unnaturally straight lines).
Sourcepub fn generate_map_par<AG, MP>(&self, init_map: Option<Map2D<AG, DK, MP>>)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
pub fn generate_map_par<AG, MP>(&self, init_map: Option<Map2D<AG, DK, MP>>)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
Creates a filled (i.e. ‘collapsed’) map, either from a partially un-collapsed map or entirely from scratch, and renders it using the default MapVisualizer.
Effectively sugar over self.generate_with_visualizer(init_map, <default visualizer>)
Arguments:
- init_map - optional; a pre-initialized map to fill out. If None, will create a new map using the provided Ruleset’s rules
Returns: nothing (i.e. Unit); a render will be created as a side-effect.
Sourcepub fn generate_par<AG, MP>(&self)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
pub fn generate_par<AG, MP>(&self)where
AG: AdjacencyGenerator<2, Input = MP> + Send + Sync + AdjacencyGenerator<2, Input = MP>,
MP: MapPosition<2> + Send + Sync + MapPosition<2>,
MP::Key: PositionKey + NumCast + Into<u32> + Send + Sync,
Creates a filled (i.e. ‘collapsed’) map from scratch, and renders it using the default MapVisualizer.
Effectively sugar over self.generate_map(None, <default visualizer>)
Arguments - none
Returns: nothing (i.e. Unit); a render will be created as a side-effect.
Trait Implementations§
Source§impl<'de, A> Deserialize<'de> for GeneratorRuleset<A>where
A: Deserialize<'de> + DistributionKey,
impl<'de, A> Deserialize<'de> for GeneratorRuleset<A>where
A: Deserialize<'de> + DistributionKey,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a, 'b, 'c, BS: Borrow<&'c str>> From<(&'a str, &'b str, Option<u32>, Option<BS>)> for GeneratorRuleset<i8>
impl<'a, 'b, 'c, BS: Borrow<&'c str>> From<(&'a str, &'b str, Option<u32>, Option<BS>)> for GeneratorRuleset<i8>
Source§impl<A: DistributionKey> From<GeneratorRuleset<A>> for HashMap<A, MapColor>
impl<A: DistributionKey> From<GeneratorRuleset<A>> for HashMap<A, MapColor>
Source§fn from(val: GeneratorRuleset<A>) -> Self
fn from(val: GeneratorRuleset<A>) -> Self
Source§impl<A: DistributionKey> From<GeneratorRuleset<A>> for MapColoringAssigner<A>
impl<A: DistributionKey> From<GeneratorRuleset<A>> for MapColoringAssigner<A>
Source§fn from(val: GeneratorRuleset<A>) -> MapColoringAssigner<A>
fn from(val: GeneratorRuleset<A>) -> MapColoringAssigner<A>
Source§impl<A> Serialize for GeneratorRuleset<A>where
A: Serialize + DistributionKey,
impl<A> Serialize for GeneratorRuleset<A>where
A: Serialize + DistributionKey,
Auto Trait Implementations§
impl<A> Freeze for GeneratorRuleset<A>
impl<A> RefUnwindSafe for GeneratorRuleset<A>where
A: RefUnwindSafe,
impl<A> Send for GeneratorRuleset<A>
impl<A> Sync for GeneratorRuleset<A>
impl<A> Unpin for GeneratorRuleset<A>where
A: Unpin,
impl<A> UnwindSafe for GeneratorRuleset<A>where
A: UnwindSafe + 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> 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