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

C++ Programming Assignment: Implement a tic-tac-toe program in which the user pl

ID: 3567756 • Letter: C

Question

C++ Programming Assignment:

Implement a tic-tac-toe program in which the user plays against an AI player. In this version, the board is a 5 by 5 grid and the players must get four of their letter in a line to win (i.e. four X's or four O's).

That means there will be 28 ways to win.

Also include an second version of the rules in which the player can win in the usual way plus 1) by marking the four corners or 2) by marking the squares in the middle of row 1, column 1, row 5 and column 5.

That means there will be 30 ways to win.

Provide a random mode, either 2, 4 or 6 squares will be filled in randomly as if both players have already moved 1, 2 or 3 times.

X will always move first, but either the human or the AI player will be X based on a virtual coin flip. After that, players alternate being X or O.

Your score will depend on how well the AI plays. It's possible to make an AI that is at least as smart as most human players.

This is a good problem to attack using an object-oriented approach. For example you could have a Board class and a Player class. Perhaps HumanPlayer and AIPlayer would be derived from Player and override the abstract method move().

Can someone give me the code for this C++ program?

Explanation / Answer

#include using namespace std; char square[10] = {'o','1','2','3','4','5','6','7','8','9'}; int checkwin(); void board(); int main() { int player = 1,i,choice; char mark; do { board(); player=(player%2)?1:2; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote