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 - Moving
Sign in to test your solution.
import Prelude hiding (Left, Right)
import Data.List (delete)
-- Locations in Sokoban are indicated with a coordinate.
-- ^
-- y |
-- +-->
-- 0 x
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)
-- The player can move in four directions
data Direction = Up | Down | Left | Right
-- Returns the coordinate next to the given coordinate in given direction.
nextPosition :: Direction -> Coord -> Coord
nextPosition = undefined
-- Getting information about the world
isMan, isWall, isStorage, isCrate :: Coord -> World -> Bool
isMan pos world = undefined
isWall pos world = undefined
isStorage pos world = undefined
isCrate pos world = undefined
-- Whether the position in the world can be moved into (is empty or unoccupied storage).
isEmpty :: Coord -> World -> Bool
isEmpty pos world = undefined
-- Move the player in given direction if the player can move in this direction.
-- A player can move in a direction iff the cell in this direction:
-- - is empty; or
-- - is a storage cell; or
-- - contains a crate and the cell behind it is empty; or
-- - contains a crate and the cell behind it is a storage cell.
move :: Direction -> World -> World
move dir world = 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.