-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.hs
49 lines (36 loc) · 1.02 KB
/
Common.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
37
38
39
40
41
42
43
44
45
46
47
48
49
module Common where
import Data.Array (Array)
import Data.Map.Strict (Map)
import BiMap (BiMap)
type Solution = [Step]
data Step = Up | Down | Left | Right deriving (Eq, Show)
type Boards = Map Char Board
type FlippedPieces = Map Piece Flipped
data Input = Input
{ boards :: Boards
, initialState :: GameState
, requirements :: Requirements
, flipped :: FlippedPieces
}
type GameState = BiMap Piece Coord
type Requirements = Map Coord Requirement
data Requirement = RequirePlayer | RequireNonPlayer
data Board = Board
{ width :: Int
, cells :: Array Int Cell
}
data Flipped = FlippedHorizontal | FlippedVertical | FlippedBoth deriving (Eq, Ord, Show)
data Piece
= Player
| Block Int
| BoardPiece Char
| Clone Char Int
deriving (Eq, Ord, Show)
data Coord = Coord
{ board :: Char
, space :: (Int, Int)
}
deriving (Eq, Ord)
instance Show Coord where
show (Coord board (x, y)) = board : (show x ++ "," ++ show y)
data Cell = Wall | Space deriving (Eq, Ord, Show)