Upcoming SlideShare
×

Like this presentation? Why not share!

# Tic tac toe

## on Jan 19, 2013

• 2,092 views

### Views

Total Views
2,092
Views on SlideShare
2,092
Embed Views
0

Likes
2
68
0

No embeds

### Report content

• Comment goes here.
Are you sure you want to

## Tic tac toePresentation Transcript

• PROJECT TIC TAC TOESubmitted to- Submitted by-Mrs.Dipti Kunra Jasleen Kaur D2 CSE 1144384
• TIC-TAC- {TOE
• 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 View slide
• 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. View slide
• 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.
• 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.
• 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
• 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
• 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
• 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.
• SCREENSHOTS {
• {
• 2. {
• {
• {
• {
• {
• {
•  Click to edit Master text styles  Second level  Third level  Fourth level  Fifth level
•  Click to edit Master text styles  Second level  Third level  Fourth level  Fifth level
• 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.
• 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.
• THANK YOU