-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.hs
More file actions
28 lines (20 loc) · 733 Bytes
/
test.hs
File metadata and controls
28 lines (20 loc) · 733 Bytes
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
type Column = [Piece]
f :: Column
f = [1,2,32,4]
data Board = Board{board::[Column],
width::Int,
height::Int}
data Piece = Null|Yellow|Red
data BoardState = BoardState{theBoard :: Board,
lastMove :: Piece,
numColumns :: Int,
numRows :: Int,
numToConnect :: Int}
dropPiece :: Column->Piece->Maybe Int
dropPiece [] i = Nothing
dropPiece (x:y:xs) i = if x==Null && not(y==Null)
dropPiece (x:y:xs) i = dropPiece (y:xs) (i)
makeMove :: BoardState -> Int -> Maybe BoardState
makeMove b i = if i ==0 then Nothing else Just b
checkWin :: BoardState -> Maybe Piece
checkWin = undefined