KEMBAR78
Mini Max Algorithm Proposal Document | DOCX
A
MINOR PROJECT PROPOSAL
ON
MINIMAX ALGORITHM
BASED
TIC-TAC-TOE
SUBMITTED BY:
SAMEER BHATTARAI (BCT/071/38)
SAROJ RAJ SHARMA (BCT/071/41)
SHEETAL BARAL (BCT/071/43)
UJJAWAL POUDEL (BCT/071/48)
DEPARTMENT OF ELECTRONICS AND COMPUTER ENGINEERING
DHARAN, NEPAL
TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
PURWANCHAL CAMPUS
NOVEMBER, 2017
2 | P a g e
TABLE OF CONTENTS
1 INTRODUCTION......................................................................................3
1.1 General Introduction.............................................................................3
1.2 Purpose.................................................................................................3
2 AIMS AND OBJECTIVES........................................................................4
3 METHODOLOGY.....................................................................................5
3.1 Flowchart..............................................................................................5
3.2 Use Case Diagram................................................................................7
4 ALGORITHM............................................................................................9
5 REFERENCES.........................................................................................11
LIST OF FIGURES
Figure 1.1 Flow chart of Tic Tac Toe………..................................................6
Figure 1.2.a Use case diagram of Player VS Player........................................7
Figure 1.2.b Use case diagram of User VS Computer.....................................8
3 | P a g e
1. INTRODUCTION
1.1 General Introduction
TodayAIis one ofthe most promising field ofcomputerscience. From solving
complex problems to doing certain things better than most humans, it has
many applications. Such capability of AI and its wide use has led us into
working on this project which will be based on “MINIMAX ALGORITHM”,
a popular algorithm basically used in game playing. The project will try to
demonstrate the implementation of an AI algorithm and it effectiveness
against a human opponent in game playing.
Tic Tac Toe (also known as noughts and crosses orXs and Os) is
a paper-and-pencil 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 of their
marks in a horizontal, vertical, or diagonal row wins the game.
The following example game is won by the first player, X:
fig (1.a) Winning condition of Player X
Tic Tac Toe is played by young children and adults alike. It is a great way to
pass your free time whether you’re standing in a line, waiting for a bus,
spending time with your friends or in the middle of a boring lecture. The
friendliness of Tic Tac Toe makes it ideal as a pedagogical tool for teaching
and learning the concepts of good sportsmanship and the branch of artificial
intelligence that deals with the searching of game trees.
1.2 Purpose
The purpose of developing a Tic Tac Toe application is to computerize the
traditional way of playing Tic Tac Toe and give it a modern technological
touch. Another purpose for developing this app is to make this traditional
game famous among today’s exclusively tech loving kids.
4 | P a g e
2. AIMS AND OBJECTIVES
Following are the objectives of this project:
 To be familiar with Object Oriented Programming (OOP).
 To learn about android device and android app development.
 To learn process ofproject development.
 To implement AI based MINIMAX ALGORITHM in digital device.
 To eliminate the use of paper for playing TIC-TAC-TOE.
The aim of this project is to develop a Tic-Tac-Toe game for mobile device.
The game is supposed to consist of two parts, one a single player game (a
player against a system), and the other a multi-player game (two players on
their mobile devices, playing against each other).
5 | P a g e
3. METHODOLOGY
3.1 FLOW CHART
Start
Game
Mode
Single
Or
Multi?
A
Enter
name
P1 &P2
Move
Player2
wins
Game
is Tie
Player1
wins
Game
is Tie
End
Check
whose
Turn?
Move
Check
Win?
Check
Win?
Check
Tie?
Check
Tie?
Multi
Single
P1P2
F F
T T
TT
Play
Again?
F
F F
T
This symbol is
connecting symbol for
process and sub
process
6 | P a g e
A
Enter
name
?
Move
Comp
wins
Game
is Tie
Player1
wins
Game
is Tie
End
Check
whose
Turn?
Move
Check
Win?
Check
Win?
Check
Tie?
Check
Tie?
Single
P1Comp
F F
T T
TT
Play
Again?
F
F F
T
This symbol is
connecting symbol for
process and sub
process
Fig 1.1: Flow chart of Tic Tac Toe
7 | P a g e
3.2 USE CASE DIAGRAM
<<include>>
Select Game type
Enter Name
Start
Take Move
Check Game Over
Result
Play Again
Player 1 Player 2
<<include>>
<<include>>
Fig 1.2.a: Use case diagram of Player VS Player
8 | P a g e
<<include>>
Select Game type
Enter Name
Start
Take Move
Check Game Over
Result
Play Again
User
Computer
<<include>>
<<include>>
Fig 1.2.b: Use case diagram for User VS Computer
9 | P a g e
4. ALGORITHM
In case of AI move
 Finding the Best Move :
