SlideShare a Scribd company logo
3
Most read
4
Most read
6
Most read
Chess Engine
Major Project Presentation
Presented By:
Guided By:
Dr. Kirti Kumari
Outline 1. Introduction
2. Background and Context
3. Objectives and Scope
4. High Level Flowchart
5. Methodology
6. Technologies Used
7. Current Progress
8. References
Introduction
Ever wondered how a simple modern computer can beat the best of grandmasters in the game
of chess?
In this presentation, I will be discussing :
● the background and context of chess engines,
● the algorithms and techniques used to create them, and
● the evaluation function that is crucial for their success
● What is a Chess Engine?
Chess engine is a computer program that can play or analyse chess.
● When did all this started?
➔ A machine capable of checkmating with a king and rook vs king was created in 1912.
➔ Alan Turing wrote the first chess-playing computer program in 1951.
➔ Chess engine development continued over the next 50 years, with hardware
advancements leading to stronger play.
➔ By 2005, chess engines surpassed the best human players in skill.
Background and Context
● Why is the thing still relevant?
➔ The game hasn’t been solved.
➔ Chess Professionals use it to analyse the positions and prepare for their matches
➔ Provides a valuable platform for testing and developing new algorithms and techniques, and
can serve as a benchmark for measuring the progress of AI research.
● How do Chess Engine work?
Uses algorithms and heuristics to make decisions about the best moves to make in a given
position.
More of it in the coming slides…
Objective
And
Scope
Objective :
● Developing a chess engine of
mid-level intelligence.
● Developing a graphical interface to
interact with the engine.
Scope :
● Limited to standard game of chess
with 8 * 8 cells.
● No time boundation
● Only two players at a time: human and
the computer
High Level
Flowchart
- Just the high level
- Each Process in the diagram
comprise their own flowchart
and complex logic
Methodology
1. Board representation
2. Move generation
3. Evaluation function
4. Search algorithms (i.e minimax, alpha-beta pruning)
5. Move ordering
6. Transposition table
1. Board Representation
There are several methods for representing a chessboard in a computer program, each with its own
advantages and disadvantages. Here’s what I choose:
Data structure:
Represented as a 2D list
Each element in the list corresponds to a row on the board
Each element within a row corresponds to a square on the board
Piece representation:
- Each piece is represented by a two-character string
- The first character represents the color of the piece
(either "w" for white or "b" for black)
- The second character represents the type of the piece
(e.g. "K" for king, "P" for pawn)
- ‘--’ means the cell is empty.
Graphical Representation:
- Represented using PyGame library using the list mentioned above.
2. Move Generation
For a given state of the game, we generate all the valid moves possible for the player.
For this I do the following:
1. Identify all pieces on the board and their positions using for loop.
2. Determine the legal moves for each piece based on the rules of chess(e.g., pawns can move forward one or
two squares on their first move, bishops move diagonally, etc.)
3. Check whether each move is legal by ensuring that it doesn't leave the player in check
4. Generate a list of all legal moves for the player
5. Consider special moves such as castling, en passant, and promotion
3. Evaluation Function
- Evaluation Function is used to evaluate the strength of each move based on various factors
- It assigns a numerical score to each move, which is then used by the engine to determine the best move
to play.
Major factors to consider in evaluation function:
Material Balance
Piece
Activity
Piece Activity
Pawn Structure King Safety
Center Control Development
For the computer to choose the best move at a given state, it searches all the valid moves upto a certain
depth and ascertain the best move based on the evaluation function provided.
Search Algos that can be used for Chess Engines are:
- MiniMax Algorithm
- Alpha-Beta Pruning
- Iterative Deepening
- Opening Book
- Endgame Tablebases
3. Search Algorithms
Mini-Max Algorithm
- Used to find the optimal move in a
two-player zero-sum game, where one
player's gain is the other player's loss.
Therefore suitable for chess
- Works by recursively evaluating each
possible move and its consequences.
- Alternates between maximizing the
score for the current player and
minimizing the score for the opponent
player at each level.
- The score is evaluated with Evaluation
Function
9
Evaluation Function
Value
An example of
MiniMax Algo with
branching factor 2 and
depth 4:
Alpha-Beta Pruning
- Optimization technique used in the
Minimax algorithm
- Reduce the number of nodes that need
to be evaluated in the Minimax
algorithm, by pruning or cutting off
branches of the game tree that are
unlikely to lead to a better outcome
- Maintains two values α and β to store
the minimum and maximum values
found during the search
- Uses these values to prune the
branches which can’t give a better
result.
9
Evaluation
Function Value
An example of
Alpha-Beta Pruning
Algo with branching
factor 2 and depth 4:
Represents Pruned
Branches
Criteria Minimax Algorithm Alpha-beta Pruning Algorithm
Time complexity
O(b^d),
- b is the branching factor
- d is the depth
Same as Minimax Algorithm, but
mostly faster due to pruning
Memory usage
Requires keeping the entire game tree in
memory More memory-efficient due to pruning
Search time Can be slow for large games
Faster than Minimax Algorithm due to
pruning
Solution optimality Provides guaranteed optimal solution
May not always provide guaranteed
optimal solution due to pruning
Opening Book
and
EndGame Tablebase
- A database of known opening positions
and endgame tactics and their best moves
is already fed to the engine
- The engine simply take the best move as
in the database.
- Database Eg.:
https://www.chess.com/openings
Technologies Used:
Python 3.8 PyGame 2.2
Current Progress
As of now, the following features are implemented by the
program:
- Board Representation and Graphical Interface.
- Movement of pieces using mouse from the
interface.
- Undo of moves.
- Only valid moves are allowed the system. It checks
for all the valid moves possible and doesn’t admit
illegal moves.
- Special moves such as Castling, Pawn Promotion,
En Passant are also taken care of.
- The computer can play random legal moves.
The following features are to be implemented:
- Strong Moves using Evaluation Function and
Search Algos
- Using Move Ordering and Transposition Table
for better search performance
- Testing the performance of the engine
- Better GUI Logging and Interaction
File System:
Contains Configuration variables
Renders the board and the pieces
Stores the current state of the game
Manages the user interactions from
the GUI
Driver function
Represent the move made
Generate all the valid move in the
given state of the game
Contains the images of the pieces
ScreenShots:
Initial Screen: During the Game:
References ● Chess.com Article on chess engine
https://www.chess.com/article/view/computer-chess-engines
● Developing a Chess Engine Thesis:
https://www.theseus.fi/bitstream/handle/10024/502571/Develop
ing%20Chess%20Engine.pdf?sequence=2&isAllowed=y
● Dissecting Stockfish(Chess Engine) Article on Medium:
https://towardsdatascience.com/dissecting-stockfish-part-1-in-de
pth-look-at-a-chess-engine-7fddd1d83579
● Chess Programming Wiki:
https://www.chessprogramming.org/Main_Page
Thank You.

