Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data HalmaGrid
- sideLength :: HalmaGrid -> Int
- numberOfFields :: HalmaGrid -> Int
- data HalmaDirection
- oppositeDirection :: HalmaDirection -> HalmaDirection
- leftOf :: HalmaDirection -> HalmaDirection
- rowsInDirection :: HalmaDirection -> (Int, Int) -> Int
- corner :: HalmaGrid -> HalmaDirection -> (Int, Int)
- type Team = HalmaDirection
- startCorner :: HalmaGrid -> Team -> (Int, Int)
- endCorner :: HalmaGrid -> Team -> (Int, Int)
- startFields :: HalmaGrid -> Team -> [(Int, Int)]
- endFields :: HalmaGrid -> Team -> [(Int, Int)]
- data Piece = Piece {
- pieceTeam :: Team
- pieceNumber :: Word8
- data HalmaBoard
- getGrid :: HalmaBoard -> HalmaGrid
- toMap :: HalmaBoard -> Map (Int, Int) Piece
- fromMap :: HalmaGrid -> Map (Index HalmaGrid) Piece -> Maybe HalmaBoard
- lookupHalmaBoard :: (Int, Int) -> HalmaBoard -> Maybe Piece
- data Move = Move {}
- movePiece :: Move -> HalmaBoard -> Either String HalmaBoard
- initialBoard :: HalmaGrid -> (Team -> Bool) -> HalmaBoard
Documentation
sideLength :: HalmaGrid -> Int Source #
Numbers of fields on each straight edge of a star-shaped halma board of the given size.
numberOfFields :: HalmaGrid -> 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 -> 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 -> Team -> (Int, Int) Source #
The position of the corner field where a team starts.
Halma gaming piece
Piece | |
|
data HalmaBoard Source #
Map from board positions to the team occupying that position.
getGrid :: HalmaBoard -> HalmaGrid Source #
fromMap :: HalmaGrid -> Map (Index HalmaGrid) Piece -> Maybe HalmaBoard Source #
Construct halma boards. Satisfies
fromMap (getGrid board) (toMap board) = Just board
.
lookupHalmaBoard :: (Int, Int) -> HalmaBoard -> Maybe Piece Source #
Lookup whether a position on the board is occupied, and
A move of piece on a (Halma) board.
movePiece :: Move -> HalmaBoard -> Either String HalmaBoard Source #
Move a piece on the halma board. This function does not check whether the move is valid according to the Halma rules.
initialBoard :: HalmaGrid -> (Team -> Bool) -> HalmaBoard Source #