Opgepast! Het lijkt erop dat je Dodona gebruikt binnen een andere webpagina waardoor mogelijk niet alles goed werkt. Laat dit weten aan de lesgever zodat die het probleem kan oplossen door een instelling in de leeromgeving aan te passen. Ondertussen kan je op deze link klikken om Dodona te openen in een nieuw venster.
Opgepast! De pagina kon niet volledig ingeladen worden, waarschijnlijk door een netwerkprobleem. Het kan zijn dat niet alle functionaliteit beschikbaar is. Probeer de pagina te verversen.
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