-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tools for working with regular grids\/graphs\/lattices. -- -- Provides tools for working with regular arrangements of tiles, such as -- might be used in a board game or some other type of grid map. -- Currently supports triangular, square, and hexagonal tiles, with -- various 2D and toroidal layouts. @package grid @version 1.1 -- | A module containing private Grid internals. Most developers -- should use Grid instead. This module is subject to change -- without notice. module Math.Geometry.GridInternal -- | A regular arrangement of tiles. Minimal complete definition: -- indices, distance, and size. class Eq x => Grid g s x | g -> s, g -> x where neighbours x g = filter (\ a -> distance x a g ≡ 1) $ indices g inGrid x g = x `elem` indices g viewpoint p g = map f (indices g) where f x = (x, distance p x g) tileCount = length . indices empty g = tileCount g ≡ 0 nonEmpty = not . empty indices :: Grid g s x => g -> [x] distance :: Grid g s x => x -> x -> g -> Int size :: Grid g s x => g -> s neighbours :: Grid g s x => x -> g -> [x] inGrid :: Grid g s x => x -> g -> Bool viewpoint :: Grid g s x => x -> g -> [(x, Int)] tileCount :: (Grid g s x, Grid g s x) => g -> Int empty :: (Grid g s x, Grid g s x) => g -> Bool nonEmpty :: (Grid g s x, Grid g s x) => g -> Bool -- | A triangular grid with triangular tiles. The grid and its indexing -- scheme are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data TriTriGrid -- | triTriGrid s returns a triangular grid with sides of -- length s, using triangular tiles. If s is -- nonnegative, the resulting grid will have s^2 tiles. -- Otherwise, the resulting grid will be empty and the list of indices -- will be null. triTriGrid :: Int -> TriTriGrid -- | A Parallelogrammatical grid with triangular tiles. The grid and its -- indexing scheme are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data ParaTriGrid -- | paraTriGrid r c returns a grid in the shape of a -- parallelogram with r rows and c columns, using -- triangular tiles. If r and c are both nonnegative, -- the resulting grid will have 2*r*c tiles. Otherwise, the -- resulting grid will be empty and the list of indices will be null. paraTriGrid :: Int -> Int -> ParaTriGrid -- | A rectangular grid with square tiles. The grid and its indexing scheme -- are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data RectSquareGrid -- | rectSquareGrid r c produces a rectangular grid with -- r rows and c columns, using square tiles. If -- r and c are both nonnegative, the resulting grid -- will have r*c tiles. Otherwise, the resulting grid will be -- empty and the list of indices will be null. rectSquareGrid :: Int -> Int -> RectSquareGrid -- | A toroidal grid with square tiles. The grid and its indexing scheme -- are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data TorSquareGrid -- | torSquareGrid r c returns a toroidal grid with -- r rows and c columns, using square tiles. If -- r and c are both nonnegative, the resulting grid -- will have r*c tiles. Otherwise, the resulting grid will be -- empty and the list of indices will be null. torSquareGrid :: Int -> Int -> TorSquareGrid -- | A hexagonal grid with hexagonal tiles The grid and its indexing scheme -- are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data HexHexGrid -- | hexHexGrid s returns a grid of hexagonal shape, with -- -- sides of length s, using hexagonal tiles. If s is -- nonnegative, the resulting grid will have 3*s*(s-1) + 1 -- tiles. Otherwise, the resulting grid will be empty and the list of -- indices will be null. hexHexGrid :: Int -> HexHexGrid -- | A parallelogramatical grid with hexagonal tiles The grid and its -- indexing scheme are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data ParaHexGrid -- | paraHexGrid r c returns a grid in the shape of a -- parallelogram with r rows and c columns, using -- hexagonal tiles. If r and c are both nonnegative, -- the resulting grid will have r*c tiles. Otherwise, the -- resulting grid will be empty and the list of indices will be null. paraHexGrid :: Int -> Int -> ParaHexGrid instance Grid ParaHexGrid (Int, Int) (Int, Int) instance Show ParaHexGrid instance Grid HexHexGrid Int (Int, Int) instance Show HexHexGrid instance Grid TorSquareGrid (Int, Int) (Int, Int) instance Show TorSquareGrid instance Grid RectSquareGrid (Int, Int) (Int, Int) instance Show RectSquareGrid instance Grid ParaTriGrid (Int, Int) (Int, Int) instance Show ParaTriGrid instance Grid TriTriGrid Int (Int, Int) instance Show TriTriGrid -- | A regular arrangement of tiles. Grids have a variety of uses, -- including games and self-organising maps. module Math.Geometry.Grid -- | A regular arrangement of tiles. Minimal complete definition: -- indices, distance, and size. class Eq x => Grid g s x | g -> s, g -> x where neighbours x g = filter (\ a -> distance x a g ≡ 1) $ indices g inGrid x g = x `elem` indices g viewpoint p g = map f (indices g) where f x = (x, distance p x g) tileCount = length . indices empty g = tileCount g ≡ 0 nonEmpty = not . empty indices :: Grid g s x => g -> [x] distance :: Grid g s x => x -> x -> g -> Int size :: Grid g s x => g -> s neighbours :: Grid g s x => x -> g -> [x] inGrid :: Grid g s x => x -> g -> Bool viewpoint :: Grid g s x => x -> g -> [(x, Int)] tileCount :: (Grid g s x, Grid g s x) => g -> Int empty :: (Grid g s x, Grid g s x) => g -> Bool nonEmpty :: (Grid g s x, Grid g s x) => g -> Bool -- | A triangular grid with triangular tiles. The grid and its indexing -- scheme are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data TriTriGrid -- | triTriGrid s returns a triangular grid with sides of -- length s, using triangular tiles. If s is -- nonnegative, the resulting grid will have s^2 tiles. -- Otherwise, the resulting grid will be empty and the list of indices -- will be null. triTriGrid :: Int -> TriTriGrid -- | A Parallelogrammatical grid with triangular tiles. The grid and its -- indexing scheme are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data ParaTriGrid -- | paraTriGrid r c returns a grid in the shape of a -- parallelogram with r rows and c columns, using -- triangular tiles. If r and c are both nonnegative, -- the resulting grid will have 2*r*c tiles. Otherwise, the -- resulting grid will be empty and the list of indices will be null. paraTriGrid :: Int -> Int -> ParaTriGrid -- | A rectangular grid with square tiles. The grid and its indexing scheme -- are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data RectSquareGrid -- | rectSquareGrid r c produces a rectangular grid with -- r rows and c columns, using square tiles. If -- r and c are both nonnegative, the resulting grid -- will have r*c tiles. Otherwise, the resulting grid will be -- empty and the list of indices will be null. rectSquareGrid :: Int -> Int -> RectSquareGrid -- | A toroidal grid with square tiles. The grid and its indexing scheme -- are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data TorSquareGrid -- | torSquareGrid r c returns a toroidal grid with -- r rows and c columns, using square tiles. If -- r and c are both nonnegative, the resulting grid -- will have r*c tiles. Otherwise, the resulting grid will be -- empty and the list of indices will be null. torSquareGrid :: Int -> Int -> TorSquareGrid -- | A hexagonal grid with hexagonal tiles The grid and its indexing scheme -- are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data HexHexGrid -- | hexHexGrid s returns a grid of hexagonal shape, with -- -- sides of length s, using hexagonal tiles. If s is -- nonnegative, the resulting grid will have 3*s*(s-1) + 1 -- tiles. Otherwise, the resulting grid will be empty and the list of -- indices will be null. hexHexGrid :: Int -> HexHexGrid -- | A parallelogramatical grid with hexagonal tiles The grid and its -- indexing scheme are illustrated in the user guide, available at -- https:github.commhwombatgrid/wiki. data ParaHexGrid -- | paraHexGrid r c returns a grid in the shape of a -- parallelogram with r rows and c columns, using -- hexagonal tiles. If r and c are both nonnegative, -- the resulting grid will have r*c tiles. Otherwise, the -- resulting grid will be empty and the list of indices will be null. paraHexGrid :: Int -> Int -> ParaHexGrid