SlideShare a Scribd company logo
Chess engine presentation
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

PDF
intelligent Chess game
PPTX
Lecture 23 alpha beta pruning
PPTX
Tic tac toe simple ai game
PPTX
Chess Engine Programming
PPTX
Adversarial search
PPTX
Alpha beta pruning in ai
PPTX
Alpha beta
PPT
Swarm intelligence algorithms
intelligent Chess game
Lecture 23 alpha beta pruning
Tic tac toe simple ai game
Chess Engine Programming
Adversarial search
Alpha beta pruning in ai
Alpha beta
Swarm intelligence algorithms

What's hot (20)

PPTX
Adversarial search
PPTX
Min-Max algorithm
PDF
Continuous control with deep reinforcement learning (DDPG)
PPTX
Minmax Algorithm In Artificial Intelligence slides
PPTX
Speaker Recognition using Gaussian Mixture Model
PPT
Game Playing in Artificial Intelligence
PPTX
AI_Session 7 Greedy Best first search algorithm.pptx
PPT
ch_5 Game playing Min max and Alpha Beta pruning.ppt
PPTX
Adversarial search with Game Playing
PDF
Naive Bayes Classifier Tutorial | Naive Bayes Classifier Example | Naive Baye...
PPTX
Minimax
DOCX
Os lab file c programs
PPTX
Feed Forward Neural Network.pptx
PPTX
Deep Reinforcement Learning
PPTX
Optimization/Gradient Descent
PPTX
Gradient descent method
PDF
Naive Bayes
PDF
AI 7 | Constraint Satisfaction Problem
PPT
finding Min and max element from given array using divide & conquer
PDF
R Programming language model test paper
Adversarial search
Min-Max algorithm
Continuous control with deep reinforcement learning (DDPG)
Minmax Algorithm In Artificial Intelligence slides
Speaker Recognition using Gaussian Mixture Model
Game Playing in Artificial Intelligence
AI_Session 7 Greedy Best first search algorithm.pptx
ch_5 Game playing Min max and Alpha Beta pruning.ppt
Adversarial search with Game Playing
Naive Bayes Classifier Tutorial | Naive Bayes Classifier Example | Naive Baye...
Minimax
Os lab file c programs
Feed Forward Neural Network.pptx
Deep Reinforcement Learning
Optimization/Gradient Descent
Gradient descent method
Naive Bayes
AI 7 | Constraint Satisfaction Problem
finding Min and max element from given array using divide & conquer
R Programming language model test paper
Ad

Similar to Chess engine presentation (20)

PDF
Chess Engine
PDF
chess-algorithms-theory-and-practice_ver2017.pdf
PPTX
AI_unit3.pptx
PDF
Games.4
PDF
chess-180927202627.pdf
PPT
Artificial intelligence games
PDF
I. Mini-Max Algorithm in AI
PPT
artificial intelligence and Game development
PPT
AI.ppt
PPTX
Minmax and alpha beta pruning.pptx
PPT
M6 game
PPT
Adversarial Search and Game-Playing .ppt
PPTX
AI subject - Game Theory and cps ppt pptx
PPT
Topic - 6 (Game Playing).ppt
PPT
cs-171-07-Games and Adversarila Search.ppt
PPT
Artificial Intelligence Adversarial Search.ppt
PPT
AI Lecture 5 (game playing)
PDF
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
PDF
Adversial-search.pdf topic of AI/ML for Diploma students
Chess Engine
chess-algorithms-theory-and-practice_ver2017.pdf
AI_unit3.pptx
Games.4
chess-180927202627.pdf
Artificial intelligence games
I. Mini-Max Algorithm in AI
artificial intelligence and Game development
AI.ppt
Minmax and alpha beta pruning.pptx
M6 game
Adversarial Search and Game-Playing .ppt
AI subject - Game Theory and cps ppt pptx
Topic - 6 (Game Playing).ppt
cs-171-07-Games and Adversarila Search.ppt
Artificial Intelligence Adversarial Search.ppt
AI Lecture 5 (game playing)
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
Adversial-search.pdf topic of AI/ML for Diploma students
Ad

Recently uploaded (20)

PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Current and future trends in Computer Vision.pptx
PDF
Well-logging-methods_new................
PDF
737-MAX_SRG.pdf student reference guides
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
DOCX
573137875-Attendance-Management-System-original
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
composite construction of structures.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
web development for engineering and engineering
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
III.4.1.2_The_Space_Environment.p pdffdf
Current and future trends in Computer Vision.pptx
Well-logging-methods_new................
737-MAX_SRG.pdf student reference guides
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
573137875-Attendance-Management-System-original
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
UNIT 4 Total Quality Management .pptx
OOP with Java - Java Introduction (Basics)
composite construction of structures.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Foundation to blockchain - A guide to Blockchain Tech
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Automation-in-Manufacturing-Chapter-Introduction.pdf
web development for engineering and engineering
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

Chess engine presentation

  • 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