1 & 2D Arrays, Strings, Functions Using Call-By-Value And Call-By-Reference Parameters - Game Case Study - Computer Science Assignment Help

Download Solution Order New Solution
Assignment Task -                 
 

 

1.0 Your task 

Tic-Tac-Toe is a board game that is very popular with kids. Typically, this game is played using a 3 X 3  board. Each player chooses a symbol – usually an ‘X’ or an ‘O’ and tries to be the first one to place 3 of his / her symbol in a straight line. This straight-line could be horizontal (straight across a row), vertical  (straight across a column), diagonal from the left corner to the right corner, or diagonal from the right corner to the left. You may refer to learn more about the game.  

In this assignment, given the main and one function definition (see givenA2.c), you are asked to write several other functions that make up this game. Prototypes and description of these functions is given in the following pages. /!\ Note that an empty cell is represented by a ‘?’ on the board. The game is played between a player and the computer. /!\ Note that in this game (1) the player always goes first and (2) the Player’s symbol is ‘X’ and the computer’s symbol is ‘O’. It is important to understand the details of each function - this will guide you in coding the others.  

Important tips: 

1. You may want to start by writing code for functions createInitialBoard and printCurrentBoard.  These are the easiest to implement. Function printCurrentBoard will help to troubleshoot the rest of  the assignment. 

2. Read and understand the code (main and one function definition) given in givenA2.c – they will help you get started on the assignment. All function prototypes and other required global constants are defined in givenA2.h (make sure you include it in your code). 

3. Start the assignment early. 

 

1. Details on Function computerPlaysToWin 

int computerPlaysToWin (char board[N][N], int * cRow, int * cool); 

 In order to win, it checks whether the board has 2 ‘O’ in any of the rows, columns, or diagonals. Some example scenarios below lead the computer to win: 

olumns or the  diagonals

One possible way of accomplishing this is discussed next: 

a. assign a score of 4 to symbol ‘O’ on the board and 1 to symbol ‘X’ 

b. If the total score for symbol ‘O’ in any of the rows or columns or diagonals is 8 (implying  that 2 cells in that row/column / diagonal have symbol ‘O’), then 

 If the third cell in that row /column / diagonal is unoccupied (i.e. it has a ‘?’), 

 

 

2. Details on computerPlaysRandom 

If the computer cannot win, then it plays a random move (Function  

computerPlaysRandom) 

void computerPlaysRandom (int * , int * ); 

- It randomly picks a row and column for a cell. If the cell it picks is occupied (by ‘O’ or  ‘X’), then it must repeat the process until it finds an empty cell (indicated by a ‘?’).

 

- line numbers are given only for convenience –

 

- line numbers are given only for convenience –

 


This Computer Science Assignment has been solved by our Computer Science Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Be it a used or new solution, the quality of the work submitted by our assignment Experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.