pub enum Tessellation {
Sokoban,
Hexoban,
Trioban,
Octoban,
}Expand description
Sokoban game variants.
Variants§
Sokoban
Classic Sokoban game variant.
Game board is grid of squares.
Direction <-> character mapping:
| Direction | Characters |
|---|---|
Direction::Left | l, L |
Direction::Right | r, R |
Direction::Up | u, U |
Direction::Down | d, D |
Example board

Hexoban
Hexoban game variant.
Game board is grid of vertical, equilateral hexagons with following coordinate system:

Textual representation uses two characters for each hexagon. This allows different encoding schemes.
| Scheme 1 | Scheme 2 |
|---|---|
![]() | ![]() |
As long as encoding of single board is consistent, all methods handle any scheme transparently - parsing of board strings ‘Just Works ™’.
Direction <-> character mapping:
| Direction | Characters |
|---|---|
Direction::Left | l, L |
Direction::Right | r, R |
Direction::NorthWest | u, U |
Direction::SouthWest | d, D |
Direction::NorthEast | n, N |
Direction::SouthEast | s, S |
Example board

Trioban
Trioban game variant.
Game board is grid of alternating triangles with origin triangle pointing down.
Depending on pusher position, not all move directions are allowed on all board positions:

Direction <-> character mapping:
| Direction | Characters |
|---|---|
Direction::Left | l, L |
Direction::Right | r, R |
Direction::NorthWest | u, U |
Direction::SouthWest | s, S |
Direction::NorthEast | n, N |
Direction::SouthEast | d, D |
Example board

Octoban
Octoban game variant.
Game board is grid of alternating squares and octagons with origin of coordinate system being octagon.

This game variant allows usage of all 8 directions of movement from
Direction. Depending on current pusher position, some of these
directions may not result in successful move or may even be invalid (ie. trying to move
north-west while standing on square tile).
Direction <-> character mapping:
| Direction | Characters |
|---|---|
Direction::Up | u, U |
Direction::NorthEast | n, N |
Direction::Right | r, R |
Direction::SouthEast | e, E |
Direction::Down | d, D |
Direction::SouthWest | s, S |
Direction::Left | l, L |
Direction::NorthWest | w, W |
Example board

Implementations§
Source§impl Tessellation
impl Tessellation
Sourcepub const COUNT: usize = 4
pub const COUNT: usize = 4
Number of all possible Tessellations.
Sourcepub const ALL: [Tessellation; 4]
pub const ALL: [Tessellation; 4]
All possible Tessellations in order of their discriminant values.
Sourcepub fn rotation_step_degrees(&self) -> u16
pub fn rotation_step_degrees(&self) -> u16
Angle of one call to GameBoard::rotate(), in degrees.
Sourcepub fn translation_period(&self) -> Size2D
pub fn translation_period(&self) -> Size2D
Smallest axis-aligned integer translation that preserves the tiling.
Board resizing may apply a smaller shift by adding perpendicular padding or, for Hexoban, reindexing alternating rows.
Sourcepub fn known_directions(&self) -> &'static [Direction]
pub fn known_directions(&self) -> &'static [Direction]
Slice of all directions that are supported by this tessellation.
Sourcepub fn tile_shapes(&self) -> &'static [TileShape]
pub fn tile_shapes(&self) -> &'static [TileShape]
Slice of all tile shapes that are supported by this tessellation.
Sourcepub const fn tile_shape_from_pos(&self, x: usize, y: usize) -> TileShape
pub const fn tile_shape_from_pos(&self, x: usize, y: usize) -> TileShape
TileShape for given game board position.
Doesn’t check if (x, y) is off board position because planar tiling applies to whole 2D
plane, not just to some part of it enclosed by some game board.
Sourcepub fn neighbor(
&self,
x: usize,
y: usize,
to: Direction,
width: usize,
height: usize,
) -> Option<(usize, usize)>
pub fn neighbor( &self, x: usize, y: usize, to: Direction, width: usize, height: usize, ) -> Option<(usize, usize)>
Calculates neighbor position in part of plane enclosed by some game board.
It returns None if:
- input coordinate
(x, y)is off-board coordinate - output coordinate in direction
towould’ve been off-board coordinate tois not supported direction of movement for underlyingTessellation(for example, trying to move north-west inTessellation::Sokobanfrom any position)tois supported direction of movement for underlyingTessellationbut is not allowed forfrom(for example, trying to move north-west inTessellation::Octobanfrom position of square tile)
Sourcepub fn neighbor_directions(
&self,
x: usize,
y: usize,
width: usize,
height: usize,
) -> Option<DirectionsSet>
pub fn neighbor_directions( &self, x: usize, y: usize, width: usize, height: usize, ) -> Option<DirectionsSet>
Calculates set of directions where all directions in output set lead to valid
Self::neighbor() positions.
If input coordinate (x, y) is off board position, returns None.
Trait Implementations§
Source§impl Clone for Tessellation
impl Clone for Tessellation
impl Copy for Tessellation
Source§impl Debug for Tessellation
impl Debug for Tessellation
Source§impl Default for Tessellation
impl Default for Tessellation
Source§impl<'de> Deserialize<'de> for Tessellation
impl<'de> Deserialize<'de> for Tessellation
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>,
impl Eq for Tessellation
Source§impl Hash for Tessellation
impl Hash for Tessellation
Source§impl Ord for Tessellation
impl Ord for Tessellation
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Tessellation
impl PartialEq for Tessellation
Source§impl PartialOrd for Tessellation
impl PartialOrd for Tessellation
Source§impl Serialize for Tessellation
impl Serialize for Tessellation
impl StructuralPartialEq for Tessellation
Auto Trait Implementations§
impl Freeze for Tessellation
impl RefUnwindSafe for Tessellation
impl Send for Tessellation
impl Sync for Tessellation
impl Unpin for Tessellation
impl UnsafeUnpin for Tessellation
impl UnwindSafe for Tessellation
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> 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 moreSource§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.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.
