Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

SPU CSC 1230 Winter 2021 Final Project Summary Develop a Tic Tac Toe game that will match a player against the computer. Requirements Use a typical 3 x 3 board. The vertical columns must be labeled A,...

1 answer below »
SPU CSC 1230 Winter 2021 Final Project

Summary
Develop a Tic Tac Toe game that will match a player against the computer.
Requirements
Use a typical 3 x 3 board. The vertical columns must be labeled A, B, C. The horizontal rows must be
labeled 1, 2, 3. For Example:
A B C
1
2
3

Must do’s:
− Use User-Defined Functions.
− Use Branching.
− Use Loops.
− Use String functions.
− Randomly determine who will move first, the human or computer.
− Assign O to the computer and X to the Human player.
− Ask the user to select their move using the horizontal and vertical position. For example: A1 for the
upper left square, or B2 for the center square.
− After each move, redraw the board with the X’s and O’s in the right positions.
− After each game, ask the user if they want to play again. If they do, start the game again.
Must not do’s:
− Don’t use User Classes or Objects
− Don’t use images
− Don’t copy a solution, even if you can find it, on the Internet or any other source. It will be
discovered and you will receive zero points for the project.
Part 1 – Design the program. (30% of Total)
− Describe the principle functions you will be using, their purpose, parameters, and return type.
− Create a Process Flow Diagram that describes how control flows through your program.
Part 2 – Develop and test the code. (70% of Total)
− This seems self explanatory.
SPU CSC 1230 Winter 2021 Final Project

Game Setup
At the beginning of a game, clear all X’s and O’s from the board and randomly determine whether the
computer or the player will select first.
Game Play.
A player wins when they put their market on three consecutive squares, either horizontally, vertically, or
diagonally. If all squares have filled with markers and neither player won, declare a tie and complete the
game.
After each game, check with the human player to see if they want to play again.
Part 1 Ru
ic:
Total points available for the Part 1: 69
Points are allocated as follows:
− Function List and Signatures 50%
− Process Flow Diagram 50%
Part 2 Ru
ic:
Total points available for the Part 2: 161
Points are allocated as follows:
− Compilable Code 15%
− Implements Solution 20%
− Gameplay 15%
− Uses Functions 10%
− Uses Loops 10%
− Uses Branching 10%
− Uses String Functions 10%
− Commented Code 10%
Deliverables:
− A single compressed (either .zip or .rar) file folder containing the source code files only. Don’t just
zip the whole project folder. Please label the folder in this format: [Last Name]+”_final.zip (or .rar)”
For example: vickers_final.zip
− Submit the file on Canvas
Answered 2 days After Mar 12, 2021

Solution

Aditya answered on Mar 15 2021
137 Votes
#include #include using namespace std;
void intiliseBoard(char board[3][3]);
void displayBoard(char board[3][3]);
ool isVaildMove(string move);
ool isCellEmpty(char board[3][3], string move);
void move(char board[3][3], string move, char value);
ool isComputerWinner(char board[3][3]);
ool isHumanWinner(char board[3][3]);
string generateComputerMove();
string getUserMove();
void userMove(char board[3][3]);
void computerMove(char board[3][3]);
void playGame();
ool isDraw(char borad[3][3]);
int main()
{
string repeat = "N";
do
{
playGame();
cout
"To play again enter Y: ";
cin
repeat;
} while (repeat == "Y");

}
void intiliseBoard(char board[3][3])
this function is used to intialise the board
{
for (int i = 0; i < 3;i++)
{
for (int j = 0; j < 3;j++)
{
board[i][j] = ' ';
}
}
}
void displayBoard(char board[3][3])
this function is used to display the board
{
cout
"Displaying Board"
endl;
for (int i = 0; i < 3;i++)
{
for (int j = 0; j < 3;j++)
{
cout
oard[i][j]
" ";
}
cout
endl;
}
}
ool isVaildMove(string move)
check if the given move in a board is valid
{
char column = move[0];
char row = move[1];
if (column != 'A' && column != 'B' && column != 'C')
{
return false;
}
if (row != '1' && row != '2' && row != '3')
{
return false;
}
return true;
}
ool isCellEmpty(char board[3][3], string move)
check if the given move in a cell is empty or not
{
char column = move[0];
char row = move[1];
int r = 0;
int c = 0;
switch (row)
{
case '1':
{
r = 0;

eak;
}
case '2':
{
r = 1;

eak;
}
case '3':
{
r = 2;

eak;
}
}
switch (column)
{
case 'A':
{
c = 0;

eak;
}
case 'B':
{
c = 1;

eak;
}
case 'C':
{
c = 2;

eak;
}
}
if (board[r][c]== ' ')
{
return true;
}
return false;
}
void move(char board[3][3], string move, char value)
this function is used to move a step in a board
{
char column = move[0];
char row = move[1];
int r = 0;
int c = 0;
switch (row)
{
case '1':
{
r = 0;

eak;
}
case '2':
{
r = 1;

eak;
}
case '3':
{
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here