Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Map as Map
- data Coordinates = Coordinates { x :: Int, y :: Int }
- deriving (Eq, Show)
- instance Ord Coordinates where
- compare (Coordinates a b) (Coordinates c d) =
- if (a == c) then compare (b d)
- else compare(a c)
- data Color = White | Black
- instance Show Color where
- show White = "⚇"
- show Black = "⚉"
- data Board = Board (Map Coordinates Color)
- toString (Board board map) =
- iterate([Coordinates x y | x <- [1..19], y <- [1..19]])
- where
- iterate [element] = mapToCharacter element
- iterate (element:listOfCoordinates) = (mapToCharacter element) ++ iterate(listOfCoordinates)
- where
- mapToCharacter (Coordinates coordinates)=
- | (member coordinates map) = (lookup coordinates map)
- | otherwise = " "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement