From: Moi on
On Fri, 25 Dec 2009 08:23:20 -0800, mandar wrote:

> I have programed a connect four in java using GUI. I have already coded
> a snippet that uses 2-d array(My board representation) for evaluation
> the winning conditions.
>
> i have declared a 2d array named board[width][height], where width is 7
> and height is 6. and initialized all the elements to 0.
>

2d arrays is always a bad choice in board game programming, IMHO.

For small boards like this it is easy to use bit maps.
Also: the set of valid moves does not change very much after
a move. It seems easiest to keep it updated after each move.
(since there are only 7 possible moves, this will fit in a char bitmask)

An even better way would be to enumerate *all the possible* winning lines
and keep a bitmap of these for both black and white. (remove it from the
bitmap once the line has been broken by the other color)

HTH,
AvK