-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Library implementing Halma rules
--
-- Rules and diagrams-based renderer for the board game Halma on a
-- hexagonal grid.
@package halma
@version 0.1.0.1
module Game.Halma.Board
data HalmaGridSize
S :: HalmaGridSize
L :: HalmaGridSize
data HalmaGrid :: HalmaGridSize -> *
SmallGrid :: HalmaGrid S
LargeGrid :: HalmaGrid L
-- | Numbers of fields on each straight edge of a star-shaped halma board
-- of the given size.
sideLength :: HalmaGrid size -> Int
-- | Total number of fields on a halma board of the given size.
numberOfFields :: HalmaGrid size -> Int
-- | The six corners of a star-shaped halma board.
data HalmaDirection
North :: HalmaDirection
Northeast :: HalmaDirection
Southeast :: HalmaDirection
South :: HalmaDirection
Southwest :: HalmaDirection
Northwest :: HalmaDirection
oppositeDirection :: HalmaDirection -> HalmaDirection
-- | From the point of view of the given corner: On which row lies the
-- given field? The row through the center is row zero, rows nearer to
-- the corner have positive, rows nearer to the opposite corner negative
-- numbers.
rowsInDirection :: HalmaDirection -> (Int, Int) -> Int
-- | The corner corresponding to a direction on a star-shaped board of the
-- given size.
corner :: HalmaGrid size -> HalmaDirection -> (Int, Int)
-- | The corner where the team starts.
type Team = HalmaDirection
-- | The position of the corner field where a team starts.
startCorner :: HalmaGrid size -> Team -> (Int, Int)
-- | The position of the end zone corner of a team.
endCorner :: HalmaGrid size -> Team -> (Int, Int)
-- | The start positions of a team's pieces.
startFields :: HalmaGrid size -> Team -> [(Int, Int)]
-- | The end zone of the given team.
endFields :: HalmaGrid size -> Team -> [(Int, Int)]
-- | Map from board positions to the team occupying that position.
data HalmaBoard size
getGrid :: HalmaBoard size -> HalmaGrid size
toMap :: HalmaBoard size -> Map (Int, Int) Team
-- | Construct halma boards. Satisfies fromMap (getGrid board) (toMap
-- board) = Just board.
fromMap :: HalmaGrid size -> Map (Index (HalmaGrid size)) Team -> Maybe (HalmaBoard size)
-- | Lookup whether a position on the board is occupied, and
lookupHalmaBoard :: (Int, Int) -> HalmaBoard size -> Maybe Team
-- | Move a piece on the halma board. This function does not check whether
-- the move is valid according to the Halma rules.
movePiece :: (Int, Int) -> (Int, Int) -> HalmaBoard size -> Either String (HalmaBoard size)
initialBoard :: HalmaGrid size -> (Team -> Bool) -> HalmaBoard size
instance Eq HalmaDirection
instance Show HalmaDirection
instance Read HalmaDirection
instance Ord HalmaDirection
instance Bounded HalmaDirection
instance Enum HalmaDirection
instance Generic HalmaDirection
instance Eq (HalmaBoard size)
instance Datatype D1HalmaDirection
instance Constructor C1_0HalmaDirection
instance Constructor C1_1HalmaDirection
instance Constructor C1_2HalmaDirection
instance Constructor C1_3HalmaDirection
instance Constructor C1_4HalmaDirection
instance Constructor C1_5HalmaDirection
instance Show (HalmaBoard size)
instance BoundedGrid (HalmaGrid size)
instance FiniteGrid (HalmaGrid 'L)
instance FiniteGrid (HalmaGrid 'S)
instance Grid (HalmaGrid size)
instance Show (HalmaGrid size)
instance Ord (HalmaGrid size)
instance Eq (HalmaGrid size)
module Game.Halma.Rules
data RuleOptions
RuleOptions :: Bool -> RuleOptions
-- | May pieces be moved towards the start corner of the team?
backwardsMovesAllowed :: RuleOptions -> Bool
-- | Computes all possible moves for a piece.
possibleMoves :: RuleOptions -> HalmaBoard size -> (Int, Int) -> [(Int, Int)]
-- | Has a team all of it's pieces in the end zone?
hasFinished :: HalmaBoard size -> Team -> Bool
instance Show RuleOptions
instance Eq RuleOptions
instance Default RuleOptions
module Game.Halma.Board.Draw
defaultTeamColours :: Team -> Colour Double
-- | Render the board using the helper function for drawing the fields.
-- Supports querying for field positions.
drawBoard' :: Renderable (Path R2) b => HalmaGrid size -> ((Int, Int) -> Diagram b R2) -> QDiagram b R2 (Option (Last (Int, Int)))
-- | Render the board using the given team colors. Supports querying for
-- field positions.
drawBoard :: Renderable (Path R2) b => HalmaBoard size -> (Team -> Colour Double) -> QDiagram b R2 (Option (Last (Int, Int)))