TIC TAC TOE

TIC TAC TOE
GROUP MEMBERS:
B.PREMA PRATHIKSHA
M.AADHITYA
A.SATYAM SINGH

ACKNOWLEDGEMENT
“Gratitude is the fairest blossom which springs from soul”

Feeling gratitude and not expressing it is like wrapping a present and not giving it.
I take this opportunity to convey my heartfelt gratitude to each and every one who
has supported me in each or the other way during the course of my project.
Acknowledgement is the most beautiful page in any project’s final pages.
More then a formality this appears to me the best opportunity to express my
gratitude.
My list can never begin without u dear lord. I sincerely thank my
computer teacher Mrs. A. Gandhi Mathi who helped our group to make our project
a successful one.
This project wouldn’t have been successful without her help. I also thank my
school principal Rev. Bro. Arul Jeevan CSC who co-operated with us at every
point in our project
. At this moment I would like to thank my group members for their wonderful
effort put into this project. At the outset I would like to thank my critics who
helped me to bring out the best; your honest opinions are welcome most.
It requires a lot of effort in terms of co-operation and support to fulfil various tasks
involved during the course of this project.
I cannot end this list without thanking the esteemed viewers of the project who
keep sending me their honest opinions, feedback, suggestions, complaints, etc.
thank you for your support.
Things always remain hidden in the shadow of unsung heroes; still I would wish to
thank all people passively involved in the assignment, People who encouraged me
day in and day out to make it success.At last above all I would like to thank
almighty for showering his blessings on me to make this project a successful one.

OVERVIEW:

etc. A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time. it provides powerful and flexible mechanisms for abstraction.This overview of C++ presents the key design. that is. in any language. to become more effective at designing and implementing new systems and at maintaining old ones. In addition. data abstraction. + 1 Introduction and Overview The C++ programming language provides a model of memory and computation that closely matches that of most computers. and generic programming. as an enhancement to the C language and originally named C with Classes but later it was renamed C++ in 1983. that is. C++ supports styles of programming that rely on fairly direct manipulation of hardware resources to deliver a high degree of efficiency plus higher-level styles of programming that rely on user-defined types to provide a model of data C++ is a statically typed. C. C++ is a general-purpose programming language with a bias towards systems programming that supports efficient low-level computation. language constructs that allow the programmer to introduce and use new types of objects that match the concepts of an application. free-form programming language that supports procedural. Smalltalk. Thus. object-oriented programming. programming. You can write in the style of Fortran. compiled. and languagetechnical concepts using examples to give the reader a feel for the language. object-oriented. and that virtually any legal C program is a legal C++ program. case-sensitive. The most important thing to do when learning C++ is to focus on concepts and not get lost in language technical details. as it comprises a combination of both high-level and low-level language features C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill.The purpose of learning a programming language is to become a better programmer. general-purpose. C++ is regarded as a middle-level language. Each style can achieve its aims .. New Jersey. and generic programming.C++ is a superset of C. C++ supports a variety of programming styles.

. Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C++ because the primary user interfaces of these systems are written in C++. C++ is used by hundreds of thousands of programmers in essentially every application domain C++ is being highly used to write device drivers and other softwares that rely on direct manipulation of hardware under real-time constraints. C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts.effectively while maintaining runtime and space efficiency.

