GeneratorRuleset

Struct GeneratorRuleset 

Source
pub struct GeneratorRuleset<A: DistributionKey> { /* private fields */ }

Implementations§

Source§

impl<A: DistributionKey> GeneratorRuleset<A>

Source

pub fn new( layout: MapColoringAssigner<A>, coloring: HashMap<A, MapColor>, map_size: Option<u32>, adjacency: Option<String>, ) -> Self

Source§

impl<K: DistributionKey + Serialize> GeneratorRuleset<K>

Source

pub fn save<P: AsRef<Path>>(&self, filepath: P) -> &Self

Source§

impl GeneratorRuleset<i8>

Source

pub fn load<P: AsRef<Path> + Debug>(filepath: P) -> Result<Self, Error>

Source§

impl<DK: DistributionKey> GeneratorRuleset<DK>

Source

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>
where MP::Key: PositionKey + NumCast,

Source

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>
where MP::Key: PositionKey + NumCast,

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.

Source

pub fn build_unassigned_map<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>, V: MapVisualizer<AG, DK, MP>>( &self, ) -> Map2D<AG, DK, MP>
where MP::Key: PositionKey + NumCast,

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.

Source

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, )
where MP::Key: PositionKey + NumCast,

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.

Source

pub fn generate_map<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>>( &self, init_map: Option<Map2D<AG, DK, MP>>, )
where MP::Key: PositionKey + NumCast + Into<u32>,

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.

Source

pub fn generate<AG: AdjacencyGenerator<2, Input = MP>, MP: MapPosition<2>>( &self, )
where MP::Key: PositionKey + NumCast + Into<u32>,

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>

Source

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>,

Source

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.

Source

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.

Source

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.

Source

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,

Source

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).

Source

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.

Source

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,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a, 'b> From<(&'a str, &'b str)> for GeneratorRuleset<i8>

Source§

fn from(value: (&'a str, &'b str)) -> Self

Converts to this type from the input type.
Source§

impl<'a, 'b> From<(&'a str, &'b str, Option<u32>)> for GeneratorRuleset<i8>

Source§

fn from(value: (&'a str, &'b str, Option<u32>)) -> Self

Converts to this type from the input type.
Source§

impl<'a, 'b, 'c, BS: Borrow<&'c str>> From<(&'a str, &'b str, Option<u32>, Option<BS>)> for GeneratorRuleset<i8>

Source§

fn from(value: (&'a str, &'b str, Option<u32>, Option<BS>)) -> Self

Converts to this type from the input type.
Source§

impl<'a, 'b> From<(&'a str, &'b str, u32)> for GeneratorRuleset<i8>

Source§

fn from(value: (&'a str, &'b str, u32)) -> Self

Converts to this type from the input type.
Source§

impl<A: DistributionKey> From<GeneratorRuleset<A>> for HashMap<A, MapColor>

Source§

fn from(val: GeneratorRuleset<A>) -> Self

Converts to this type from the input type.
Source§

impl<A: DistributionKey> From<GeneratorRuleset<A>> for MapColoringAssigner<A>

Source§

fn from(val: GeneratorRuleset<A>) -> MapColoringAssigner<A>

Converts to this type from the input type.
Source§

impl<A> Serialize for GeneratorRuleset<A>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<A> Freeze for GeneratorRuleset<A>

§

impl<A> RefUnwindSafe for GeneratorRuleset<A>
where A: RefUnwindSafe,

§

impl<A> Send for GeneratorRuleset<A>
where A: Send + Sync,

§

impl<A> Sync for GeneratorRuleset<A>
where A: Sync + Send,

§

impl<A> Unpin for GeneratorRuleset<A>
where A: Unpin,

§

impl<A> UnwindSafe for GeneratorRuleset<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,