------------------------------------------------------------------------------
CS429 - Functional Programming

Final Project Report : Implementing a logical puzzle board game in Haskell

Team Members:
   Bill Javorcik
   Bratin Saha
   Kishnan Nedungadi
------------------------------------------------------------------------------


Klocki: A logical puzzle board game

The game is played on the board of rectangular shape containing movable and
immovable pieces. The purpose of the game is to move one of the movable
pieces (the Main piece) to the predefined target position.

Individual pieces come in various shapes and usually occupy most of the board
space, leaving only limited space for moving pieces around. The pieces can only
be shifted, they do not rotate or slide over other pieces.

To distinguish the pieces, they are painted using different colors according
to their type:
Main     Red       The main piece that needs to be moved to the target position
Target   DarkGray  The target piece, onto which the Main piece should be moved
Regular  Yellow    A regular, moveable piece on the board
Static   Blue      An immovable piece (border)
Opening  Cyan      The piece the covers the opening and can be removed only
                   when the Main piece is next to it

When the game starts, the program asks for the name of file to read the
board definition from. The definition is read in using the Haskell read
function, since the board (ReadBoard) has been made an instance of the
read class.

The definition and internal representation is such that it allows any
board to be represented. There are no restrictions on number of pieces
or their shapes or sizes.


Board description file:

The board is read in as a Haskell data type ReadBoard using the read function.
The definition of ReadBoard and data types is contains is as follows:

type Dim   = Int
type Dims  = (Dim, Dim)   -- (width,height)
type Coord = (Int, Int)	  -- (x, y)

type PieceBit    = Int
type PieceBitmap = [PieceBit]
type VertexList  = [Coord]
data PieceType = Main | Target | Regular | Static | Opening | Empty
data PieceShape = PieceShape Dims PieceBitmap VertexList
data Piece = Piece PieceType Coord PieceShape

data ReadBoard = ReadBoard Dims [Piece]

Types Dim, Dims and Coord are used to describe a single dimension,
a pair of dimensions and a pair of coordinates.

All coordinates and indexes start at zero.

The piece description consists of piece type, coordinates of the piece on
the board and the piece shape. The piece shape consists of the dimensions
of the bounding rectangle, bitmap information describing the piece itself
and a list of vertices describing the piece as a polygon.

Example:

A regular piece consisting of single square at position (1,2) will be
described as follows:
Piece Regular (1,2) (PieceShape (1,1) [0] [(0,0),(1,0),(1,1),(0,1)])
The main piece in shape of a letter T whose upper left corner is at position
(6,9) will be described as follows:
Piece Main (6,9) (PieceShape (3,4) [0,1,2,4,7,10] 
                 [(0,0),(0,3),(1,3),(1,2),(4,2),(4,1),(1,1),(0,1)])
A piece can be of any shape, it is possible to leave empty squares inside the
piece.

The board itself is described by its dimensions and a list of pieces.
It is not necessary to add the outside border of the board, the program
does it automatically.


The board layouts provided with the game are:
daisy
violet
poppy
pansy
snowdrop
forget-me-not



Technical information about the implementation:

The program consists of the following modules:
game.hs
board.hs
input.hs
output.hs
solver.hs

board.hs:
To achieve speed, the board information is stored in a mutable array.

