Warning! It seems that you are using Dodona within another webpage, so not everything may work properly. Let your teacher know so that he can solve the problem by adjusting a setting in the learning environment. In the meantime, you can click this link to open Dodona in a new window.
Sokoban - Parsing
Sign in to test your solution.
-- 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
You can submit as many times as you like. Only your latest submission will be taken into account.
Sign in to test your solution.