-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chess.hs
36 lines (30 loc) · 1015 Bytes
/
Chess.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{-# LANGUAGE UnicodeSyntax #-}
module Board
( initialBoardStr
) where
import Data.Char
import Control.Monad
b = ' '
w = '█'
type Ve = Int
type Ho = Int
type Board = [String]
initialBoardStr :: [String] -- c c c
initialBoardStr = ["♖♘♗♕♔♗♘♖","♙♙♙♙♙♙♙♙"]++ (take 4 $ repeat " ") ++ ["♟♟♟♟♟♟♟♟","♜♞♝♛♚♝♞♜"]
logicSquare :: Ho → Ve → Char → String
logicSquare h v ' '
| odd v = [if odd h then b else w]
| otherwise = [if odd h then w else b]
logicSquare h v cc
| odd v = [if odd h then cc else cc]
| otherwise = [if odd h then cc else cc]
squareFree c = [c,c,c]
squareWithFig = cmc
cmc c m = [c,m,c]
showLine:: Int → String → String
showLine nl ss= concatMap (\ (h,cc) -> logicSquare h (8-nl) cc) $ zip [1..] ss
printBoard :: Board → IO ()
printBoard bb = do
forM_ [0..7] (\i → do
putStrLn $ show (8- i) ++" "++ showLine i (bb !! i))
putStrLn $ " "++ ['a'..'h']-- concatMap (cmc b)