Data Report of Tic Tac Toe Game
Data Report of Tic Tac Toe Game
PROJECT Report
OF
TIC-TAC-TOE GAME
Bachelor of Computer Application
From
Govt. Digvijay Automous PG College Rajnandgaon(C.G.)
Year:-2020-21
Guided by Submitted by
Guide Name
KEWAL DEWANGAN
Certificate of evaluation
matter embodied in this project work has not been submitted earlier for
Roll No:
ACKNOWLEDGEMENT
to our thoughts and understanding making us believe that all that was of
our own efforts for which for we well ever our remain indebted to them.
SUBMITTED BY
Geetanjali gupta
What is AI?
Strategy
• Win: If the player has two in a row, they 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 themselves to block the opponent.
• Fork: Create an opportunity where the player has two threats to
win (two non-blocked lines of 2)
Algorithm
• The algorithm has built in strategy for each move it may have to
make. It makes the odd numbered moves if it is playing X, the
even numbered moves if it is playing O. The strategy for each turn
is as follows:
• Turn 1 Go(1)(under left corner).
• Turn 2 If Board[5] is blank, Go(5),else Go(1).
• Turn 3 If Board[5] is blank, Go(9),else Go(3).
• Turn 4 If Posswin(X) is not 0, then Go(Posswin(X))[i.e.,block
opponent’s win], else Go(Make2).
• Turn 5 If Posswin(X) is not 0, then Go(Posswin(X))[i.e.,win] else
if Posswin(O) is not 0, then Go(Posswin(O)) [i.e.,win], else if
Board[7] is blank, then Go(7), else Go(3). • [Here the program is
trying to make fork.]
• Turn 6 If Posswin(O) is not 0, then Go(Posswin(O)), else if
Posswin(X) is not 0,then Go(Posswin(X)),else Go(Make2).
• Turn 7 If Posswin(X) is not 0, then Go(Posswin(X)), else if
Posswin(O) is not 0,then Go(Posswin(O)),else go anywhere that is
blank.
• Turn 8 If Posswin(O) is not O, then Go(Posswin(O)), else if
Posswin(X) is not 0,then Go(Posswin(X)),else go anywhere that is
blank.
• Turn 9 Same as Turn 7.
Block Diagram for Single Player game Main Menu One Player
Two Player Start Game Exit game Exit Game Players Turn
Computer’s Turn Get player moves Get Android moves Check if
player 1 won Check if player 2 won If it’s a tie New/End Game Yes
Yes No No Yes
Technologies Used
Libraries
Block Diagram
for Two Player game Main Menu One Player Two Player New
Game Exit game Exit Game Get player 1 moves Get player2
moves Check if player 1 won Check if player 2 won If it’s a tie
New/End Game Player 1 Turn Player 2 Turn Yes Yes No No Ye
ADMINISTRATION
Provides authentication
GAME
PLAYER
Responds to computer
SELECTION
USER USER
PROCESS
Player 1
Player 1
moves
Player 2
moves
Player 2
Check for
Display
win
winner
Setting the Two player game: User Interface String in this text
views updates the turn of each player and in the end shows the
result Score Board 3X3 board of buttons
findViewById(R.id.one_player)).setOnClickListener(new
OnClickListener(){ public void onClick(View V) { Log.d("DEBUG",
"One Player Button Pressed!"); Intent intent = new
Intent(MainMenuScreen.this, TicTacToeTutorialActivity.class);
intent.putExtra("gameType", true); startActivityForResult(intent,
0); } });
1. Interface definition for a callback to be invoked when a view is
clicked
2. Log class ensures that the button was clicked and Log.d sends
the debug output.
3. An Intent provides a facility for performing late runtime binding
between the code in different applications. Its most significant use
is in the launching of activities, where it can be thought of as the
glue between activities.
4. start another activity and receive a result back. To receive a
result, call startActivityForResult()
Future Work
Conclusion