We shall be introducing a new function called findBestMove() . This function
evaluates all the available moves using minimax() and then returns the best
move the maximizer can make.
function findBestMove (Board):
bestMove = NULL
for each move is board :
if current move is better than bestMove
bestMove = current Move
return bestMove
 To check whether or not the current move is better than the best move we
take the help of minimax() function which will consider all the possible
ways the game can go and returns the best value for that move, assuming
the opponent also plays optimally.
function minimax (board , depth ,isMaximizingPlayer):
if current board state is a terminal state:
return value of the board
if isMaximizingPlayer :
bestVal = -INFINITY
for each move in board:
value =minimax(board , depth+1 ,false)
bestVal = max(bestVal ,value)
return bestVal
else :
bestVal =+INFINITY
10 | P a g e
for each move in board :
value = minimax(board , depth+1 ,true)
bestVal = min (bestVal ,value)
return bestVal
 To check whether the game is over and to make sure there are no moves
left we use isMovesLeft() function.
function isMovesLeft (board):
for each cell in board:
if current cell is empty:
return ture
return false
11 | P a g e
5. REFERENCES
 J. Horton, “Android Programming for Beginners”, Packt Publishing Ltd,
2015.
Y. D. Liang, “Introduction to Java Programming, Pearson Education, 2015.
I. Sommerville, “Software Engineering”, Pearson Education, 2016.
“Android Tutorial”, http://www.tutorialspoint.com/, N.P., n.d. Web, 15
May 2016.