More Related Content

PPTX
Operations Research - Introduction
PPT
Ecart type experimental : quelle formule choisir ?
PDF
98 ejercicios de entrenamiento de futbol (La libreta del mister)
PDF
El Girona de Pablo Machín
PPTX
A system to generate rhythms automatically for songs in rhythm game
PPTX
Amerikan Futbolu ve Avustralya Futbolu
PPT
Initiation image numérique & photoshop
PPTX
Situations à dominante tactique double
Operations Research - Introduction
Ecart type experimental : quelle formule choisir ?
98 ejercicios de entrenamiento de futbol (La libreta del mister)
El Girona de Pablo Machín
A system to generate rhythms automatically for songs in rhythm game
Amerikan Futbolu ve Avustralya Futbolu
Initiation image numérique & photoshop
Situations à dominante tactique double

What's hot (20)

PDF
Ch1 traitement de texte
PDF
optimisation cours.pdf
PDF
recherche operationnelle
PPTX
Soutenance du pfe
PDF
Cours informatique éléments de présentation - 8ème
PDF
TECHNICAL - TACTICAL FOOTBALL PERIODIZATION
PDF
Les frappes à mi-court
PPTX
PDF
devoir traitement d'images
PPTX
Audios in Unity
PPT
Ch2 representation
PDF
Cahier 1er technique 2023.pdf
PDF
U.S. Soccer Coaching Curriculum
DOC
Bac blanc base de données
PPT
Football 101 for Erin
PDF
Le périphérique souris
PDF
Guida del pallone e dribbling nello spazio
PPTX
Coordination et vitesse du smash
PDF
US Youth Soccer Practice Activities (U6-U8)
Ch1 traitement de texte
optimisation cours.pdf
recherche operationnelle
Soutenance du pfe
Cours informatique éléments de présentation - 8ème
TECHNICAL - TACTICAL FOOTBALL PERIODIZATION
Les frappes à mi-court
devoir traitement d'images
Audios in Unity
Ch2 representation
Cahier 1er technique 2023.pdf
U.S. Soccer Coaching Curriculum
Bac blanc base de données
Football 101 for Erin
Le périphérique souris
Guida del pallone e dribbling nello spazio
Coordination et vitesse du smash
US Youth Soccer Practice Activities (U6-U8)
Ad

Similar to Chess Engine (20)

