Givens:
- Connect 4 game board code
- Rules of connect 4
- First to get 4 across, down, diagonally wins
- Players take turns
- Player is red, computer is black
Assumptions:
- Player knows how to play connect 4
Algorithm:
- Load the connect 4 set up.
- Count the number of cycles that the game has gone through.
- Allow the player to make a move. If the player tries to put a piece in an full column, doesn’t make a choice, or is out of bounds, go to step 4. If it is a valid move, go to step 5.
- This yields an error. Prompt the user to return to step 3.
- The player has placed the piece. The computer places a piece automatically to block the row of the player’s piece.
- This turn has been completed. If the player both the player and the computer have less than four in a row, return to step 2. If the board is full, go to step 7. If the player has four in a row, go to step 8. If the computer has four in a row, go to step 9.
- The game is tied and finished.
- The player has won!
- The computer has won.