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.
#include <stdio.h>
#include <conio.h>
char square[10] = { 'o', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
int checkwin();
void board();
int main()
{
int player = 1, i, choice;
char mark;
do
{
board();
player = (player % 2) ? 1 : 2;
printf("Player %d, enter a number: ", player);
scanf("%d", &choice);
mark = (player == 1) ? 'X' : 'O';
if (choice == 1 && square[1] == '1')
square[1] = mark;
else if (choice == 2 && square[2] == '2')
square[2] = mark;
else if (choice == 3 && square[3] == '3')
square[3] = mark;
else if (choice == 4 && square[4] == '4')
square[4] = mark;
else if (choice == 5 && square[5] == '5')
square[5] = mark;
else if (choice == 6 && square[6] == '6')
square[6] = mark;
else if (choice == 7 && square[7] == '7')
square[7] = mark;
else if (choice == 8 && square[8] == '8')
square[8] = mark;
else if (choice == 9 && square[9] == '9')
square[9] = mark;
else
{
printf("Invalid move ");
player--;
getch();
}
i = checkwin();
player++;
}while (i == - 1);
board();
if (i == 1)
printf("==>\aPlayer %d win ", --player);
else
printf("==>\aGame draw");
getch();
return 0;
}
/*********************************************
FUNCTION TO RETURN GAME STATUS
1 FOR GAME IS OVER WITH RESULT
-1 FOR GAME IS IN PROGRESS
O GAME IS OVER AND NO RESULT
**********************************************/
int checkwin()
{
if (square[1] == square[2] && square[2] == square[3])
return 1;
else if (square[4] == square[5] && square[5] ==
square[6])
return 1;
else if (square[7] == square[8] && square[8] ==
square[9])
return 1;
else if (square[1] == square[4] && square[4] ==
square[7])
return 1;
else if (square[2] == square[5] && square[5] ==
square[8])
return 1;
else if (square[3] == square[6] && square[6] ==
square[9])
return 1;
else if (square[1] == square[5] && square[5] ==
square[9])
return 1;
else if (square[3] == square[5] && square[5] ==
square[7])
return 1;
else if (square[1] != '1' && square[2] != '2' &&
square[3] != '3' &&
square[4] != '4' && square[5] != '5' && square[6]
!= '6' && square[7]
!= '7' && square[8] != '8' && square[9] != '9')
return 0;
else
return - 1;
}
/*******************************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
********************************************************************/
void board()
{
system("cls");
printf("\n\n\tTic Tac Toe\n\n");
printf("Player 1 (X) - Player 2 (O)\n\n\n");
printf(" | | \n");
printf(" %c | %c | %c \n", square[1], square[2], square[3]);
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" %c | %c | %c \n", square[4], square[5], square[6]);
printf("_____|_____|_____\n");
printf(" | | \n");
printf(" %c | %c | %c \n", square[7], square[8], square[9]);
printf(" | | \n\n");
}
/*******************************************************************
END OF PROJECT
********************************************************************/
Create a very basic tic tac toe game written in C code. This C code should...
Create a batch file tic tac toe game written in C code. This code should be able to run through an emulator.
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...
How to write a (c++ program) tic tac toe code where its the computer against a human. and the computer always wins. a basic c++ code program using gaming theory arrays <stdio.h> computer plays tic tac toe against a user. computer always when or the game is a draw.
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
(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...
what’s the code of game Tic-tac-toe by using the Alpha Beta Turing algorithm ? The code in language JavaScript?
(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...
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#
Please do this in Java (Java FX) Tic-Tac-Toe game (aka X's and O's) in which the player, who is "X", plays against the application, which is "O". The game should be built using the basic window-with-canvas code used for the various tutorials and course assignments. The user plays by dragging "X" tokens onto the Tic-Tac-Toe board area after which the application will automatically play by moving an "O" onto the board area. When a game is over the app should...
Tic tac toe game C++ programing using classes, objects, arays