This library allows user to create a random two dimensional map/grid/board based on custom "tiles". The user has to specify what "sockets" each tile is exposing at each edge/direction to determine whether they can be placed next to each other.
Specifies direction in which another tile can be placed relative to the current tile
Represents the working state of a two dimensional map/board.
Unless it's done this will have positions that have not been
assigned to a tile yet.
tileT is the type for the tiles used to "fill" the map.
socketT is a type that describes the "edge" of a tile in a certain Direction.
The sockets have to match in order for two tiles to be positioned next to each other.
The position/index of a tile in the initial list of tiles (given with the TilesDefinition)
The init function creates an empty model based on the given TilesDefinition.
This model can then either be populated step by step with propagate or
filled in one call with the solve function.
Tries to solve/fill the whole grid in one go by assigning a tile to each position.
Adds a step to pick a specific tile at a specific position
Execute a single step. This can mean picking the next random tile or propagating restrictions resulting from the last placement of a tile.
Returns a Html representation of the internal state while assigning the tiles It will let the user pick tiles manually and requires a function to generate a message for that. It also needs a function to render a Html representation of a tile (since it's type is only known to the app). For positions that have not been assigned a tile yet this will show which tile (ids) can still be picked.
A
TilesDefinitioncontains all the necessary information to describe what kind of map/grid/board is to be generated. User can user their own type oftiles. But they must provide agetSocketInfunction that returns what kind ofsocketeach tile exposes in a certain direction.The
initialSeeddetermines the generation of the pseudo random numbers used to pick tiles. So to get different results you can seed it for example with the current timestamp.