Create a batch file tic tac toe game written in C code. This code should be able to run through an emulator.
CODE
#include <stdio.h> //function prototypes void displayBoard(); int verifySelection(int,int); void checkForWin(); //global variables char board[ 8 ], whoWon = ' '; int currentPlayer = 0; //begin main function int main() { int i, square; for(i = 0; i < 9; i++) board[ i ] = ' '; displayBoard(); while(whoWon == ' ') { printf("\n%c\n", whoWon); if(currentPlayer == 0 || currentPlayer == 1) { printf("\nPlayer X\n"); printf("Enter an available square (1..9)"); scanf("%d", &square); if(verifySelection(square, currentPlayer) == 1) { currentPlayer = 1; } else { currentPlayer = 2; } } else { printf("\nPlayer 0\n"); printf("Enter an available square (1..9)"); scanf("%d", &square); if(verifySelection(square, currentPlayer) == 1) { currentPlayer = 2; } else { currentPlayer = 1; } } displayBoard(); checkForWin(); }//end for loop return (0); }; void displayBoard() { system("cls"); printf("\t|\t|\n"); printf("%c\t|%c\t|%c\n", board[0], board[1], board[2]); printf("--------|-------|--------\n"); printf("\t|\t|\n"); printf("%c\t|%c\t|%c\n", board[3], board[4], board[5]); printf("--------|-------|--------\n"); printf("%c\t|%c\t|%c\n", board[6], board[7], board[8]); printf("\t|\t|\n"); }; int verifySelection(int square, int player) { if((player == 0 || player == 1) && board[square-1] == ' ') { board[ square - 1 ] = 'X'; return 0; } else if(board[square-1] == ' ' && player == 2) { board[square-1] = 'O'; return 0; } else return 1; } void checkForWin() { int i, contor = 0; if(board[ 0 ] == 'X' && board[ 1 ] == 'X' && board[ 2 ] == 'X') { whoWon = 'X'; } else if(board[ 3 ] == 'X' && board[ 4 ] == 'X' && board[ 5 ] == 'X') { whoWon = 'X'; } else if(board[ 6 ] == 'X' && board[ 7 ] == 'X' && board[ 8 ] == 'X') { whoWon = 'X'; } else if(board[ 0 ] == 'X' && board[ 3 ] == 'X' && board[ 6 ] == 'X') { whoWon = 'X'; } else if(board[ 1 ] == 'X' && board[ 4 ] == 'X' && board[ 7 ] == 'X') { whoWon = 'X'; } else if(board[ 2 ] == 'X' && board[ 5 ] == 'X' && board[ 8 ] == 'X') { whoWon = 'X'; } else if(board[ 0 ] == 'O' && board[ 1 ] == 'O' && board[ 2 ] == 'O') { whoWon = 'O'; } else if(board[ 3 ] == 'O' && board[ 4 ] == 'O' && board[ 5 ] == 'O') { whoWon = 'O'; } else if(board[ 6 ] == 'O' && board[ 7 ] == 'O' && board[ 8 ] == 'O') { whoWon = 'O'; } else if(board[ 0 ] == 'O' && board[ 3 ] == 'O' && board[ 6 ] == 'O') { whoWon = 'O'; } else if(board[ 1 ] == 'O' && board[ 4 ] == 'O' && board[ 7 ] == 'O') { whoWon = 'O'; } else if(board[ 2 ] == 'O' && board[ 5 ] == 'O' && board[ 8 ] == 'O') { whoWon = 'O'; } //for diagonals if(board[ 0 ] == 'X' && board[ 4 ] == 'X' && board[ 8 ] == 'X') { whoWon = 'X'; } else if(board[ 2 ] == 'X' && board[ 4 ] == 'X' && board[ 6 ] == 'X') { whoWon = 'X'; } if(board[ 0 ] == 'O' && board[ 4 ] == 'O' && board[ 8 ] == 'O') { whoWon = 'O'; } else if(board[ 2 ] == 'O' && board[ 4 ] == 'O' && board[ 6 ] == 'O') { whoWon = 'O'; } if(whoWon == 'X') { printf("\nX WON\n"); return; } if(whoWon == 'O') { printf("\nO WON\n"); return; } for(i = 0; i < 9; i++) if(board[i] != ' ') contor++; if(contor == 9) { whoWon = 'C'; printf("\nCAT GAME\n"); return; } }
Create a batch file tic tac toe game written in C code. This code should be...
Create a very basic tic tac toe game written in C code. This C code should be able to create a GBA file from using devkit to run in visual boy advance.
PYTHON Exercise 2. Tic-Tac-Toe In this exercise we are going to create a Tic-Tac-Toe game. 1. Create the data structure – Nine slots that can each contain an X, an O, or a blank. – To represent the board with a dictionary, you can assign each slot a string-value key. – String values in the key-value pair to represent what’s in each slot on the board: ■ 'X' ■ 'O' ■ ‘ ‘ 2. Create a function to print the...
(Game: play a tic-tac-toe game) In a game of tic-tac-toe, two players take turns marking an available cell in a grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the cells in the grid have been filled with tokens and neither player has achieved a win. Create...
(Tic-Tac-Toe) Create a class Tic-Tac-Toe that will enable you to write a program to play Tic-Tac-Toe. The class contains a private 3-by-3 two-dimensional array. Use an enumeration to represent the value in each cell of the array. The enumeration’s constants should be named X, O and EMPTY (for a position that does not contain an X or an O). The constructor should initialize the board elements to EMPTY. Allow two human players. Wherever the first player moves, place an X...
1. Use Turtle Graphics to create a tic tac toe game in Python. Write a Python program that allows for one player vs computer to play tic tac toe game, without using turtle.turtle
tic-tac-toe game. Add functionality to the program so when the button is clicked for the AI to take a turn, a heuristic is applied for each of the possible moves, a possible move is selected and the game state and GUI are properly updated. Once complete, the program should be able to play a single game of tic-tac-toe with the user. C#
what’s the code of game Tic-tac-toe by using the Alpha Beta Turing algorithm ? The code in language JavaScript?
Write a Tic-Tac-Toe game in C language. Your project must contain at least one header file, two C source files.
So I have to make a tic tac toe game in C++. and the problem is asking me to design, implement and test classea to reperesnt the game board(3x3 sqaure), and the x and o markers. the problem is also asking me to provide suitable observor and mutator methods for modifying the game board and displaying game status. I have to use clases to create a game that prompts for player x and player O to place markers at specified...
18. Tic-Tac-Toe Game rite a program that allows two players to play a game of tic-tac-toe. Use dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following: Write . Displays the contents of the board array. . Allows player 1 to select a location on the board for an X. The program should ask the...