Generate random tiling patters.
import Tiler exposing (Board, Neighbor(..), emptyBoard, generateBoard, map)
Dict String (Tile t)
The set of all tiles. Can be easily mapped over for displaying
emptyBoard : Board t
An empty board.
generateBoard : Basics.Int -> Basics.Int -> (( Basics.Int, Basics.Int ) -> ( t, List t )) -> (List t -> List t -> Neighbor -> ( t, List t )) -> Random.Seed -> ( Board t, Random.Seed )
Generates a new Board.
Expects an Int width, Int height, function for populating the possible tiles per position in the board, function for validating neighbors, and an initial Seeds.
The function gets 2 arguments. First a tuple of Ints, in the same format as positionToXY. Second a List of the tile(s). A single item in the list represents the tile being set to that item. Multiple represents that the tile is still undecided.
generateBoard width height generateOneOf validateNeighbors seed
generateOneOf gets a tuple of Ints in the format of positionToXY and returns a tuple of (tile, List tile) representing the possible tiles for this coordinate.
validateNeighbors gets a list of tiles, a list of neighbor tiles, and a Neighbor direction for describing the position of the neighbor tiles relative to the first tiles
map : (( Basics.Int, Basics.Int ) -> ( t, List t ) -> a) -> Board t -> List a
Used for mapping over a Board. Takes a function and a Board.
The function gets 2 arguments. First a tuple of Ints, in the same format as positionToXY. Second a List of the tile(s). A single item in the list represents the tile being set to that item. Multiple represents that the tile is still undecided.
map (\(x, y) (tile, tiles) -> a) someBoard
Used for determining the relative positioning of 2 tiles.
positionToString : Position -> String
Used for pretty printing a Position.
-- A position where x == 3 and y ==2
positionToString pos == "3, 2"
positionFromString : String -> Maybe Position
Used to build a position from a string
positionFromString "3, 2" == Just { x = 3, y = 2 }
positionFromString "6 8" == Nothing
positionToXY : Position -> ( Basics.Int, Basics.Int )
Used to get the X and Y values from a position
-- A position where x == 3 and y ==2
positionToXY pos == (3, 2)