Tessellations¶
Tessellation¶
SokobanTessellation¶
- class SokobanTessellation¶
Bases:
BaseTessellation
Tessellation for Sokoban game variant.
Board is laid out on squares.
Direction <-> character mapping:
LEFT
RIGHT
UP
DOWN
l, L
r, R
u, U
d, D
- __init__()¶
HexobanTessellation¶
- class HexobanTessellation¶
Bases:
BaseTessellation
Tessellation for Hexoban game variant.
Board space is laid out on vertical 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 (TM)’
Direction <-> character mapping:
LEFT
RIGHT
NORTH_WEST
SOUTH_WEST
NORTH_EAST
SOUTH_EAST
l, L
r, R
u, U
d, D
n, N
s, S
- __init__()¶
TriobanTessellation¶
- class TriobanTessellation¶
Bases:
BaseTessellation
Tessellation for Trioban game variant.
Board is laid out on alternating triangles with origin triangle pointing down.
Direction <-> character mapping:
LEFT
RIGHT
NORTH_EAST
NORTH_WEST
SOUTH_EAST
SOUTH_WEST
l, L
r, R
n, N
u, U
d, D
s, S
Depending on pusher position, not all move directions are allowed on all board positions:
- __init__()¶
OctobanTessellation¶
- class OctobanTessellation¶
Bases:
BaseTessellation
Tessellation for Octoban game variant.
Board space is laid out on alternating squares and octagons with origin of coordinate system being octagon. Tessellation allows all 8 directions of movement from Direction and depending on current pusher position some of these directions do not result in successful move.
Direction <-> character mapping:
UP
NORTH_EAST
RIGHT
SOUTH_EAST
DOWN
SOUTH_WEST
LEFT
NORTH_WEST
u, U
n, N
r, R
e, E
d, D
s, S
l, L
w, W
- __init__()¶
BaseTessellation¶
- class BaseTessellation¶
Base class for all tessellation implementations.
- cell_orientation(position: int, board_width: int, board_height: int) CellOrientation ¶
Calculates board cell orientation for given coordinate.
- char_to_pusher_step(input_chr: str) PusherStep ¶
Converts movement character to
PusherStep
.- Raises
ValueError – conversion is not possible in context of this tessellation
- classmethod instance(tessellation: Tessellation) Union[TriobanTessellation, OctobanTessellation, HexobanTessellation, SokobanTessellation] ¶
- abstract neighbor_position(position: int, direction: Direction, board_width: int, board_height: int) int ¶
Calculates neighbor position in given direction.
Position is always expressed as 1D index of board graph vertex.
To convert 2D coordinates into vertex index, use
index_1d()
method.To convert 1D vertex index into 2D coordinates, use combinations of
index_row()
andindex_column()
functions.- Returns
New position or
Config.NO_POS
when new position would be off-board.- Return type
- Raises
ValueError –
direction
is not one oflegal_directions
orboard_width
is invalid value orboard_height
is invalid value.
- pusher_step_to_char(pusher_step: PusherStep) str ¶
Converts
PusherStep
to movement character.- Raises
ValueError – conversion not possible in context of this tessellation