Sokoban - Moving

Log in om je oplossingen te testen.
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
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.