-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A complicated turn-based game -- -- Players take turns in a labyrinth, competing with each other to pick a -- treasure and carry it out. They only know everyone's moves and -- responses, but do not see the map and must deduce it themselves. @package labyrinth @version 0.4.1.0 module Labyrinth.Map data Direction L :: Direction R :: Direction U :: Direction D :: Direction allDirections :: [Direction] opposite :: Direction -> Direction data CellType Land :: CellType Armory :: CellType Hospital :: CellType Pit :: Int -> CellType _pitNumber :: CellType -> Int River :: Direction -> CellType _riverDirection :: CellType -> Direction RiverDelta :: CellType riverDirection :: Traversal' CellType Direction pitNumber :: Traversal' CellType Int data Treasure TrueTreasure :: Treasure FakeTreasure :: Treasure data Cell Cell :: CellType -> Int -> Int -> [Treasure] -> Cell _ctype :: Cell -> CellType _cbullets :: Cell -> Int _cgrenades :: Cell -> Int _ctreasures :: Cell -> [Treasure] ctype :: Lens' Cell CellType ctreasures :: Lens' Cell [Treasure] cgrenades :: Lens' Cell Int cbullets :: Lens' Cell Int emptyCell :: CellType -> Cell data Wall NoWall :: Wall Wall :: Wall HardWall :: Wall data Position Pos :: Int -> Int -> Position pX :: Position -> Int pY :: Position -> Int advance :: Position -> Direction -> Position data Health Dead :: Health Wounded :: Health Healthy :: Health data Player Player :: Position -> Health -> Int -> Int -> Maybe Treasure -> Bool -> Player _position :: Player -> Position _phealth :: Player -> Health _pbullets :: Player -> Int _pgrenades :: Player -> Int _ptreasure :: Player -> Maybe Treasure _pjustShot :: Player -> Bool ptreasure :: Lens' Player (Maybe Treasure) position :: Lens' Player Position pjustShot :: Lens' Player Bool phealth :: Lens' Player Health pgrenades :: Lens' Player Int pbullets :: Lens' Player Int maxBullets :: Int maxGrenades :: Int initialPlayer :: Position -> Player type PlayerId = Int data Labyrinth Labyrinth :: Int -> Int -> Map Position Cell -> Map Position Wall -> Map Position Wall -> [Player] -> PlayerId -> Bool -> Bool -> Labyrinth _labWidth :: Labyrinth -> Int _labHeight :: Labyrinth -> Int _cells :: Labyrinth -> Map Position Cell _wallsH :: Labyrinth -> Map Position Wall _wallsV :: Labyrinth -> Map Position Wall _players :: Labyrinth -> [Player] _currentTurn :: Labyrinth -> PlayerId _positionsChosen :: Labyrinth -> Bool _gameEnded :: Labyrinth -> Bool wallsV :: Lens' Labyrinth (Map Position Wall) wallsH :: Lens' Labyrinth (Map Position Wall) positionsChosen :: Lens' Labyrinth Bool players :: Lens' Labyrinth [Player] labWidth :: Lens' Labyrinth Int labHeight :: Lens' Labyrinth Int gameEnded :: Lens' Labyrinth Bool currentTurn :: Lens' Labyrinth PlayerId cells :: Lens' Labyrinth (Map Position Cell) isInside :: Position -> Labyrinth -> Bool isOutside :: Position -> Labyrinth -> Bool wayOutside :: Position -> Labyrinth -> Bool outerPos :: Labyrinth -> [(Position, Direction)] playerCount :: Labyrinth -> Int posRectangle :: Int -> Int -> [Position] mapRectangle :: a -> Int -> Int -> Map Position a emptyLabyrinth :: Int -> Int -> Int -> Labyrinth cell :: Position -> Simple Lens Labyrinth Cell wallH :: Position -> Simple Lens Labyrinth Wall wallV :: Position -> Simple Lens Labyrinth Wall wall :: Position -> Direction -> Simple Lens Labyrinth Wall ix' :: (Functor f, Ixed (BazaarT p f (IxValue t) (IxValue t)) t, Indexable (Index t) p) => Index t -> Over p f t t (IxValue t) (IxValue t) player :: PlayerId -> Simple Lens Labyrinth Player currentPlayer :: Simple Lens Labyrinth Player allPositions :: Labyrinth -> [Position] allCells :: Labyrinth -> [Cell] allPosCells :: Labyrinth -> [(Position, Cell)] pitCount :: Labyrinth -> Int armories :: Labyrinth -> [Position] pits :: Labyrinth -> [Position] isPit :: CellType -> Bool pit :: Int -> Labyrinth -> Position instance Eq Labyrinth instance Eq Wall instance Eq Position instance Eq Health instance Enum Health instance Eq Player instance Show Position instance Ord Position instance Eq Treasure instance Eq Cell instance Eq Direction instance Eq CellType module Labyrinth.Move data MoveDirection Towards :: Direction -> MoveDirection Next :: MoveDirection type ActionCondition = String data Action Go :: MoveDirection -> Action _amdirection :: Action -> MoveDirection Shoot :: Direction -> Action _asdirection :: Action -> Direction Grenade :: Direction -> Action _agdirection :: Action -> Direction Surrender :: Action Conditional :: ActionCondition -> [Action] -> [Action] -> Action _acif :: Action -> ActionCondition _acthen :: Action -> [Action] _acelse :: Action -> [Action] asdirection :: Traversal' Action Direction amdirection :: Traversal' Action MoveDirection agdirection :: Traversal' Action Direction acthen :: Traversal' Action [Action] acif :: Traversal' Action ActionCondition acelse :: Traversal' Action [Action] goTowards :: Direction -> Action data QueryType BulletCount :: QueryType GrenadeCount :: QueryType PlayerHealth :: QueryType TreasureCarried :: QueryType data Move Move :: [Action] -> Move _mactions :: Move -> [Action] ChoosePosition :: Position -> Move _mcposition :: Move -> Position ReorderCell :: Position -> Move _mrposition :: Move -> Position Query :: [QueryType] -> Move _mqueries :: Move -> [QueryType] Say :: String -> Move _msstext :: Move -> String msstext :: Traversal' Move String mrposition :: Traversal' Move Position mqueries :: Traversal' Move [QueryType] mcposition :: Traversal' Move Position mactions :: Traversal' Move [Action] data CellTypeResult LandR :: CellTypeResult ArmoryR :: CellTypeResult HospitalR :: CellTypeResult PitR :: CellTypeResult RiverR :: CellTypeResult RiverDeltaR :: CellTypeResult ctResult :: CellType -> CellTypeResult data TreasureResult TurnedToAshesR :: TreasureResult TrueTreasureR :: TreasureResult data CellEvents CellEvents :: Int -> Int -> Int -> Maybe CellTypeResult -> CellEvents _foundBullets :: CellEvents -> Int _foundGrenades :: CellEvents -> Int _foundTreasures :: CellEvents -> Int _transportedTo :: CellEvents -> Maybe CellTypeResult transportedTo :: Lens' CellEvents (Maybe CellTypeResult) foundTreasures :: Lens' CellEvents Int foundGrenades :: Lens' CellEvents Int foundBullets :: Lens' CellEvents Int noEvents :: CellEvents data GoResult Went :: CellTypeResult -> CellEvents -> GoResult _onto :: GoResult -> CellTypeResult _wevents :: GoResult -> CellEvents WentOutside :: Maybe TreasureResult -> GoResult _treasureResult :: GoResult -> Maybe TreasureResult HitWall :: CellEvents -> GoResult _hitr :: GoResult -> CellEvents LostOutside :: GoResult InvalidMovement :: GoResult wevents :: Traversal' GoResult CellEvents treasureResult :: Traversal' GoResult (Maybe TreasureResult) onto :: Traversal' GoResult CellTypeResult hitr :: Traversal' GoResult CellEvents data ShootResult ShootOK :: ShootResult Scream :: ShootResult NoBullets :: ShootResult Forbidden :: ShootResult data GrenadeResult GrenadeOK :: GrenadeResult NoGrenades :: GrenadeResult data ChoosePositionResult ChosenOK :: ChoosePositionResult ChooseAgain :: ChoosePositionResult data ReorderCellResult ReorderOK :: CellTypeResult -> CellEvents -> ReorderCellResult _ronto :: ReorderCellResult -> CellTypeResult _revents :: ReorderCellResult -> CellEvents ReorderForbidden :: ReorderCellResult ronto :: Traversal' ReorderCellResult CellTypeResult revents :: Traversal' ReorderCellResult CellEvents data QueryResult BulletCountR :: Int -> QueryResult _qrbullets :: QueryResult -> Int GrenadeCountR :: Int -> QueryResult _qrgrenades :: QueryResult -> Int HealthR :: Health -> QueryResult _qrhealth :: QueryResult -> Health TreasureCarriedR :: Bool -> QueryResult _qrtreasure :: QueryResult -> Bool qrtreasure :: Traversal' QueryResult Bool qrhealth :: Traversal' QueryResult Health qrgrenades :: Traversal' QueryResult Int qrbullets :: Traversal' QueryResult Int data StartResult StartR :: PlayerId -> CellTypeResult -> CellEvents -> StartResult _splayer :: StartResult -> PlayerId _scell :: StartResult -> CellTypeResult _sevents :: StartResult -> CellEvents splayer :: Lens' StartResult PlayerId sevents :: Lens' StartResult CellEvents scell :: Lens' StartResult CellTypeResult data ActionResult GoR :: GoResult -> ActionResult ShootR :: ShootResult -> ActionResult GrenadeR :: GrenadeResult -> ActionResult Surrendered :: ActionResult WoundedAlert :: PlayerId -> Health -> ActionResult ChoosePositionR :: ChoosePositionResult -> ActionResult ReorderCellR :: ReorderCellResult -> ActionResult QueryR :: QueryResult -> ActionResult GameStarted :: [StartResult] -> ActionResult Draw :: ActionResult WrongTurn :: ActionResult InvalidMove :: ActionResult data MoveResult MoveRes :: [ActionResult] -> MoveResult instance Eq ActionResult instance Eq MoveResult instance Eq StartResult instance Eq QueryResult instance Eq ShootResult instance Show ShootResult instance Eq GrenadeResult instance Show GrenadeResult instance Eq ChoosePositionResult instance Eq ReorderCellResult instance Eq GoResult instance Eq CellTypeResult instance Eq TreasureResult instance Eq CellEvents instance Eq QueryType instance Eq Move instance Eq MoveDirection instance Eq Action module Labyrinth.Read parseMove :: String -> Either String Move stringResult :: String -> a -> Parser a spaces1 :: Parser () commaSpaces :: Parser () moveParser :: Parser Move emptyMove :: Parser Move choosePosition :: Parser Move reorderCell :: Parser Move positionParser :: Parser Position integer :: Parser Int actions :: Parser [Action] action :: Parser Action goAction :: Parser Action grenadeAction :: Parser Action shootAction :: Parser Action surrenderAction :: Parser Action direction :: Parser Direction conditionalPart :: Parser [Action] conditionalAction :: Parser Action queriesParser :: Parser Move queryParser :: Parser QueryType sayParser :: Parser Move module Labyrinth.Show data Definite Definite :: Definite Indefinite :: Definite pluralize :: (Eq a, Integral a, Show a) => Definite -> a -> String -> String showH :: Wall -> String showV :: Wall -> String showWallLine :: Labyrinth -> Int -> String showCellLine :: Labyrinth -> Int -> String showMap :: Labyrinth -> [String] showPlayers :: Labyrinth -> [String] showCurrentPlayer :: Labyrinth -> [String] showItems :: Labyrinth -> [String] showCellItems :: Cell -> String showStatus :: Labyrinth -> [String] sepShow :: Show a => Char -> [a] -> String commaSepShow :: Show a => [a] -> String showActResults :: [ActionResult] -> String instance Show MoveResult instance Show StartResult instance Show QueryResult instance Show ReorderCellResult instance Show ChoosePositionResult instance Show ActionResult instance Show CellEvents instance Show CellTypeResult instance Show Move instance Show QueryType instance Show Action instance Show MoveDirection instance Show Direction instance Show Labyrinth instance Show Player instance Show Health instance Show Treasure instance Show Cell instance Show CellType module Labyrinth.Common type LabState m a = StateT Labyrinth m a module Labyrinth.Reachability type PositionMap a = Map Position a type Connectivity = PositionMap [Position] type Distribution = PositionMap Double type Reachability = PositionMap Bool nextCell :: Position -> Reader Labyrinth Position reachable :: Position -> Reader Labyrinth [Position] connectivity :: Labyrinth -> Connectivity insertAppend :: Ord k => k -> v -> Map k [v] -> Map k [v] inverse :: (Ord a, Ord b) => Map a [b] -> Map b [a] foldConcat :: Monoid v => Map k [v] -> Map k v distribute :: (Ord k, Monoid v) => Map k [k] -> Map k v -> Map k v distributeN :: (Ord k, Monoid v) => Int -> Map k [k] -> Map k v -> Map k v distributeU :: (Ord k, Monoid v, Eq v) => Map k [k] -> Map k v -> Map k v normalize :: Fractional v => Map k v -> Map k v converge :: Int -> Labyrinth -> Distribution reachConverge :: Int -> Labyrinth -> Reachability reachConvergeU :: Labyrinth -> Reachability uniformBetween :: a -> [Position] -> PositionMap a armoriesDist :: Labyrinth -> PositionMap Any maxKeyBy :: Ord n => (k -> n) -> Map k a -> n showReach :: Reachability -> String showDist :: Distribution -> String showGrid :: (Maybe a -> String) -> PositionMap a -> String showGridLine :: (Maybe a -> String) -> PositionMap a -> Int -> String showGridPos :: (Maybe a -> String) -> PositionMap a -> Int -> Int -> String pad :: Int -> a -> [a] -> [a] module Labyrinth.Generate generateLabyrinth :: RandomGen g => Int -> Int -> Int -> g -> (Labyrinth, g) type LabGen g a = LabState (Rand g) a type CellPredicate m = Position -> LabState m Bool type CellPredicateR g = CellPredicate (Rand g) isTypeF :: Monad m => (CellType -> Bool) -> CellPredicate m isType :: Monad m => CellType -> CellPredicate m isLand :: Monad m => CellPredicate m perimeter :: Labyrinth -> Int area :: Labyrinth -> Int chooseRandomR :: RandomGen g => [a] -> LabGen g a randomDirection :: RandomGen g => LabGen g Direction allOf :: Monad m => [a -> m Bool] -> a -> m Bool cellIf :: RandomGen g => CellPredicateR g -> LabGen g Position putCell :: RandomGen g => CellType -> LabGen g Position putCellIf :: RandomGen g => CellPredicateR g -> CellType -> LabGen g Position neighbors :: Monad m => Position -> LabState m [Position] allNeighbors :: Monad m => CellPredicate m -> CellPredicate m isArmoryHospital :: Monad m => CellPredicate m putAH :: RandomGen g => CellType -> LabGen g Position putArmories :: RandomGen g => LabGen g () putHospitals :: RandomGen g => LabGen g () noTreasures :: Monad m => CellPredicate m putTreasure :: RandomGen g => Treasure -> LabGen g () hasWall :: Monad m => Direction -> CellPredicate m putExit :: RandomGen g => Wall -> LabGen g () putExits :: RandomGen g => LabGen g () putPits :: RandomGen g => LabGen g () foldTimes :: Monad m => a -> Int -> (a -> m a) -> m a foldTimes_ :: Monad m => a -> Int -> (a -> m a) -> m () putRivers :: RandomGen g => LabGen g () hasLandAround :: Monad m => CellPredicate m landCellThere :: Monad m => Position -> Direction -> LabState m Bool putTreasures :: RandomGen g => LabGen g () putWalls :: RandomGen g => LabGen g () goodReachability :: Monad m => LabState m Bool goodDistribution :: Monad m => LabState m Bool untilR :: MonadState v m => m Bool -> m a -> m () untilRN :: MonadState v m => Int -> m Bool -> m a -> m Bool generate :: RandomGen g => LabGen g () module Labyrinth.Action type ActionState a = LabState (State [ActionResult]) a putResult :: ActionResult -> ActionState () matchResult :: String -> ActionState Bool returnContinue :: [Action] -> ActionResult -> ActionState () alwaysContinue :: [Action] -> ActionState ActionResult -> ActionState () performMove :: PlayerId -> Move -> State Labyrinth MoveResult onlyWhenCurrent :: PlayerId -> ActionState () -> ActionState () onlyWhenChosen :: ActionState () -> ActionState () performMove' :: PlayerId -> Move -> ActionState () advancePlayer :: ActionState (Maybe PlayerId) isMovement :: Action -> Bool performActions :: [Action] -> ActionState () type AmmoLocation = Simple Lens Labyrinth Int transferAmmo :: Maybe Int -> AmmoLocation -> AmmoLocation -> ActionState Int transferAmmo_ :: Maybe Int -> AmmoLocation -> AmmoLocation -> ActionState () pickInside :: ActionState Int -> ActionState Int pickBullets :: ActionState Int pickGrenades :: ActionState Int pickTreasures :: ActionState Int nextPit :: Monad m => Int -> LabState m Int cellActions :: Bool -> ActionState (CellTypeResult, CellEvents) performMovement :: MoveDirection -> [Action] -> ActionState () performGrenade :: Direction -> ActionState ActionResult performShoot :: Direction -> ActionState ActionResult performShootFrom :: Position -> Direction -> ActionState ShootResult allPlayers :: Monad m => LabState m [PlayerId] alivePlayers :: Monad m => LabState m [PlayerId] playerAlive :: Monad m => PlayerId -> LabState m Bool playersAliveAt :: Monad m => Position -> LabState m [PlayerId] playerAt :: Monad m => Position -> PlayerId -> LabState m Bool isFallen :: Monad m => PlayerId -> LabState m Bool notFallen :: Monad m => PlayerId -> LabState m Bool dropBullets :: PlayerId -> ActionState () dropGrenades :: PlayerId -> ActionState () dropTreasure :: PlayerId -> ActionState () performSurrender :: ActionState () performConditional :: Action -> [Action] -> ActionState () performQueries :: PlayerId -> [QueryType] -> ActionState () performQuery :: PlayerId -> QueryType -> ActionState () module Labyrinth generateLabyrinth :: RandomGen g => Int -> Int -> Int -> g -> (Labyrinth, g) parseMove :: String -> Either String Move performMove :: PlayerId -> Move -> State Labyrinth MoveResult