PDF
Ibm's deep blue chess grandmaster chips
PPTX
Artificial Intelligence gaming techniques
PDF
Alpha go 16110226_김영우
PPT
Project on ai gaming
PDF
International journal of engineering issues vol 2015 - no 2 - paper1
PPT
Topic - 6 (Game Playing).ppt
PPTX
Initial design (Game Architecture)
PDF
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
PPTX
98 374 Lesson 06-slides
PDF
A realtime classic chess game [proposal]
PDF
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
PPTX
Mini-Max Algorithm in Artificial Intelligence.pptx
PDF
Connect (4|n)
PPTX
Capgemini 1
PDF
An analysis of minimax search and endgame databases in evolving awale game pl...
PDF
AN ANALYSIS OF MINIMAX SEARCH AND ENDGAME DATABASES IN EVOLVING AWALE GAME PL...
PPTX
98 374 Lesson 04-slides
PPTX
AI- to eat boiled egg and cheese Unit-II.pptx
PDF
Supersize Your Production Pipe
PPTX
Tales from the Optimization Trenches - Unite Copenhagen 2019
Ibm's deep blue chess grandmaster chips
Artificial Intelligence gaming techniques
Alpha go 16110226_김영우
Project on ai gaming
International journal of engineering issues vol 2015 - no 2 - paper1
Topic - 6 (Game Playing).ppt
Initial design (Game Architecture)
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engi...
98 374 Lesson 06-slides
A realtime classic chess game [proposal]
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
Mini-Max Algorithm in Artificial Intelligence.pptx
Connect (4|n)
Capgemini 1
An analysis of minimax search and endgame databases in evolving awale game pl...
AN ANALYSIS OF MINIMAX SEARCH AND ENDGAME DATABASES IN EVOLVING AWALE GAME PL...
98 374 Lesson 04-slides
AI- to eat boiled egg and cheese Unit-II.pptx
Supersize Your Production Pipe
Tales from the Optimization Trenches - Unite Copenhagen 2019
Ad

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Trump Administration's workforce development strategy
PPTX
Cell Types and Its function , kingdom of life
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Updated Idioms and Phrasal Verbs in English subject
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
master seminar digital applications in india
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Classroom Observation Tools for Teachers
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cell Structure & Organelles in detailed.
STATICS OF THE RIGID BODIES Hibbelers.pdf
What if we spent less time fighting change, and more time building what’s rig...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Trump Administration's workforce development strategy
Cell Types and Its function , kingdom of life
Yogi Goddess Pres Conference Studio Updates
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Complications of Minimal Access Surgery at WLH
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Updated Idioms and Phrasal Verbs in English subject
2.FourierTransform-ShortQuestionswithAnswers.pdf
master seminar digital applications in india
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Classroom Observation Tools for Teachers
Anesthesia in Laparoscopic Surgery in India
Cell Structure & Organelles in detailed.

