SlideShare a Scribd company logo
1 of 33
Guided By
Dr Nishant Shrivastava
Head of Department
Presented By
Tanushree Sharma
(8818103001)
Amit Verma
(8818103004)
CONTENT
3
Objective
Scope
Building Blocks of Chess Engine
Introduction
Flow Charts
Tools and Techniques
Home Page
Board Representation
Move Generation Implementation
AI Algorithms
Integration of AI Algorithms
Future Enhancement
The objective is to checkmate the
opponent’s king by placing it under an
unavoidable threat of capture.
4
The scope of our project is
limited for two players to play
chess as real in computer.
And a player also able to play
with computer according to the
intelligence we gave it.
5
Building Blocks of Chess
Chess
Board
Possible
Moves
Move
Choose
Animate
Move
Update
7
Chess is a game played between two
opponents on opposite sides of a
board containing 64 squares of
alternating colors.
Each player has 16 pieces: 2 rooks, 1
king, 1 queen, 2 bishops, 2 knights
and 8 pawns.
Tools & Techniques
8
Python 3 It is a General-purpose dynamic programming language
which provides the high-level readability and it is interpreted. In our
project we use python for calculate the players's move.
Pygame Pygame is a Python framework for game programming. We
use pygame in our project for creating, updating and handling GUI.
Start
Gave Move
Move
is
legal
Move applied
End
True​
False
False​
Stale/
Chec
kmate
Playing
Steps
(Human)
True​
10
Start User's Move
Move is
Legal
Move Generator
Move Evaluation
Best Move
Stale/Chec
k mate
End
Playing Steps (AI)
True
End
True
False
Stale/Chec
k mate
True
Fals
e
False
Home Page
11
The user may play against a friend or the computer.
Representation of Chess Board
12
Move Generation
13
After representation of board we shift to the move
generator. Each piece in chess has its own list of
moves, therefore for each piece is necessary to
write a specific function to generate the moves.
Here are snapshots of chess piece's move
from are code.
Pawn's Move
14
Knight's Move
15
Bishop's Move
16
Queen's Move
17
King's Move
18
Rook's Move
19
we should introduce two things to computer for making the
game Intelligent which will make the game to do optimal
moves
 A technique to choose the move to make amongest all legal
possibilities, so that it can choose a move instead of being
forced to pick one at random.
 A way to compare moves and positions, so that it makes
intelligent choices. 20
AI Algorithms
21
Mini-Max Algorithm
22
The Mini-max algorithm is a way to find an optimal move in a two player game.
Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-
making and game theory. It provides an optimal move for the player assuming that
opponent is also playing optimally.
The minimax algorithm performs a depth-first search algorithm for the exploration of the
complete game tree.
The minimax algorithm proceeds all the way down to the terminal node of the tree, then
backtrack the tree as the recursion
Properties of Mini-Max algorithm:
23
Complete- Min-Max algorithm is Complete. It will definitely find a solution (if exist), in the finite search
tree.
Optimal- Min-Max algorithm is optimal if both opponents are playing optimally.
Time complexity- As it performs DFS for the game-tree, so the time complexity of Min-Max algorithm
is O(bm), where b is branching factor of the game-tree, and m is the maximum depth of the tree.
Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS which is O(bm).
Working of Mini-max
24
 Minimax: Assume that both White and Black plays
the best moves. We maximizes White’s score
 Perform a depth-first search and evaluate the leaf
nodes
 Choose child node with highest value if it is White to
move
 Choose child node with lowest value if it is Black to
move
 Branching factor is 40 in a typical chess position
