Tetris fitsTetromino

Log in om je oplossingen te testen.
import Graphics.Gloss import Graphics.Gloss.Interface.Pure.Game import Graphics.Gloss.Data.Color import Data.List type Direction = (Int,Int) data Tetromino = Tetromino Int (Int,Int) Color [Block] deriving (Eq,Show) data Block = Block (Int,Int) deriving (Eq,Show) data Board = Board [Block] deriving (Eq,Show) width :: Float width = 10 height :: Float height = 20 move :: Direction -> Block -> Block move (x,y) (Block (p,q)) = (Block (x+p,y+q)) freeBlock :: Board -> Block -> Bool freeBlock (Board l) b = not (b `elem` l) onBoard :: Block -> Bool onBoard (Block (x,y)) = and [(x>=0), (x < round width), (y>=0), (y< round height)] -- Check if a Tetromino fits in the board -- This means that if you move all the blocks of the tetromino to their position -- then: -- 1) The position of all the moved blocks in the Tetromino are free -- 2) All the positions of the moved blocks are within the boundaries -- Lookup "all" and "and" -- (* Difficulty 2 *) fitsTetromino :: Tetromino -> Board -> Bool fitsTetromino (Tetromino s p c blocks) board = undefined -- hint :: where aBlocks = (move p) <$> blocks
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.