SlideShare une entreprise Scribd logo
1  sur  26
Presented By : Group
SAS - 212 (OFFICIAL)
Preston University, ISLAMABAD | 29 April, 2013
Tic Tac Toe
(Console Game) C++ Program
Saad Wazir, Sidra Batool, Kamran Shah, Abdul Rehman, Haseeb Ullah, Shafaq Arif & Bushra
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 212012 / BSCS
Tic Tac Toe | (Console Game) C++ Program
Sidra Batool
Presenting :
Introduction to Tic Tac Toe
(Console Game) C++ Program
Presented by: Sidra Batool | 1421 – 212012 / BSCS
Tic-tac-toe (or Noughts and crosses, Xs and Os) is a pencil-
and-paper game for two players, X and O, who take turns
marking the spaces in a 3×3 grid. The player who succeeds in
placing three respective marks in a horizontal, vertical, or
diagonal row wins the game.
Introduction to Tic Tac Toe
(Console Game) C++ Program
This program is a game program, Tic Tac
Toe. Most of us have played this game in
school days, we have make a C++
program on it.
Presented by: Sidra Batool | 1421 – 212012 / BSCS
Introduction to Tic Tac Toe
(Console Game) C++ Program
This game uses board to control players
In each turn players enter a number and
choose a move
Simplify programing assumes that player
one always moves first and uses X's
Player two moves at 2nd position and
uses O's
A Sample Screen Shot of a Game
Presented by: Sidra Batool | 1421 – 212012 / BSCS
Introduction to Tic Tac Toe
(Console Game) C++ Program
How the program structured :
At the time when program start we initialize variables, and we run
the game loop until the game end or players choose to quit
The game consists of three steps
• Display board
• Get players move
• Check for game end
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 312126 / BSCS
Tic Tac Toe | (Console Game) C++ Program
Shafaq Arif
Presenting :
Tic Tac Toe C++ Program
Initialization Of Variables &
explanatory statements
Presented by: Shafaq Arif | 1421 – 3121236 / BSCS
Initialization Of Variables &
explanatory statements
This portion of code is for initialization of variables,
the variables of squares are initializing with the
characters from 1 to 9.
The player turn will be initializing to 1 because since
the player 1 makes the first turn
Game over is initialize to true but that does not really
matter for this program because after game loop
game check itself for winner.
Presented by: Shafaq Arif | 1421 – 3121236 / BSCS
Initialization Of Variables &
explanatory statements
Program comments are explanatory statements that you can include in the C++ code
that you write and helps anyone reading its source code. All programming languages
allow for some form of comments.
C++ supports single line and multi-line comments. All characters available inside any
comment are ignored by C++ compiler.
C++ comments start with /* and end with */. For example:
// This is a comment
/* C++ comments can also
span multiple lines
*/
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 312129 / BSCS
Tic Tac Toe | (Console Game) C++ Program
Bushra Urooj
Presenting :
Tic Tac Toe C++ Program
Game Loops
Presented by: Bushra Urooj | 1421 – 312129 / BSCS
Game Loops
After initialization game began to move forward for main
game loop these loops are while and do while loop which are
encapsulated in statements that what to do or not to do.
Once we enter the game loop
The first thing will be done is print the game board which
displays the tic tac toe game board in console window
Remember we initialize these squares with characters from 1 to
9 for basic console input and output.
Presented by: Bushra Urooj | 1421 – 312129 / BSCS
Game Loops
When we run the program the board looks like this
Notice that the console window
prompts the player for move
The player's moves are handled by
the next portion of code
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 212008 / BSCS
Tic Tac Toe | (Console Game) C++ Program
Haseeb Ullah
Presenting :
Tic Tac Toe C++ Program
Game Loops
( player's moves )
Presented by: Haseeb Ullah| 1421 – 212008 / BSCS
Game Loops
( player's moves )
cPlayerMark determines that first player has X and second has 0
This portion of statements check for player turn if it's not the first
player move its promoted the move to next player
Then the next line gets the valid move of the player
Game Loops
( player's moves )
If players input an invalid move it's prompted for another
move and says try again like this ..
Presented by: Haseeb Ullah| 1421 – 212008 / BSCS
A Screen Shot of an Invalid Move
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 212271 / BSCS
Tic Tac Toe | (Console Game) C++ Program
Kamran Shah
Presenting :
Tic Tac Toe C++ Program
Game Loops
( player's moves )
Presented by: Kamran Shah| 1421 – 212271 / BSCS
Game Loops
( player's moves )
The cin statement gets the valid
move for the player
Notice that it's begin with another
loop it has pretty much statements to
check the conditions.
The check for valid move is pretty
large branch of square check.
Game Loops
( player's moves )
Each branch of the if statement makes two check, the first input
check that the input is valid digit from 1 to 9 and second check is for
make sure of the input is digit not an character, second check also
make sure that the number which is entered not entered
Previously
once a player moves the
square changes like this.
Presented by: Kamran Shah| 1421 – 212271 / BSCS
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 212019/ BSCS
Tic Tac Toe | (Console Game) C++ Program
Saad Wazir
Presenting :
Tic Tac Toe C++ Program
Game Loops
( player's moves )
Game Loops
( player's moves )
Presented by: Saad Wazir | 1421 – 212019 / BSCS
After the valid move the series of checks perform to check
the games conditions.
Note there are the nine ways to end the game, 8 conditions
to win the game and 1 condition for draw the game.
The first conditions check the ending game condition
through
the walls of 1st square.
Game Loops
( player's moves )
Presented by: Saad Wazir | 1421 – 212019 / BSCS
The second if statement handles the 4 cases from
the middle 5th square .
Game Loops
( player's moves )
Presented by: Saad Wazir | 1421 – 212019 / BSCS
The third if statement handles the 2 cases from the 9th square
In each of these cases we check that the squares not equals to its number
character.
This check ensures that we have an extra O and the other two checks make
sure that the other two squares have the same O in the series like this one
Those cases cover the win condition however game will be ended and draw like
this.
Game Loops
( player's moves )
Presented by: Saad Wazir | 1421 – 212019 / BSCS
Screen Shot “ Game Draw”
SAS-212 (OFFICIAL)
Preston University
ISLAMABAD
1421 – 212010 / BSCS
Tic Tac Toe | (Console Game) C++ Program
Abdul Rehman
Presenting :
Tic Tac Toe C++ Program
Game Loops
(Final Check)
Presented by: Abdul Rehman| 1421 – 212010 / BSCS
Game Loops
(Final Check)
After that we print the ending board of the game and tells
whose win and ask the user to play another game or quit
If the user want play again the looping is continue and the
board will be reset and the player turn also set back to 1
On the other hand the game will be quit .
Presented by: Abdul Rehman| 1421 – 212010 / BSCS
Game Loops
(Final Check)
The final check takes cover of the case that game will be draw and all the
squares will be marked.
When we determine that the game is over we run through over final
condition
If the game is over we check for the game that someone is win the game
Boolean which we set at the last part, if some has won then it will be last
one or last player which is moved.
Tic Tac Toe | (Console Game) C++ Program
SAS-212 (OFFICIAL)
ALLAH Hafiz
Hope you Enjoy & Learn Something
Reference :
2007 Xoax
xoax.net ( C++ Lesson # 9 )

Contenu connexe

Tendances

Decoder for digital electronics
Decoder for digital electronicsDecoder for digital electronics
Decoder for digital electronics
IIT, KANPUR INDIA
 

Tendances (20)

Tic tac toe game code
Tic tac toe game codeTic tac toe game code
Tic tac toe game code
 
Tic Tac Toe
Tic Tac ToeTic Tac Toe
Tic Tac Toe
 
Tic toc game presentation
Tic toc game presentationTic toc game presentation
Tic toc game presentation
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
 
Synopsis tic tac toe
Synopsis tic tac toeSynopsis tic tac toe
Synopsis tic tac toe
 
Snake game implementation in c
Snake game implementation in cSnake game implementation in c
Snake game implementation in c
 
report on snake game
report on snake game report on snake game
report on snake game
 
The complete srs documentation of our developed game.
The complete srs documentation of our developed game. The complete srs documentation of our developed game.
The complete srs documentation of our developed game.
 
online movie ticket booking system
online movie ticket booking systemonline movie ticket booking system
online movie ticket booking system
 
TicTacToe.pptx
TicTacToe.pptxTicTacToe.pptx
TicTacToe.pptx
 
Casino game project based on c++
Casino  game  project based on c++Casino  game  project based on c++
Casino game project based on c++
 
Report on car racing game for android
Report on car racing game for androidReport on car racing game for android
Report on car racing game for android
 
Project proposal presentation(Quiz game)
Project proposal presentation(Quiz game)Project proposal presentation(Quiz game)
Project proposal presentation(Quiz game)
 
Integer Optimisation for Dream 11 Cricket Team Selection
Integer Optimisation for Dream 11 Cricket Team SelectionInteger Optimisation for Dream 11 Cricket Team Selection
Integer Optimisation for Dream 11 Cricket Team Selection
 
Snake project report
Snake project reportSnake project report
Snake project report
 
Software Engineer- A unity 3d Game
Software Engineer- A unity 3d GameSoftware Engineer- A unity 3d Game
Software Engineer- A unity 3d Game
 
project on snake game in c language
project on snake game in c languageproject on snake game in c language
project on snake game in c language
 
Rock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxRock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptx
 
Decoder for digital electronics
Decoder for digital electronicsDecoder for digital electronics
Decoder for digital electronics
 
Final project report Snake Game in Python
Final project report Snake Game in PythonFinal project report Snake Game in Python
Final project report Snake Game in Python
 

En vedette

Contact Management System
Contact Management SystemContact Management System
Contact Management System
Gopal Bhat
 

En vedette (20)

Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac Toe
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
 
Modul Kelas Programming : Java MySQL
Modul Kelas Programming : Java MySQLModul Kelas Programming : Java MySQL
Modul Kelas Programming : Java MySQL
 
Ip project work test your knowledge
Ip project work test your knowledgeIp project work test your knowledge
Ip project work test your knowledge
 
Ip project visual mobile
Ip project visual mobileIp project visual mobile
Ip project visual mobile
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
PPT FOR ONLINE HOTEL MANAGEMENT
PPT FOR ONLINE HOTEL MANAGEMENTPPT FOR ONLINE HOTEL MANAGEMENT
PPT FOR ONLINE HOTEL MANAGEMENT
 
Petrol station safety
Petrol station safetyPetrol station safety
Petrol station safety
 
Computer science class 12 project on Super Market Billing
Computer science class 12 project on Super Market BillingComputer science class 12 project on Super Market Billing
Computer science class 12 project on Super Market Billing
 
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IP
 
Computer project final for class 12 Students
Computer project final for class 12 StudentsComputer project final for class 12 Students
Computer project final for class 12 Students
 
Contact Management System
Contact Management SystemContact Management System
Contact Management System
 
Hotel Management In C++
Hotel Management In C++Hotel Management In C++
Hotel Management In C++
 
Investigatory Project
Investigatory ProjectInvestigatory Project
Investigatory Project
 
School Management (c++)
School Management (c++) School Management (c++)
School Management (c++)
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station software
 
Ip project
Ip projectIp project
Ip project
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
Hotel Management system in C++
Hotel Management system in C++ Hotel Management system in C++
Hotel Management system in C++
 

Similaire à Tic tac toe c++ project presentation

#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
aquacareser
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
aquapariwar
 
2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report
Cem Recai Çırak
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
anjandavid
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
manjan6
 
C++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdfC++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdf
ezzi97
 
Project 2
Project 2Project 2
Project 2
umtkrc
 

Similaire à Tic tac toe c++ project presentation (13)

Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
 
2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report2 Level Guitar Hero Final Report
2 Level Guitar Hero Final Report
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
 
python.pptx
python.pptxpython.pptx
python.pptx
 
cpbricks manual
cpbricks manualcpbricks manual
cpbricks manual
 
C++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdfC++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdf
 
Global Math Game Guideline English Version
Global Math Game Guideline English VersionGlobal Math Game Guideline English Version
Global Math Game Guideline English Version
 
Project 2
Project 2Project 2
Project 2
 
Types of Gaming Program
Types of Gaming ProgramTypes of Gaming Program
Types of Gaming Program
 

Tic tac toe c++ project presentation

  • 1. Presented By : Group SAS - 212 (OFFICIAL) Preston University, ISLAMABAD | 29 April, 2013 Tic Tac Toe (Console Game) C++ Program Saad Wazir, Sidra Batool, Kamran Shah, Abdul Rehman, Haseeb Ullah, Shafaq Arif & Bushra
  • 2. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 212012 / BSCS Tic Tac Toe | (Console Game) C++ Program Sidra Batool Presenting : Introduction to Tic Tac Toe (Console Game) C++ Program
  • 3. Presented by: Sidra Batool | 1421 – 212012 / BSCS Tic-tac-toe (or Noughts and crosses, Xs and Os) is a pencil- and-paper game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game. Introduction to Tic Tac Toe (Console Game) C++ Program This program is a game program, Tic Tac Toe. Most of us have played this game in school days, we have make a C++ program on it.
  • 4. Presented by: Sidra Batool | 1421 – 212012 / BSCS Introduction to Tic Tac Toe (Console Game) C++ Program This game uses board to control players In each turn players enter a number and choose a move Simplify programing assumes that player one always moves first and uses X's Player two moves at 2nd position and uses O's A Sample Screen Shot of a Game
  • 5. Presented by: Sidra Batool | 1421 – 212012 / BSCS Introduction to Tic Tac Toe (Console Game) C++ Program How the program structured : At the time when program start we initialize variables, and we run the game loop until the game end or players choose to quit The game consists of three steps • Display board • Get players move • Check for game end
  • 6. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 312126 / BSCS Tic Tac Toe | (Console Game) C++ Program Shafaq Arif Presenting : Tic Tac Toe C++ Program Initialization Of Variables & explanatory statements
  • 7. Presented by: Shafaq Arif | 1421 – 3121236 / BSCS Initialization Of Variables & explanatory statements This portion of code is for initialization of variables, the variables of squares are initializing with the characters from 1 to 9. The player turn will be initializing to 1 because since the player 1 makes the first turn Game over is initialize to true but that does not really matter for this program because after game loop game check itself for winner.
  • 8. Presented by: Shafaq Arif | 1421 – 3121236 / BSCS Initialization Of Variables & explanatory statements Program comments are explanatory statements that you can include in the C++ code that you write and helps anyone reading its source code. All programming languages allow for some form of comments. C++ supports single line and multi-line comments. All characters available inside any comment are ignored by C++ compiler. C++ comments start with /* and end with */. For example: // This is a comment /* C++ comments can also span multiple lines */
  • 9. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 312129 / BSCS Tic Tac Toe | (Console Game) C++ Program Bushra Urooj Presenting : Tic Tac Toe C++ Program Game Loops
  • 10. Presented by: Bushra Urooj | 1421 – 312129 / BSCS Game Loops After initialization game began to move forward for main game loop these loops are while and do while loop which are encapsulated in statements that what to do or not to do. Once we enter the game loop The first thing will be done is print the game board which displays the tic tac toe game board in console window Remember we initialize these squares with characters from 1 to 9 for basic console input and output.
  • 11. Presented by: Bushra Urooj | 1421 – 312129 / BSCS Game Loops When we run the program the board looks like this Notice that the console window prompts the player for move The player's moves are handled by the next portion of code
  • 12. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 212008 / BSCS Tic Tac Toe | (Console Game) C++ Program Haseeb Ullah Presenting : Tic Tac Toe C++ Program Game Loops ( player's moves )
  • 13. Presented by: Haseeb Ullah| 1421 – 212008 / BSCS Game Loops ( player's moves ) cPlayerMark determines that first player has X and second has 0 This portion of statements check for player turn if it's not the first player move its promoted the move to next player Then the next line gets the valid move of the player
  • 14. Game Loops ( player's moves ) If players input an invalid move it's prompted for another move and says try again like this .. Presented by: Haseeb Ullah| 1421 – 212008 / BSCS A Screen Shot of an Invalid Move
  • 15. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 212271 / BSCS Tic Tac Toe | (Console Game) C++ Program Kamran Shah Presenting : Tic Tac Toe C++ Program Game Loops ( player's moves )
  • 16. Presented by: Kamran Shah| 1421 – 212271 / BSCS Game Loops ( player's moves ) The cin statement gets the valid move for the player Notice that it's begin with another loop it has pretty much statements to check the conditions. The check for valid move is pretty large branch of square check.
  • 17. Game Loops ( player's moves ) Each branch of the if statement makes two check, the first input check that the input is valid digit from 1 to 9 and second check is for make sure of the input is digit not an character, second check also make sure that the number which is entered not entered Previously once a player moves the square changes like this. Presented by: Kamran Shah| 1421 – 212271 / BSCS
  • 18. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 212019/ BSCS Tic Tac Toe | (Console Game) C++ Program Saad Wazir Presenting : Tic Tac Toe C++ Program Game Loops ( player's moves )
  • 19. Game Loops ( player's moves ) Presented by: Saad Wazir | 1421 – 212019 / BSCS After the valid move the series of checks perform to check the games conditions. Note there are the nine ways to end the game, 8 conditions to win the game and 1 condition for draw the game. The first conditions check the ending game condition through the walls of 1st square.
  • 20. Game Loops ( player's moves ) Presented by: Saad Wazir | 1421 – 212019 / BSCS The second if statement handles the 4 cases from the middle 5th square .
  • 21. Game Loops ( player's moves ) Presented by: Saad Wazir | 1421 – 212019 / BSCS The third if statement handles the 2 cases from the 9th square In each of these cases we check that the squares not equals to its number character. This check ensures that we have an extra O and the other two checks make sure that the other two squares have the same O in the series like this one Those cases cover the win condition however game will be ended and draw like this.
  • 22. Game Loops ( player's moves ) Presented by: Saad Wazir | 1421 – 212019 / BSCS Screen Shot “ Game Draw”
  • 23. SAS-212 (OFFICIAL) Preston University ISLAMABAD 1421 – 212010 / BSCS Tic Tac Toe | (Console Game) C++ Program Abdul Rehman Presenting : Tic Tac Toe C++ Program Game Loops (Final Check)
  • 24. Presented by: Abdul Rehman| 1421 – 212010 / BSCS Game Loops (Final Check) After that we print the ending board of the game and tells whose win and ask the user to play another game or quit If the user want play again the looping is continue and the board will be reset and the player turn also set back to 1 On the other hand the game will be quit .
  • 25. Presented by: Abdul Rehman| 1421 – 212010 / BSCS Game Loops (Final Check) The final check takes cover of the case that game will be draw and all the squares will be marked. When we determine that the game is over we run through over final condition If the game is over we check for the game that someone is win the game Boolean which we set at the last part, if some has won then it will be last one or last player which is moved.
  • 26. Tic Tac Toe | (Console Game) C++ Program SAS-212 (OFFICIAL) ALLAH Hafiz Hope you Enjoy & Learn Something Reference : 2007 Xoax xoax.net ( C++ Lesson # 9 )