Implementation of Connect 4 in Haskell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
src
test
.gitignore
ChangeLog.md
LICENSE
README.md
Setup.hs
package.yaml
stack.yaml

README.md

haskell-connect-4

Implementation of Connect 4 in Haskell

Application Spec

A board can be represented as such:

-- TypeDef for a columnn for more verbose code
type Column = Int

-- Enumeration for the 3 Colors
data Color = Empty | Red | Yellow

-- Board is just a 2 Dimensional List
data Board = Board [[Color]]

Functions Needed:

-- Returns Columns whose topmost row is still not filled
possibleMoves :: Board -> [Column]

-- Update the Board
makeMove :: Board -> Color -> Column -> Board

-- Check if a player of particular color has won
checkWin :: Board -> Color -> Bool

-- Calculate value of a particular board w.r.t to Color
valuation :: Board -> Color -> Int

-- Generate all possible next move positions
-- Uses possibleMoves and makeMove
moves :: Board -> Color -> [Board]