The game field
As usual, the first thing we have to do is defining and setting up the game field.
The idea: Just like Minesweeper game, the best solution is a two-dimensional array representing the six rows and seven columns. The first index determines the row, and the second index determines the column.
Then, any element can have these values:
- 0: an empty cell.
- 1: a cell occupied by player one.
- 2: a cell occupied by player two.
Look at this picture with a typical Connect Four situation:
On the left, array indexes for each cell. On the right, array values to represent board's situation.
When the game starts, all cells are empty, so the entire array must ...