Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a C program that will simulate the Connect Four game. The game should ha

ID: 3868087 • Letter: D

Question

Develop a C program that will simulate the Connect Four game. The game should have two modes: player verses player and player verses computer. In the case of player verses computer, there should be three levels of difficulty: easy, intermediate and hard. In the easy level, the computer should just randomly pick places to drop the disc randomly. For the case of intermediate, the computer should attempt to block all horizontal and vertical attempts for victory. The hard level should make the computer defend vertical, horizontal and diagonally paths to victory, while aggressively trying to win the game. By playing offense, the computer should attempt to aggressively win the game. The Connect four grid should be displayed with "x" and "o" being used in place of the red and black disc. The grid display should be redrawn after each player takes a turn and should the current state of the game. Once, the game is over. The program should output who won the game or output that the game resulted in a tie.

Explanation / Answer

#include #include #include #define BOARD_ROWS 6 #define BOARD_COLS 7 void printBoard(char *board); int takeTurn(char *board, int player, const char*); int checkWin(char *board); int checkFour(char *board, int, int, int, int); int horizontalCheck(char *board); int verticalCheck(char *board); int diagonalCheck(char *board); int main(int argc, char *argv[]){ const char *PIECES = "XO"; char board[BOARD_ROWS * BOARD_COLS]; memset(board, ' ', BOARD_ROWS * BOARD_COLS); int turn, done = 0; for(turn = 0; turn