-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Library implementing Halma rules -- @package halma @version 0.2.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 leftOf :: 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 MoveRestriction Allowed :: MoveRestriction Temporarily :: MoveRestriction Forbidden :: MoveRestriction data RuleOptions RuleOptions :: MoveRestriction -> MoveRestriction -> RuleOptions -- | May pieces be moved backwards? movingBackwards :: RuleOptions -> MoveRestriction -- | May pieces be moved into other star corners? invading :: RuleOptions -> MoveRestriction -- | 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 MoveRestriction instance Eq MoveRestriction 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' :: (V b ~ V2, N b ~ Double, Renderable (Path V2 Double) b) => HalmaGrid size -> ((Int, Int) -> Diagram b) -> QDiagram b V2 Double (Option (Last (Int, Int))) -- | Render the board using the given team colors. Supports querying for -- field positions. drawBoard :: (V b ~ V2, N b ~ Double, Renderable (Path V2 Double) b) => HalmaBoard size -> (Team -> Colour Double) -> QDiagram b V2 Double (Option (Last (Int, Int))) module Game.Halma.AI.Base type Move size = (Index (HalmaGrid size), Index (HalmaGrid size)) outcome :: HalmaBoard size -> Move size -> HalmaBoard size data Rating WinIn :: Int -> Rating Rating :: Float -> Rating LossIn :: Int -> Rating teamRating :: Team -> HalmaBoard size -> Rating allOwnPieces :: HalmaBoard size -> Team -> [Index (HalmaGrid size)] allLegalMoves :: RuleOptions -> HalmaBoard size -> Team -> [Move size] instance Show Rating instance Eq Rating instance Bounded Rating instance Ord Rating module Game.Halma.AI.Ignorant aiMove :: RuleOptions -> HalmaBoard size -> Team -> Move size module Game.Halma.AI.Competitive aiMove :: RuleOptions -> HalmaBoard size -> Perspective -> Move size