Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- data HalmaGridSize
- data HalmaGrid :: HalmaGridSize -> * where
- sideLength :: HalmaGrid size -> Int
- numberOfFields :: HalmaGrid size -> Int
- data HalmaDirection
- oppositeDirection :: HalmaDirection -> HalmaDirection
- leftOf :: HalmaDirection -> HalmaDirection
- rowsInDirection :: HalmaDirection -> (Int, Int) -> Int
- corner :: HalmaGrid size -> HalmaDirection -> (Int, Int)
- type Team = HalmaDirection
- startCorner :: HalmaGrid size -> Team -> (Int, Int)
- endCorner :: HalmaGrid size -> Team -> (Int, Int)
- startFields :: HalmaGrid size -> Team -> [(Int, Int)]
- endFields :: HalmaGrid size -> Team -> [(Int, Int)]
- data HalmaBoard size
- getGrid :: HalmaBoard size -> HalmaGrid size
- toMap :: HalmaBoard size -> Map (Int, Int) Team
- fromMap :: HalmaGrid size -> Map (Index (HalmaGrid size)) Team -> Maybe (HalmaBoard size)
- lookupHalmaBoard :: (Int, Int) -> HalmaBoard size -> Maybe Team
- movePiece :: (Int, Int) -> (Int, Int) -> HalmaBoard size -> Either String (HalmaBoard size)
- initialBoard :: HalmaGrid size -> (Team -> Bool) -> HalmaBoard size
Documentation
data HalmaGridSize Source
data HalmaGrid :: HalmaGridSize -> * where Source
Eq (HalmaGrid size) | |
Ord (HalmaGrid size) | |
Show (HalmaGrid size) | |
Grid (HalmaGrid size) | |
FiniteGrid (HalmaGrid L) | |
FiniteGrid (HalmaGrid S) | |
BoundedGrid (HalmaGrid size) | |
type Direction (HalmaGrid size) = HexDirection | |
type Index (HalmaGrid size) = (Int, Int) | |
type Size (HalmaGrid L) = () | |
type Size (HalmaGrid S) = () |
sideLength :: HalmaGrid size -> Int Source
Numbers of fields on each straight edge of a star-shaped halma board of the given size.
numberOfFields :: HalmaGrid size -> Int Source
Total number of fields on a halma board of the given size.
data HalmaDirection Source
The six corners of a star-shaped halma board.
rowsInDirection :: HalmaDirection -> (Int, Int) -> Int Source
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.
corner :: HalmaGrid size -> HalmaDirection -> (Int, Int) Source
The corner corresponding to a direction on a star-shaped board of the given size.
type Team = HalmaDirection Source
The corner where the team starts.
startCorner :: HalmaGrid size -> Team -> (Int, Int) Source
The position of the corner field where a team starts.
endCorner :: HalmaGrid size -> Team -> (Int, Int) Source
The position of the end zone corner of a team.
data HalmaBoard size Source
Map from board positions to the team occupying that position.
Eq (HalmaBoard size) | |
Show (HalmaBoard size) |
getGrid :: HalmaBoard size -> HalmaGrid size Source
fromMap :: HalmaGrid size -> Map (Index (HalmaGrid size)) Team -> Maybe (HalmaBoard size) Source
Construct halma boards. Satisfies fromMap (getGrid board) (toMap board) = Just board
.
lookupHalmaBoard :: (Int, Int) -> HalmaBoard size -> Maybe Team Source
Lookup whether a position on the board is occupied, and
:: (Int, Int) | start position |
-> (Int, Int) | end position |
-> HalmaBoard size | |
-> Either String (HalmaBoard size) |
Move a piece on the halma board. This function does not check whether the move is valid according to the Halma rules.
initialBoard :: HalmaGrid size -> (Team -> Bool) -> HalmaBoard size Source