ppt of lab project by 08537 & 08564
TRANSCRIPT
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
1/14
Submitted by:-Poonam Arya 08537
Aprajita Chandel 08564
COMPUTER LAB PROJECT
Submitted to:Mr.Pradeep Singh
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
2/14
Problem Definition
Algorithm used
Snapshots
Assumptions
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
3/14
Tic-tac-toe, also called wick wack woe , noughts andcrosses, is a pencil-and-paper game for twoplayers, X and O, who take turns marking the spaces in a33.The X player usually goes first. The player who succeeds inplacing three respective marks in a horizontal, vertical, ordiagonal row wins the game.
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
4/14
1. Here we use the nine-element vector representing the boardwhere the elements of the vector correspond to the boardpositions as follows:
An element contains the value 2 if the corresponding square isblank, 3 if the corresponding square is filled with X and 5 if the
corresponding square is filled with O.
2. Player X makes the first move in case of the game between twohuman players while in case of the game of a human with computer,
the computer makes the even moves (i.e.2,4,6,8).
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
5/14
TAB FIVE
Data Structures
Board: 2 : blank, 3 : X, 5 : OTurn: move of the game 1,2,3,.....
odd-numbered move : xeven-numbered move : o
3 sub procedures
Make2: Returns 5 if the center square is blank i.e.if Board[5] =2. Else any other blank non-cornersquare (2,4,6,8).
Posswin (p): Returns 0 if the player p cannot win on his nextmove; otherwise it returns the number of thesquare that constitutes a winning move. This
function will enable the program both to win andto block the opponents win. Posswin operates bychecking each of the rows, columns and diagonals.Because it can test an entire row, column ordiagonal to see if it is a possible win by multiplying
the values of its squares together.
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
6/14
Posswin If the product is 18 (3x3x2), then X can win. If theproduct is 50 (5x5x2) then O can win. If we find a
winning row, we determine which element isblank, and return the number of that square.
Go(n) Makes a move in the square n. This proceduresets Board[n] to 3 if Turn is odd, or 5 if turn iseven. It also increments Turn by one.
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
7/14
Turn = 1 Go(1)Turn = 2 If Board[5] is blank, Go(5), else Go(1)Turn = 3 If Board[9] is blank, Go(9), else Go(3)
Turn = 4 If Posswin(X) 0, then Go(Posswin(X)),else Go(Make2).Turn = 5 If Posswin(X) 0, then Go(Posswin(X)) else if Posswin(0)
0, then Go(Posswin(0)), else if Board[7] is blank, orGo(7), or Go(3) [fork]Turn = 6 Posswin(0) 0, then Go(Posswin(0)), else if Posswin(X)
0, then Go(Posswin(X)) else Go(Make2).Turn = 7 If Posswin(X) 0,vthen Go(Posswin(X)),else if Posswin(0) 0, then Go(Posswin(0)), else go anywhere that is blank.Turn = 8 Posswin(0) 0, then Go(Posswin(0)), else if Posswin(X)
0, then Go(Posswin(X)) else go anywhere that is blank.Turn = 9 Same as Turn = 7.
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
8/14
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
9/14
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
10/14
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
11/14
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
12/14
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
13/14
-
8/3/2019 Ppt of Lab Project by 08537 & 08564
14/14