To code the two implementations of Connect 4, the game rules are transcribed as follows in the form of requirements. These requirements are the starting point for both the developments. We will go through the code with some explanations and compare both implementations at the end:
- The board is composed of seven columns and six rows; all positions are empty.
- Players introduce discs on the top of the columns. The introduced disc drops down the board if the column is empty. Future discs introduced in the same column will stack over the previous ones.
- It is a two-person game, so there is one color for each player. One player uses red (R) and the other one uses green (G). Players alternate turns, inserting one disc every time.