830 possible games up to rotations and reflections (the game tree complexity) on this space. with the goal of getting k of their own color in a row.n. it is often used as a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. Tictac-toe is most often played by young children. Tic-tac-toe requires detailed analysis to determine even some elementary combinatory facts. The following example game is won by the first player. Because of the simplicity of Tic-tac-toe. or the 26.k-game in which two players alternate placing stones of their own color on an m×n board. X: Players soon discover that best play from both parties leads to a draw. to enumerate the 765 essentially different positions (the state space complexity). who take turns marking the spaces in a 3×3 grid. X and O. It is straightforward to write a computer program to play Tic-tac-toe perfectly. Hence. The player who succeeds in placing three of their marks in a horizontal.3)-game Despite its apparent simplicity.[1] The game can be generalized to an m. the most interesting of which are the . Tic-tac-toe is the (3. vertical.NEED FOR THE PROJECT: Tic-tac-toe (also known as Noughts and crosses or Xs and Os) is a paper-andpencil game for two players. or diagonal row wins the game.3.

9!) possible games (different sequences for placing the Xs and Os on the board).683 possible board layouts (39 since each of the nine spaces can be X. Assuming that X makes the first move every time:  91 distinct positions are won by (X)  44 distinct positions are won by (O)  3 distinct positions are drawn . However. and 362.When considering only the state of the board. A position is merely a state of the board.number of possible games and the number of possible positions. rotations and reflections). The complete analysis is further complicated by the definitions used when setting the conditions. two matters much reduce these numbers:  The game ends when three-in-a-row is obtained.e.e. there are only 138 terminal board positions.  The number of Xs is always either equal to or exactly 1 more than the number of Os (if X starts). O or blank). Naive counting leads to 19. while a game usually refers to the way a terminal position is obtained.880 (i. and after taking into account board symmetries (i. like board symmetries.

h> Using name space std .h> #include<stdio.HEADER FILES USED:     #include <iostream> #include<conio.

this key word gives out the message to user to play the move .KEY WORDS: Check win: To check which user has won the match Board: To display the board to user Square: To display the box to user Player: The user who has to start the move .

SOFT WARE AND HARDWARE:     1 TB hard disk Turbo c++ software Intel core processor Windows explorer .

h> #include<stdio.'5'.'7'.'8'. cout << "Player " << player << ". enter a number: ".'6'. mark=(player == 1) ? 'X' : 'O'.i.'4'.'3'. void board().'2'. cin >> choice.SOURCE CODE: #include <iostream> #include<conio.'1'. player=(player%2)?1:2.h> using namespace std. int checkwin().'9'}. char square[10] = {'o'. do { board().choice. . char mark. int main() { int player = 1.

else if (choice == 9 && square[9] == '9') square[9] = mark. else . else if (choice == 7 && square[7] == '7') square[7] = mark. else if (choice == 8 && square[8] == '8') square[8] = mark.if (choice == 1 && square[1] == '1') square[1] = mark. else if (choice == 5 && square[5] == '5') square[5] = mark. else if (choice == 6 && square[6] == '6') square[6] = mark. else if (choice == 4 && square[4] == '4') square[4] = mark. else if (choice == 2 && square[2] == '2') square[2] = mark. else if (choice == 3 && square[3] == '3') square[3] = mark.

board(). }while(i==-1). cin. } . player++.ignore().{ cout<<"Invalid move ". cin. } i=checkwin().get(). return 0. cin.ignore(). else cout<<"==>\aGame draw". if(i==1) cout<<"==>\aPlayer "<<--player<<" win ". player--. cin.get().

/********************************************* 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[7] == square[8] && square[8] == square[9]) return 1. else if (square[1] == square[4] && square[4] == square[7]) . else if (square[4] == square[5] && square[5] == square[6]) return 1.

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 if (square[3] == square[6] && square[6] == square[9]) return 1. . else if (square[3] == square[5] && square[5] == square[7]) return 1. else return -1. else if (square[1] == square[5] && square[5] == square[9]) return 1. else if (square[2] == square[5] && square[5] == square[8]) return 1.

cout << " " << square[1] << " | " << square[2] << " | " << square[3] << endl. cout << " | | " << endl. cout << endl. cout << " | | " << endl.} /****************************************************************** FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK ******************************************************************/ void board() { system("cls"). cout << " " << square[4] << " | " << square[5] << " | " << square[6] << endl. cout << "\n\n\tTic Tac Toe\n\n".Player 2 (O)" << endl << endl. cout << "Player 1 (X) . cout << "_____|_____|_____" << endl. .

cout << " } | | " << endl << endl.cout << "_____|_____|_____" << endl. . cout << " " << square[7] << " | " << square[8] << " | " << square[9] << endl. cout << " | | " << endl.

SCREENSHOTS: .

.

.

.

.

.

.

.

Bro .BIBLIO GRAPHY: To make this project I have taken the help of the book”let us with c++” Which is written by Yeshwanth kanethkar and “computer science with c++. And I would also thank our dear principal Rev.A.com  My c++friend.written by sumitha arrora.com  Cpp for school.Arul jeevan. .com Last but not the least to complete this project our computer teacher Mrs.Gandhi mathi has helped us. We referred some websites too for the completion of this project they are:  Cplusplus.