Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module T where
- import Data.List
- data Cell a = Blue a | Yellow a | Green a | Red a | Explode a
- type Board = [Cell (Int,Int)]
- getX :: Cell (Int,Int) -> Int
- getX _ (x,_) = x
- getY :: Cell (Int,Int) -> Int
- getY _ (_,y) = y
- distance :: (Int,Int) -> Cell (Int,Int) -> Maybe Int
- distance (x,y) _ (x2,y2)
- | x == x2 = Just y2 - y
- | y == y2 = Just x2 - x
- | otherwise = Nothing
- cellEvolve :: Cell (Int,Int) -> Cell (Int,Int)
- cellEvolve Blue (x,y) = Yellow (x,y)
- cellEvolve Yellow (x,y) = Green (x,y)
- cellEvolve Green (x,y) = Red (x,y)
- cellEvolve Red (x,y) = Explode (x,y)
- explode :: (Int,Int) -> Board -> Board
- explode (x,y) b1 =
- let matchingRow
- cellFuture :: (Int, Int) -> (Cell (Int,Int) -> Int) -> Cell (Int,Int) -> Maybe Int
- cellFuture (x,y) f c
- | (f c == f x) = distance (x,y) c
- | otherwise = Nothing
- manageExplode :: Board -> Board
- manageExplode b1 =
Add Comment
Please, Sign In to add comment