Mini – max Algorithm Graph
25
Pseudocode
26
function minimax(node, depth, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, minimax(child, depth − 1, FALSE))
return value
else (* minimizing player *)
value := +∞
for each child of node do
value := min(value, minimax(child, depth − 1, TRUE))
return value
Pruning Techniques
27
The complexity of
mini-max algorithm
for d ply ahead is
O(b*b*…*b)
= O(b^d).
With a branching
factor (b) of 40 it is
crucial to be able to
prune the search
tree.
Alpha-Beta Pruning
28
Alpha-Beta Pruning is a way of finding the minimum solution.
Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization technique for the minimax algorithm.
Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the tree leaves but also entire sub-tree.
parameter can be defined as:
Alpha : The best (highest-value) choice we have found so far at any point along the path of Maximizer. The initial value of alpha
is -∞.
Beta: The best (lowest-value) choice we have found so far at any point along the path of Minimizer. The initial value of beta is +∞.
Alpha-Beta Pruning
29
The Alpha-beta pruning to a standard minimax algorithm returns the same move as the
standard algorithm does, but it removes all the nodes which are not really affecting the
final decision but making algorithm slow. Hence by pruning these nodes, it makes the
algorithm fast.
If Beta is less than Alpha, then the position will never occur assuming best play
If search tree is evaluated left to right, then we can skip the greyed- out sub trees
Mini-max with Alpha Beta Pruning Graph
30
Pseudocode
31
function alphabeta(node, depth, α, β, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
α := max(α, value)
if α ≥ β then
break (* β cutoff *)
return value
else
value := +∞
for each child of node do
value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
β := min(β, value)
if β ≤ α then
break (* α cutoff *)
return value
Future Enhancement
32
Thank You

More Related Content

What's hot (20)

Tic tac toe simple ai game
Tic tac toe simple ai gameTic tac toe simple ai game
Tic tac toe simple ai game
 
tic-tac-toe: Game playing
 tic-tac-toe: Game playing tic-tac-toe: Game playing
tic-tac-toe: Game playing
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 
Control Strategies in AI
Control Strategies in AI Control Strategies in AI
Control Strategies in AI
 
02 order of growth
02 order of growth02 order of growth
02 order of growth
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
 
Sorting network
Sorting networkSorting network
Sorting network
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6
 
Fuzzy inference systems
Fuzzy inference systemsFuzzy inference systems
Fuzzy inference systems
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
 
Compiler design lab programs
Compiler design lab programs Compiler design lab programs
Compiler design lab programs
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
Minimax
MinimaxMinimax
Minimax
 

Similar to Chess engine presentation

Adversarial search
Adversarial searchAdversarial search
Adversarial searchpramod naik
 
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15  Min Max Algorithm.pptxAI3391 Artificial intelligence Session 15  Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptxAsst.prof M.Gokilavani
 
12 adversal search
12 adversal search12 adversal search
12 adversal searchTianlu Wang
 
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCEudayvanand
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.pptssuser148ae0
 
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAsst.prof M.Gokilavani
 
Min Max Artificial Intelligence algorithm
Min Max Artificial Intelligence algorithmMin Max Artificial Intelligence algorithm
Min Max Artificial Intelligence algorithmvipulkondekar
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesSamiaAziz4
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxNayanChandak1
 
Topic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptTopic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptSabrinaShanta2
 
9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptxumairshams6
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchDheerendra k
 

Similar to Chess engine presentation (20)

AI_unit3.pptx
AI_unit3.pptxAI_unit3.pptx
AI_unit3.pptx
 
Two player games
Two player gamesTwo player games
Two player games
 
1.game
1.game1.game
1.game
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15  Min Max Algorithm.pptxAI3391 Artificial intelligence Session 15  Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptx
 
12 adversal search
12 adversal search12 adversal search
12 adversal search
 
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
 
Capgemini 1
Capgemini 1Capgemini 1
Capgemini 1
 
adversial search.pptx
adversial search.pptxadversial search.pptx
adversial search.pptx
 
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppthanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
hanoosh-tictactoeqqqqqqqaaaaaaaaaaaa.ppt
 
AI Lecture 5 (game playing)
AI Lecture 5 (game playing)AI Lecture 5 (game playing)
AI Lecture 5 (game playing)
 
cai
caicai
cai
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
 
Min Max Artificial Intelligence algorithm
Min Max Artificial Intelligence algorithmMin Max Artificial Intelligence algorithm
Min Max Artificial Intelligence algorithm
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
 
Topic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).pptTopic - 6 (Game Playing).ppt
Topic - 6 (Game Playing).ppt
 
9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 

Recently uploaded

Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 

Recently uploaded (20)

Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 