Mini Max Algorithm Proposal Document

  • 1.
    A MINOR PROJECT PROPOSAL ON MINIMAXALGORITHM BASED TIC-TAC-TOE SUBMITTED BY: SAMEER BHATTARAI (BCT/071/38) SAROJ RAJ SHARMA (BCT/071/41) SHEETAL BARAL (BCT/071/43) UJJAWAL POUDEL (BCT/071/48) DEPARTMENT OF ELECTRONICS AND COMPUTER ENGINEERING DHARAN, NEPAL TRIBHUVAN UNIVERSITY INSTITUTE OF ENGINEERING PURWANCHAL CAMPUS NOVEMBER, 2017
  • 2.
    2 | Pa g e TABLE OF CONTENTS 1 INTRODUCTION......................................................................................3 1.1 General Introduction.............................................................................3 1.2 Purpose.................................................................................................3 2 AIMS AND OBJECTIVES........................................................................4 3 METHODOLOGY.....................................................................................5 3.1 Flowchart..............................................................................................5 3.2 Use Case Diagram................................................................................7 4 ALGORITHM............................................................................................9 5 REFERENCES.........................................................................................11 LIST OF FIGURES Figure 1.1 Flow chart of Tic Tac Toe………..................................................6 Figure 1.2.a Use case diagram of Player VS Player........................................7 Figure 1.2.b Use case diagram of User VS Computer.....................................8
  • 3.
    3 | Pa g e 1. INTRODUCTION 1.1 General Introduction TodayAIis one ofthe most promising field ofcomputerscience. From solving complex problems to doing certain things better than most humans, it has many applications. Such capability of AI and its wide use has led us into working on this project which will be based on “MINIMAX ALGORITHM”, a popular algorithm basically used in game playing. The project will try to demonstrate the implementation of an AI algorithm and it effectiveness against a human opponent in game playing. Tic Tac Toe (also known as noughts and crosses orXs and Os) is a paper-and-pencil 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 of their marks in a horizontal, vertical, or diagonal row wins the game. The following example game is won by the first player, X: fig (1.a) Winning condition of Player X Tic Tac Toe is played by young children and adults alike. It is a great way to pass your free time whether you’re standing in a line, waiting for a bus, spending time with your friends or in the middle of a boring lecture. The friendliness of Tic Tac Toe makes it ideal as a pedagogical tool for teaching and learning the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. 1.2 Purpose The purpose of developing a Tic Tac Toe application is to computerize the traditional way of playing Tic Tac Toe and give it a modern technological touch. Another purpose for developing this app is to make this traditional game famous among today’s exclusively tech loving kids.
  • 4.
    4 | Pa g e 2. AIMS AND OBJECTIVES Following are the objectives of this project:  To be familiar with Object Oriented Programming (OOP).  To learn about android device and android app development.  To learn process ofproject development.  To implement AI based MINIMAX ALGORITHM in digital device.  To eliminate the use of paper for playing TIC-TAC-TOE. The aim of this project is to develop a Tic-Tac-Toe game for mobile device. The game is supposed to consist of two parts, one a single player game (a player against a system), and the other a multi-player game (two players on their mobile devices, playing against each other).
  • 5.
    5 | Pa g e 3. METHODOLOGY 3.1 FLOW CHART Start Game Mode Single Or Multi? A Enter name P1 &P2 Move Player2 wins Game is Tie Player1 wins Game is Tie End Check whose Turn? Move Check Win? Check Win? Check Tie? Check Tie? Multi Single P1P2 F F T T TT Play Again? F F F T This symbol is connecting symbol for process and sub process
  • 6.
    6 | Pa g e A Enter name ? Move Comp wins Game is Tie Player1 wins Game is Tie End Check whose Turn? Move Check Win? Check Win? Check Tie? Check Tie? Single P1Comp F F T T TT Play Again? F F F T This symbol is connecting symbol for process and sub process Fig 1.1: Flow chart of Tic Tac Toe
  • 7.
    7 | Pa g e 3.2 USE CASE DIAGRAM <<include>> Select Game type Enter Name Start Take Move Check Game Over Result Play Again Player 1 Player 2 <<include>> <<include>> Fig 1.2.a: Use case diagram of Player VS Player
  • 8.
    8 | Pa g e <<include>> Select Game type Enter Name Start Take Move Check Game Over Result Play Again User Computer <<include>> <<include>> Fig 1.2.b: Use case diagram for User VS Computer
  • 9.
    9 | Pa g e 4. ALGORITHM In case of AI move  Finding the Best Move : We shall be introducing a new function called findBestMove() . This function evaluates all the available moves using minimax() and then returns the best move the maximizer can make. function findBestMove (Board): bestMove = NULL for each move is board : if current move is better than bestMove bestMove = current Move return bestMove  To check whether or not the current move is better than the best move we take the help of minimax() function which will consider all the possible ways the game can go and returns the best value for that move, assuming the opponent also plays optimally. function minimax (board , depth ,isMaximizingPlayer): if current board state is a terminal state: return value of the board if isMaximizingPlayer : bestVal = -INFINITY for each move in board: value =minimax(board , depth+1 ,false) bestVal = max(bestVal ,value) return bestVal else : bestVal =+INFINITY
  • 10.
    10 | Pa g e for each move in board : value = minimax(board , depth+1 ,true) bestVal = min (bestVal ,value) return bestVal  To check whether the game is over and to make sure there are no moves left we use isMovesLeft() function. function isMovesLeft (board): for each cell in board: if current cell is empty: return ture return false
  • 11.
    11 | Pa g e 5. REFERENCES  J. Horton, “Android Programming for Beginners”, Packt Publishing Ltd, 2015. Y. D. Liang, “Introduction to Java Programming, Pearson Education, 2015. I. Sommerville, “Software Engineering”, Pearson Education, 2016. “Android Tutorial”, http://www.tutorialspoint.com/, N.P., n.d. Web, 15 May 2016.