Tic tac toe


Published on

Published in: Education
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Tic tac toe

  1. 1. PROJECT TIC TAC TOESubmitted to- Submitted by-Mrs.Dipti Kunra Jasleen Kaur D2 CSE 1144384
  2. 2. TIC-TAC- {TOE
  3. 3. INTRODUCTIONTic-tac-toe, also called noughts and crosses (in the British Commonwealth countries), Xs and Os (in Ireland) and Xand 0 (in India) is a pencil-and-paper game for two players, X and O, who take turns marking the spaces in a 3×3grid. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins thegame.The following example game is won by the first player, X: {Players soon discover that best play from both parties leads to a draw (often referred to as cat or cats game). Hence,tic-tac-toe is most often played by young children.The friendliness of tic-tac-toe games makes them ideal as a pedagogical tool for teaching the concepts of goodsportsmanship and the branch of artificial intelligence that deals with the searching of game trees. It isstraightforward to write a computer program to play tic-tac-toe perfectly, to enumerate the 765 essentially differentpositions (the state space complexity), or the 26,830 possible games up to rotations and reflections (the game treecomplexity) on this space
  4. 4. StrategyOptimal strategy for player X. In each grid, the shaded red X denotes the optimal move, and the location of Os next move givesthe next subgrid to examine. Note that only two sequences of moves by O (both starting with center, top-right, left-mid) lead toa draw, with the remaining sequences leading to wins from X.A player can play perfect tic-tac-toe (win or draw) given they choose the first possible move from the following list.Win : If the player has two in a row, he or she can place a third to get three in a row.Block : If the [opponent] has two in a row, the player must play the third himself or herself to block them. {Fork : Creation of an opportunity where the player has two threats to win (two non-blocked lines of 2).Blocking an opponents fork:Option 1: The player should create two in a row to force the opponent into defending, as long as it doesnt result in themcreating a fork. For example, if "X" has a corner, "O" has the center, and "X" has the opposite corner as well, "O" must not play acorner in order to win. (Playing a corner in this scenario creates a fork for "X" to win.)Option 2: If there is a configuration where the opponent can fork, the player should block that fork.Center : A player marks the center. (If it is the first move of the game, playing on a corner gives "O" more opportunities tomake a mistake and may therefore be the better choice; however, it makes no difference between perfect players.)Opposite corner : If the opponent is in the corner, the player plays the opposite corner.
  5. 5. INTRODUCTION TO C++ The c++ programming language is a very powerful general purpose programming languagethat supports procedural programming as well as object oriented programming .It incoporates all the ingredients required for building software for large and complexproblems.The C++ programming language provides a model of memory and computation that closely {matches that of most computers. In addition, it provides powerful and flexible mechanismsfor abstraction; that is, language constructs that allow the programmer to introduce and usenew types of objects that match the concepts of an application. Thus, C++ supports styles ofprogramming that rely on fairly direct manipulationof hardware resources to deliver a high degree of efficiency plus higher-level styles ofprogramming that rely on user-defined types to provide a model of data and computationthat is closer to a human’s view ofthe task being performed by a computer. These higher-level styles of programming are oftencalled data abstraction, object-oriented programming, and generic programming.
  6. 6. EVOLUTION OF C++LANGUAGEC++ is a powerful programming language that had attracted worldwide attention because the software industryhad adopted the language to great advantage. The programs written in c++ are portable ,fast and efficient.C++ was designed and implemented by Bjarne Stroustrup at AT&T Bell Laboratories to combine theorganizational and design strengths of Simula with C’s facilities for systems programming.The initial version of C++, called ‘‘C with Classes’’ , was first used in 1980. It supported traditional systemprogramming techniques and data abstraction . The basic facilities for object-oriented programming were {added in 1983 and object-oriented design and programmingtechniques were gradually introduced into the C++ community. The language was first made commerciallyavailable in 1985 . Facilities for generic programming were added to the language in the 1987-1989 time frame . Asthe result of widespread use and the appearance of several independently-developed C++ implementations,formal standardization of C++ started in 1990 under the auspices of the American National Standards Institute,ANSI, and later the International Standards Organization, ISO, leading to an international standard in 1998 .During the period of standardization the standards committee acted as an important focus for the C++community and its draft standards acted as interim definitions ofthe language.
  7. 7. IOstream LibraryStandard Input / Output Streams Library The iostream library is an object-oriented library that provides input and outputfunctionality using streams.A stream is an abstraction that represents a device on whichinput and ouput operations are performed. A stream can basically be represented as asource or destination of characters of indefinite length. {Streams are generally associated to a physical source or destination of characters, like a diskfile, the keyboard, or the console, so the characters gotten or written to/from our abstractioncalled stream are physically input/output to the physical device. For example, file streamsare C++ objects to manipulate and interact with files; Once a file stream is used to open afile, any input or output operation performed on that stream is physically reflected in thefile.
  8. 8. DATA TYPESWhile doing programming in any programming language, you need to use various variables to storevarious information. Variables are nothing but reserved memory locations to store values. This meansthat when you create a variable you reserve some space in memory.You may like to store information of various data type like character, wide character, integer, floatingpoint, double floating point, boolean etc. Based on the data type of a variable, the operating systemTypechar {allocates memory and decides what can be stored in the reserved memory. Typical Bit Width 1byte Typical Range -127 to 127 or 0 to 255int 4bytes -2147483648 to 2147483647bool 1byte false or true
  9. 9. OperatorsOnce we know of the existence of variables and constants, we can begin to operate with them. For that purpose, C++ integrates operators.Unlike other languages whose operators are mainly keywords, operators in C++ are mostly made of signs that are not part of the alphabet butare available in all keyboards. This makes C++ code shorter and more international, since it relies less on English words, but requires a little oflearning effort in the beginning.1. Assignment (=)The assignment operator assigns a value to a variable.a = 5; {2.Arithmetic operators ( +, -, *, /, % )The five arithmetical operations supported by the C++ language are:+ addition, - subtraction* multiplication/ division% modulo3.Relational and equality operators== Equal to!= Not equal to
  10. 10. 4. Logical operators( !, &&)! ORERATOR!(5 == 5) // evaluates to false because the expression at its right (5 == 5) is true.!(6 <= 4) // evaluates to true because (6 <= 4) would be false.!true // evaluates to false!false // evaluates to true.&& OPERATORa b { a && btrue true truetrue false falsefalse true falsefalse false false
  11. 11. Control StructuresA program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or takedecisions. For that purpose, C++ provides control structures that serve to specify what has to be done by our program, when andunder which circumstances.Conditional structure: if and elseThe if keyword is used to execute a statement or block only if a condition is fulfilled.syntax:if (condition) statement1 else statement2For example:if (x == 100) cout << "x is 100"; {Else cout << "x is not 100";Iteration structures (loops)The do-while loopIts format is:do statement while (condition); Its functionality is exactly the same as the while loop, except that condition in the do-while loop is evaluated after the execution ofstatement instead of before, granting at least one execution of statement even if condition is never fulfilled.
  12. 12. SCREENSHOTS {
  13. 13. {
  14. 14. 2. {
  15. 15. {
  16. 16. {
  17. 17. {
  18. 18. {
  19. 19. {
  20. 20.  Click to edit Master text styles  Second level  Third level  Fourth level  Fifth level
  21. 21.  Click to edit Master text styles  Second level  Third level  Fourth level  Fifth level
  22. 22. APPLICATIONSVarious game shows have been based on Tic-Tac-Toe and its variants: On Hollywood Squares, nine celebrities filled the cells of the tic-tac-toe grid; players put symbols on the board by correctly agreeing or disagreeing with a celebritys answer to a question. Variations of the show include Storybook Squares and Hip Hop Squares. In Tic-Tac-Dough, players put symbols up on the board by answering questions in various categories, which shuffle after each players turn. In Beat the Teacher, contestants answer questions to win a turn to influence a tic-tac-toe grid. On The Price Is Right, several national variants feature a pricing game called "Secret X," in which players must guess prices of two small prizes to win Xs (in addition to one free X) to place on a blank board. They must place the Xs in position to guess the location of the titular "secret X" hidden in the center column of the board and form a tic-tac-toe line across or diagonally (no vertical lines allowed). There are no Os in this variant of the game. On Minute to Win It, the game Ping Tac Toe has one contestant playing the game with nine water- filled glasses and white and orange ping-pong balls, trying to get three in a row of either color. They must alternate colors after each successful landing and must be careful not to block themselves.
  23. 23. LIMITATIONS1. This game cannot be played by one or more than 2 players.2. It is not a high level game.3. It doesn’t contain levels.
  24. 24. THANK YOU