Chess engine presentation

  • 1.
  • 2. Guided By Dr Nishant Shrivastava Head of Department Presented By Tanushree Sharma (8818103001) Amit Verma (8818103004)
  • 3. CONTENT 3 Objective Scope Building Blocks of Chess Engine Introduction Flow Charts Tools and Techniques Home Page Board Representation Move Generation Implementation AI Algorithms Integration of AI Algorithms Future Enhancement
  • 4. The objective is to checkmate the opponent’s king by placing it under an unavoidable threat of capture. 4
  • 5. The scope of our project is limited for two players to play chess as real in computer. And a player also able to play with computer according to the intelligence we gave it. 5
  • 6. Building Blocks of Chess Chess Board Possible Moves Move Choose Animate Move Update
  • 7. 7 Chess is a game played between two opponents on opposite sides of a board containing 64 squares of alternating colors. Each player has 16 pieces: 2 rooks, 1 king, 1 queen, 2 bishops, 2 knights and 8 pawns.
  • 8. Tools & Techniques 8 Python 3 It is a General-purpose dynamic programming language which provides the high-level readability and it is interpreted. In our project we use python for calculate the players's move. Pygame Pygame is a Python framework for game programming. We use pygame in our project for creating, updating and handling GUI.
  • 10. 10 Start User's Move Move is Legal Move Generator Move Evaluation Best Move Stale/Chec k mate End Playing Steps (AI) True End True False Stale/Chec k mate True Fals e False
  • 11. Home Page 11 The user may play against a friend or the computer.
  • 13. Move Generation 13 After representation of board we shift to the move generator. Each piece in chess has its own list of moves, therefore for each piece is necessary to write a specific function to generate the moves. Here are snapshots of chess piece's move from are code.
  • 20. we should introduce two things to computer for making the game Intelligent which will make the game to do optimal moves  A technique to choose the move to make amongest all legal possibilities, so that it can choose a move instead of being forced to pick one at random.  A way to compare moves and positions, so that it makes intelligent choices. 20
  • 22. Mini-Max Algorithm 22 The Mini-max algorithm is a way to find an optimal move in a two player game. Mini-max algorithm is a recursive or backtracking algorithm which is used in decision- making and game theory. It provides an optimal move for the player assuming that opponent is also playing optimally. The minimax algorithm performs a depth-first search algorithm for the exploration of the complete game tree. The minimax algorithm proceeds all the way down to the terminal node of the tree, then backtrack the tree as the recursion
  • 23. Properties of Mini-Max algorithm: 23 Complete- Min-Max algorithm is Complete. It will definitely find a solution (if exist), in the finite search tree. Optimal- Min-Max algorithm is optimal if both opponents are playing optimally. Time complexity- As it performs DFS for the game-tree, so the time complexity of Min-Max algorithm is O(bm), where b is branching factor of the game-tree, and m is the maximum depth of the tree. Space Complexity- Space complexity of Mini-max algorithm is also similar to DFS which is O(bm).
  • 24. Working of Mini-max 24  Minimax: Assume that both White and Black plays the best moves. We maximizes White’s score  Perform a depth-first search and evaluate the leaf nodes  Choose child node with highest value if it is White to move  Choose child node with lowest value if it is Black to move  Branching factor is 40 in a typical chess position
  • 25. Mini – max Algorithm Graph 25
  • 26. Pseudocode 26 function minimax(node, depth, maximizingPlayer) is if depth = 0 or node is a terminal node then return the heuristic value of node if maximizingPlayer then value := −∞ for each child of node do value := max(value, minimax(child, depth − 1, FALSE)) return value else (* minimizing player *) value := +∞ for each child of node do value := min(value, minimax(child, depth − 1, TRUE)) return value
  • 27. Pruning Techniques 27 The complexity of mini-max algorithm for d ply ahead is O(b*b*…*b) = O(b^d). With a branching factor (b) of 40 it is crucial to be able to prune the search tree.
  • 28. Alpha-Beta Pruning 28 Alpha-Beta Pruning is a way of finding the minimum solution. Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization technique for the minimax algorithm. Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the tree leaves but also entire sub-tree. parameter can be defined as: Alpha : The best (highest-value) choice we have found so far at any point along the path of Maximizer. The initial value of alpha is -∞. Beta: The best (lowest-value) choice we have found so far at any point along the path of Minimizer. The initial value of beta is +∞.
  • 29. Alpha-Beta Pruning 29 The Alpha-beta pruning to a standard minimax algorithm returns the same move as the standard algorithm does, but it removes all the nodes which are not really affecting the final decision but making algorithm slow. Hence by pruning these nodes, it makes the algorithm fast. If Beta is less than Alpha, then the position will never occur assuming best play If search tree is evaluated left to right, then we can skip the greyed- out sub trees
  • 30. Mini-max with Alpha Beta Pruning Graph 30
  • 31. Pseudocode 31 function alphabeta(node, depth, α, β, maximizingPlayer) is if depth = 0 or node is a terminal node then return the heuristic value of node if maximizingPlayer then value := −∞ for each child of node do value := max(value, alphabeta(child, depth − 1, α, β, FALSE)) α := max(α, value) if α ≥ β then break (* β cutoff *) return value else value := +∞ for each child of node do value := min(value, alphabeta(child, depth − 1, α, β, TRUE)) β := min(β, value) if β ≤ α then break (* α cutoff *) return value