Sokoban - Parsing

Log in om je oplossingen te testen.
-- Locations in Sokoban are indicated with a coordinate. type X = Integer type Y = Integer type Coord = (X, Y) -- A world in sokoban contains a character, walls, movable crates and storage. data World = World { wMan :: Coord , wWalls :: [Coord] , wCrates :: [Coord] , wStorage :: [Coord] } deriving (Eq, Ord, Show) -- In the beginning, the world is empty, except for a man at (0, 0). emptyWorld = undefined -- Given a list of lines, create a world. In this string: -- - @ is the position of the man. -- - # is the position of a wall. -- - o is the position of a crate. -- - . is the position of a storage. -- -- For example, in: -- -- ^ -- y | ##### -- | # # -- | #o # -- | ### o## -- | # o o # -- | ### # ## # ###### -- | # # ## ##### ..# -- | # o o ..# -- | ##### ### #@## ..# -- | # ######### -- 0 | ####### -- -------------------> -- 0 x -- -- we have a man on (11, 2), crates on (5, 8) and (2, 3) and so on. makeWorld :: [String] -> World makeWorld = undefined -- Given a list of lines, where worlds are separated by empty lines, return a list of worlds. parseWorlds :: [String] -> [World] parseWorlds = undefined -- Given a filename, read and return a list of worlds. readWorlds :: String -> IO [World] readWorlds = undefined
Je kunt zo vaak indienen als je wenst. Er wordt enkel rekening gehouden met je laatst ingediende oplossing.
Log in om je oplossingen te testen.