halma-0.2.0.0: Library implementing Halma rules

Game.Halma.Board

Synopsis

# Documentation

Constructors

 S L

data HalmaGrid :: HalmaGridSize -> * where Source

Constructors

 SmallGrid :: HalmaGrid S LargeGrid :: HalmaGrid L

Instances

 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.

The six corners of a star-shaped halma board.

Constructors

 North Northeast Southeast South Southwest Northwest

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.

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.

startFields :: HalmaGrid size -> Team -> [(Int, Int)] Source

The start positions of a team's pieces.

endFields :: HalmaGrid size -> Team -> [(Int, Int)] Source

The end zone of the given team.

data HalmaBoard size Source

Map from board positions to the team occupying that position.

Instances

 Eq (HalmaBoard size) Show (HalmaBoard size)

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

Arguments

 :: (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.