Must be written in C. Introduction Program an interactive simulation of the game
ID: 3647156 • Letter: M
Question
Must be written in C.Introduction
Program 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
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
}
Explanation / Answer
//This code is of simple TIC TAC TOE #include #include #include char matrix[3][3],block=' '; void one_player(); void two_player(); void player_1(); void player_2(); void computer(); void screen(); void move(); void print_matrix(); char win_check(); void main() { int row,column,option; clrscr(); printf(" This is a Tic Tac Toe Game "); printf(" Press 1: To play with the computer "); printf(" Press 2: To play against another player "); scanf(option; for(row=0;rowRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.