Introduction In this assignment, you will be programming an interactive simulati
ID: 3656635 • Letter: I
Question
Introduction
In this assignment, you will be programming an interactive simulation of the game Tic-Tac-Toe. However, unlike regular Tic-Tac-Toe, you will have to write your program in a robust manner so a board of arbitrary size can be played on and a player need an arbitrary number of consecutive pieces in a row to win. When your program is done, you should have a final product that would allow two players sitting at the same computer to give moves to the program so they can play the game against one another.
NOTE: Must make sure the program compiles on MS Visual Studio 2008 .NET with no errors
YOU ARE NOT ALLOWED TO USE THE cin OR cout COMMANDS BECAUSE THEY ARE C++!
Assignment
To provide some structure in this project, the following shell is provided. You do not have to use this exact shell in your project, but the desired structure of the program and the functions involved is best explained by looking at some starting code:
// INCLUDES
#include <stdio.h>
// DEFINES
#ifndef __TRUE_FALSE__
#define __TRUE_FALSE__
#define TRUE 1
#define FALSE 0
#endif
// ROWS and COLS must be between 1 and 9
#define ROWS 7
#define COLS 7
// MARKER CODES
#define MARKONE 'X'
#define MARKTWO 'O'
#define BLANK ' '
// VICTORY CODES
#define NOWIN 0
#define MARKONEVICTORY 1
#define MARKTWOVICTORY 2
#define TIE 3
#define ERROR 4
#define EPIC_FAIL 5
// GAME PARAMETER CODES
#define CONSECUTIVE_MARKS_REQUIRED 3
// PROTOTYPES
void InitializeBoard(char[ROWS][COLS]);
void DisplayBoard(char[ROWS][COLS]);
int PlayerMove(int, int, char[ROWS][COLS], char);
int VictoryCheck(int, char[ROWS][COLS]);
void DisplayVictoryMessage(int);
// MAIN
int main() {
// THE CORE LOGIC FOR YOUR GAME GOES HERE
// exit program
return 0;
}
// FUNCTION IMPLEMENTATIONS
void InitializeBoard(char board[ROWS][COLS]) {
// YOUR IMPLEMENTATION GOES HERE
}
void DisplayBoard(char board[ROWS][COLS]) {
// YOUR IMPLEMENTATION GOES HERE
}
int PlayerMove(int row, int col, char board[ROWS][COLS], char symbol) {
// YOUR IMPLEMENTATION GOES HERE
}
int VictoryCheck(int winRequirement, char board[ROWS][COLS]) {
// YOUR IMPLEMENTATION GOES HERE
}
void DisplayVictoryMessage(int victoryCode) {
// AN IMPLEMENTATION FOR THIS FUNCTION WAS PROVIDED IN A WEEKLY ASSIGNMENT
}
Minimally, the following functions should exist in your program. You may add additional functions if you desire, but please make sure the provided functions exist in some form within your program.
void InitializeBoard(char[ROWS][COLS]);
FUNCTION EXPLANATION
This function should initialize the board. The board is represented in the game as a two-dimensional array. The dimensions of the board in rows and columns are provided in the provided preprocessor directive statements. When the board is initialized, all spaces within the board array should be set to the blank space. The function returns no value.
void DisplayBoard(char[ROWS][COLS]);
FUNCTION EXPLANATION
This function should display the board in an organized, intuitive fashion. Details on the way this function works can be found in the weekly assignments. The function takes a single two-dimensional array as its only argument. That array should contain information about the pieces that are on the board at specific coordinates. Please note that this is the only function that draws things on the screen. Your main() may contain some prompting code to get player moves, but this function should be doing most of the drawing in the program. It return no value.
int PlayerMove(int, int, char[ROWS][COLS], char);
FUNCTION EXPLANATION
This function is called when the core logic of your program attempts to put a player marker on the board. The first two arguments represent the row and column on the board where the user wishes to place a piece. Please note that in your interface, the upper-left corner of the board should be coordinate (1, 1). However, within the board array, the upper-left space would be coordinate (0, 0). Make sure the PlayerMove() function performs the appropriate offset calculation to ensure the piece is actually going where it belongs. The third argument is a two-dimensional array representing the board. The fourth argument is a character that represents the symbol that the player wants to place on the board. Ideally, you should use X and O. The ASCII codes used to represent these markers are set in the preprocessor directive within your program. The function should return TRUE is the move was successfully placed on the board. The function should return FALSE if the player attempts to make a move that is off of the board or make a move that collides with a piece that already exists on the board. Optionally, you can print a small error message on the screen if one of these error conditions occurs. Make sure the printed error message results in an intuitive user interface once the program is complete.
int VictoryCheck(int, char[ROWS][COLS]);
FUNCTION EXPLANATION
This function
Explanation / Answer
//some function definitions...others said to refer to your weekly assignment for details... void InitializeBoard(char board[ROWS][COLS]) { /*This function should initialize the board. The board is represented in the game as a two-dimensional array. The dimensions of the board in rows and columns are provided in the provided preprocessor directive statements. When the board is initialized, all spaces within the board array should be set to the blank space. The function returns no value.*/ int i,j; for(i=0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.