Chess Engine

  • 1. Chess Engine Major Project Presentation Presented By: Guided By: Dr. Kirti Kumari
  • 2. Outline 1. Introduction 2. Background and Context 3. Objectives and Scope 4. High Level Flowchart 5. Methodology 6. Technologies Used 7. Current Progress 8. References
  • 3. Introduction Ever wondered how a simple modern computer can beat the best of grandmasters in the game of chess? In this presentation, I will be discussing : ● the background and context of chess engines, ● the algorithms and techniques used to create them, and ● the evaluation function that is crucial for their success
  • 4. ● What is a Chess Engine? Chess engine is a computer program that can play or analyse chess. ● When did all this started? ➔ A machine capable of checkmating with a king and rook vs king was created in 1912. ➔ Alan Turing wrote the first chess-playing computer program in 1951. ➔ Chess engine development continued over the next 50 years, with hardware advancements leading to stronger play. ➔ By 2005, chess engines surpassed the best human players in skill. Background and Context
  • 5. ● Why is the thing still relevant? ➔ The game hasn’t been solved. ➔ Chess Professionals use it to analyse the positions and prepare for their matches ➔ Provides a valuable platform for testing and developing new algorithms and techniques, and can serve as a benchmark for measuring the progress of AI research. ● How do Chess Engine work? Uses algorithms and heuristics to make decisions about the best moves to make in a given position. More of it in the coming slides…
  • 6. Objective And Scope Objective : ● Developing a chess engine of mid-level intelligence. ● Developing a graphical interface to interact with the engine. Scope : ● Limited to standard game of chess with 8 * 8 cells. ● No time boundation ● Only two players at a time: human and the computer
  • 7. High Level Flowchart - Just the high level - Each Process in the diagram comprise their own flowchart and complex logic
  • 8. Methodology 1. Board representation 2. Move generation 3. Evaluation function 4. Search algorithms (i.e minimax, alpha-beta pruning) 5. Move ordering 6. Transposition table
  • 9. 1. Board Representation There are several methods for representing a chessboard in a computer program, each with its own advantages and disadvantages. Here’s what I choose: Data structure: Represented as a 2D list Each element in the list corresponds to a row on the board Each element within a row corresponds to a square on the board Piece representation: - Each piece is represented by a two-character string - The first character represents the color of the piece (either "w" for white or "b" for black) - The second character represents the type of the piece (e.g. "K" for king, "P" for pawn) - ‘--’ means the cell is empty. Graphical Representation: - Represented using PyGame library using the list mentioned above.
  • 10. 2. Move Generation For a given state of the game, we generate all the valid moves possible for the player. For this I do the following: 1. Identify all pieces on the board and their positions using for loop. 2. Determine the legal moves for each piece based on the rules of chess(e.g., pawns can move forward one or two squares on their first move, bishops move diagonally, etc.) 3. Check whether each move is legal by ensuring that it doesn't leave the player in check 4. Generate a list of all legal moves for the player 5. Consider special moves such as castling, en passant, and promotion
  • 11. 3. Evaluation Function - Evaluation Function is used to evaluate the strength of each move based on various factors - It assigns a numerical score to each move, which is then used by the engine to determine the best move to play. Major factors to consider in evaluation function: Material Balance Piece Activity Piece Activity
  • 12. Pawn Structure King Safety Center Control Development
  • 13. For the computer to choose the best move at a given state, it searches all the valid moves upto a certain depth and ascertain the best move based on the evaluation function provided. Search Algos that can be used for Chess Engines are: - MiniMax Algorithm - Alpha-Beta Pruning - Iterative Deepening - Opening Book - Endgame Tablebases 3. Search Algorithms
  • 14. Mini-Max Algorithm - Used to find the optimal move in a two-player zero-sum game, where one player's gain is the other player's loss. Therefore suitable for chess - Works by recursively evaluating each possible move and its consequences. - Alternates between maximizing the score for the current player and minimizing the score for the opponent player at each level. - The score is evaluated with Evaluation Function 9 Evaluation Function Value An example of MiniMax Algo with branching factor 2 and depth 4:
  • 15. Alpha-Beta Pruning - Optimization technique used in the Minimax algorithm - Reduce the number of nodes that need to be evaluated in the Minimax algorithm, by pruning or cutting off branches of the game tree that are unlikely to lead to a better outcome - Maintains two values α and β to store the minimum and maximum values found during the search - Uses these values to prune the branches which can’t give a better result. 9 Evaluation Function Value An example of Alpha-Beta Pruning Algo with branching factor 2 and depth 4: Represents Pruned Branches
  • 16. Criteria Minimax Algorithm Alpha-beta Pruning Algorithm Time complexity O(b^d), - b is the branching factor - d is the depth Same as Minimax Algorithm, but mostly faster due to pruning Memory usage Requires keeping the entire game tree in memory More memory-efficient due to pruning Search time Can be slow for large games Faster than Minimax Algorithm due to pruning Solution optimality Provides guaranteed optimal solution May not always provide guaranteed optimal solution due to pruning
  • 17. Opening Book and EndGame Tablebase - A database of known opening positions and endgame tactics and their best moves is already fed to the engine - The engine simply take the best move as in the database. - Database Eg.: https://www.chess.com/openings
  • 19. Current Progress As of now, the following features are implemented by the program: - Board Representation and Graphical Interface. - Movement of pieces using mouse from the interface. - Undo of moves. - Only valid moves are allowed the system. It checks for all the valid moves possible and doesn’t admit illegal moves. - Special moves such as Castling, Pawn Promotion, En Passant are also taken care of. - The computer can play random legal moves. The following features are to be implemented: - Strong Moves using Evaluation Function and Search Algos - Using Move Ordering and Transposition Table for better search performance - Testing the performance of the engine - Better GUI Logging and Interaction
  • 20. File System: Contains Configuration variables Renders the board and the pieces Stores the current state of the game Manages the user interactions from the GUI Driver function Represent the move made Generate all the valid move in the given state of the game Contains the images of the pieces
  • 22. References ● Chess.com Article on chess engine https://www.chess.com/article/view/computer-chess-engines ● Developing a Chess Engine Thesis: https://www.theseus.fi/bitstream/handle/10024/502571/Develop ing%20Chess%20Engine.pdf?sequence=2&isAllowed=y ● Dissecting Stockfish(Chess Engine) Article on Medium: https://towardsdatascience.com/dissecting-stockfish-part-1-in-de pth-look-at-a-chess-engine-7fddd1d83579 ● Chess Programming Wiki: https://www.chessprogramming.org/Main_Page