Requirements

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:

  1. The board is composed of seven columns and six rows; all positions are empty.
  2. 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.
  3. 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.
  4. We want feedback when either an event or an error occurs within the game. The output shows the status of the board after every move.
  5. When no more discs can be inserted, the game finishes, and it is considered a draw.
  6. If a player inserts a disc and connects more than three discs of his color in a straight vertical line, then that player wins.
  7. The same happens in a horizontal line direction.
  8. The same happens in a diagonal line direction.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.214.60