0% found this document useful (0 votes)
18 views148 pages

Cs217 PC Search in Chess Week7 17feb25

The document covers concepts in Predicate Calculus and its application in artificial intelligence, particularly in resolution and refutation methods. It discusses the formalization of propositional calculus, soundness, completeness, and consistency, along with inferencing techniques such as forward and backward chaining. Additionally, it provides examples, including the Himalayan Club problem, to illustrate the practical use of these concepts in knowledge representation and reasoning.

Uploaded by

sanchita.iitb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views148 pages

Cs217 PC Search in Chess Week7 17feb25

The document covers concepts in Predicate Calculus and its application in artificial intelligence, particularly in resolution and refutation methods. It discusses the formalization of propositional calculus, soundness, completeness, and consistency, along with inferencing techniques such as forward and backward chaining. Additionally, it provides examples, including the Himalayan Club problem, to illustrate the practical use of these concepts in knowledge representation and reasoning.

Uploaded by

sanchita.iitb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 148

CS217: Artificial Intelligence and

Machine Learning
(associated lab: CS240)

Pushpak Bhattacharyya
CSE Dept.,
IIT Bombay
Week7 of 17feb25, Predicate Calculus,
Search in Chess
Main points covered: week6 of
10feb25
Important pointes associated with FFNN BP

Local Minima

Momentum Factor

Symmetry Breaking
Hilbert's formalization of propositional calculus
1. Elements are propositions : Capital letters
2. Operator is only one :  (called implies)
3. Special symbol F (called 'false')
4. Two other symbols : '(' and ')'
5. Well formed formula is constructed according to the grammar
WFF P|F|WFFWFF
6. Inference rule : only one
Given AB and
A
write B
known as MODUS PONENS
7. Axioms : Starting structures
A1: ( A  ( B  A))

A2: (( A  ( B  C ))  (( A  B)  ( A  C )))

A3 ((( A  F )  F )  A)

This formal system defines the propositional calculus


A very useful theorem (Actually a meta
theorem, called deduction theorem)
Statement
If
A1, A2, A3 ............. An ├ B
then
A1, A2, A3, ...............An-1├ An  B

├ is read as 'derives'

Given
A1 A1
A2 A2
A3 A3
. .
. .
. .
. .
An An-1
B An  B
Picture 1 Picture 2
Soundness, Completeness &
Consistency

Soundness

Syntactic Semantic
World World
---------- ----------
Valuation,
Theorems,
Tautology
Proofs
Completeness

* *
Consistency
The System should not be able to

prove both P and ~P, i.e., should not be

able to derive

F
End of main points
Predicate calculus
Insight into resolution
Resolution - Refutation
 man(x) → mortal(x)
 Convert to clausal form
 ~man(shakespeare) \/ mortal(x)
 Clauses in the knowledge base
 ~man(shakespeare) \/ mortal(x)
 man(shakespeare)
 mortal(shakespeare)
Resolution – Refutation contd
 Negate the goal
 ~man(shakespeare)
 Get a pair of resolvents
~ mortal ( shakespeare) ~ man( x)  mortal ( x)

~ man( shakespeare) man( shakespeare)


Resolution Tree

Re solvent1 Re solvent2

Re solute
Search in resolution
 Heuristics for Resolution Search
 Goal Supported Strategy
 Always start with the negated goal
 Set of support strategy
 Always one of the resolvents is the most recently
produced resolute
Inferencing in Predicate Calculus
 Forward chaining
 Given P, P  Q , to infer Q
 P, match L.H.S of
 Assert Q from R.H.S
 Backward chaining
 Q, Match R.H.S of P Q
 assert P
 Check if P exists
 Resolution – Refutation
 Negate goal
 Convert all pieces of knowledge into clausal form (disjunction of
literals)
 See if contradiction indicated by null clause can be derived
1. P
2. P  Q converted to ~ P  Q
3. ~Q
Draw the resolution tree (actually an inverted
tree). Every node is a clausal form and
branches are intermediate inference steps.
~Q ~ PQ

~P P
Theoretical basis of Resolution
 Resolution is proof by contradiction
 resolvent1 .AND. resolvent2 => resolute is a
tautology

PQ P  Q

Q
Tautologiness of Resolution
 Using Semantic Tree (assume the RHS
of  is false)
( P  Q)^ (P  Q)

Q
Contradiction

PQ
P  Q

P Q

P Q
Theoretical basis of Resolution
(cont …)
 Monotone Inference
 Size of Knowledge Base goes on increasing
as we proceed with resolution process
since intermediate resolvents added to the
knowledge base
 Non-monotone Inference
 Size of Knowledge Base does not increase
 Human beings use non-monotone
inference
Back to Himalayan Club
Himalayan Club example

 Introduction through an example (Zohar Manna,


1974):
 Problem: A, B and C belong to the Himalayan club.
Every member in the club is either a mountain
climber or a skier or both. A likes whatever B
dislikes and dislikes whatever B likes. A likes rain
and snow. No mountain climber likes rain. Every
skier likes snow. Is there a member who is a
mountain climber and not a skier?
 Given knowledge has:
 Facts

 Rules
Example contd.
 Let mc denote mountain climber and sk denotes skier.
Knowledge representation in the given problem is as follows:
1. member(A)
2. member(B)
3. member(C)
4. ∀x[member(x) → (mc(x) ∨ sk(x))]
5. ∀x[mc(x) → ~like(x,rain)]
6. ∀x[sk(x) → like(x, snow)]
7. ∀x[like(B, x) → ~like(A, x)]
8. ∀x[~like(B, x) → like(A, x)]
9. like(A, rain)
10. like(A, snow)
11. Question: ∃x[member(x) ∧ mc(x) ∧ ~sk(x)]
 We have to infer the 11th expression from the given 10.
 Done through Resolution Refutation.
Club example: Inferencing
1. member(A)
2. member(B)
3. member(C)
4. x[member ( x)  (mc( x)  sk ( x))]
– Can be written as
[member ( x)  (mc( x)  sk ( x))]
– ~ member ( x)  mc( x)  sk ( x)
5. x[ sk ( x)  lk ( x, snow)]
– ~ sk ( x)  lk ( x, snow)
6. x[mc( x) ~ lk ( x, rain)]
– ~ mc( x) ~ lk ( x, rain)
7. x[like( A, x) ~ lk ( B, x)]
– ~ like( A, x) ~ lk ( B, x)
8. x[~ lk ( A, x)  lk ( B, x)]
– lk ( A, x)  lk ( B, x)
9. lk ( A, rain)
10. lk ( A, snow)
11. x[member ( x)  mc( x) ~ sk ( x)]
– Negate– x[~ member ( x) ~ mc( x)  sk ( x)]
 Now standardize the variables apart which
results in the following
1. member(A)
2. member(B)
3. member(C)
4. ~ member ( x1)  mc( x1)  sk ( x1)
5. ~ sk ( x 2)  lk ( x 2, snow)
6. ~ mc( x3) ~ lk ( x3, rain)
7. ~ like( A, x 4) ~ lk ( B, x 4)
8. lk ( A, x5)  lk ( B, x5)
9. lk ( A, rain)
10. lk ( A, snow)
11. ~ member ( x 6) ~ mc( x 6)  sk ( x 6)
~ like( A, x 4) ~ lk ( B, x 4) lk ( A, snow) 10
7

12 ~ lk ( B, snow) ~ sk ( x 2)  lk ( x 2, snow) 5

13 ~ sk ( B) ~ member ( x1)  mc( x1)  sk ( x1) 4

14 ~ member ( B)  mc( B) member (B) 2

11
~ member ( x 6) ~ mc( x 6)  sk ( x 6) mc(B) 15

16 ~ member ( B)  sk ( B) ~ sk ( B) 13

17 ~ member ( B) member (B) 2


Well known examples in
Predicate Calculus

 Man is mortal : rule


∀x[man(x) → mortal(x)]

 shakespeare is a man
man(shakespeare)

 To infer shakespeare is mortal


mortal(shakespeare)
Predicate Calculus: origin

 Predicate calculus originated in language

Sentence

Subject Predicate

Grass is green green(grass)


Subject P : D  {T , F }
Predicate
D : Domain
Predicate Calculus: only for declarative
sentences

 Is grass green? (Interrogative)


 Oh, grass is green! (Exclamatory)
Declarative Sentence

Subject Predicate

 Grass which is supple is green


x(grass( x))  supple ( x)  green( x))
Predicate Calculus: more expressive
power than propositional calculus

 2 is even and is divisible by 2: P1


 4 is even and is divisible by 2: P2

 6 is even and is divisible by 2: P3

Generalizing,

x(( Integer( x)  even( x)  divides(2, x))


Predicate Calculus: finer than
propositional calculus
1. Finer Granularity (Grass is green, ball is green, leaf is
green (green(x)))
2. Succinct description for infinite number of statements
which would need ∝ number of properties

3 place predicate
Example: x gives y to z give(x,y,z)

4 place predicate
Example: x gives y to z through w give(x,y,z,w)
Double causative in Hindi giving
rise to higher place predicates
 जॉन ने खाना खाया
John ne khana khaya
John <CM> food ate
John ate food
eat(John, food)

 जॉन ने जैक को खाना खखलाया


John ne Jack ko khana khilaya
John <CM> Jack <CM> food fed
John fed Jack
eat(John, Jack, food)

 जॉन ने जैक को जजल के द्वारा खाना खखलाया


John ne Jack ko Jill ke dvara khana khilaya
John <CM> Jack <CM> Jill <CM> food made-to-eat
John fed Jack through Jill
eat(John, Jack, Jill, food)
PC primitive: N-ary Predicate
P (a1 ,  an )

P : D n  {T , F }

 Arguments of predicates can be


variables and constants
 Ground instances : Predicate all whose
arguments are constants
N-ary Functions

f : Dn  D
president(India) : Droupadi Murmu
 Constants & Variables : Zero-order objects
 Predicates & Functions : First-order
objects

Prime minister of Fiji is older than the president of


Fiji
older(prime_minister(Fiji), president(Fiji))
Operators
  ~   

 Universal Quantifier

 Existential Quantifier

All men are mortal


x[man( x)  mortal ( x)]
Some men are rich
x[man( x)  rich( x)]
Tautologies
~ x( p( x))  x(~ p( x))
~ x( p( x))  x(~ p( x))
 2nd tautology in English:
 Not a single man in this village is educated
implies all men in this village are
uneducated
 Tautologies are important instruments
of logic, but uninteresting statements!
Inferencing: Forward Chaining

 man(x) → mortal(x)
 Dropping the quantifier, implicitly Universal
quantification assumed
 man(shakespeare)
 Goal mortal(shakespeare)
 Found in one step
 x = shakespeare, unification
Backward Chaining

 man(x) → mortal(x)
 Goal mortal(shakespeare)
 x = shakespeare
 Travel back over and hit the fact asserted
 man(shakespeare)
Wh-Questions and Knowledge
what

where
Factoid / Declarative
who
when
which

how procedural
why Reasoning
Fixing Predicates
 Natural Sentences
<Subject> <verb> <object>

Verb(subject,object)

predicate(subject)
Examples
 Ram is a boy
 Boy(Ram)?
 Is_a(Ram,boy)?

 Ram Plays Football


 Plays(Ram,football)?
 Plays_football(Ram)?
Knowledge Representation of
Complex Sentence
 “In every city there is a thief who is
beaten by every policeman in the city”
Knowledge Representation of
Complex Sentence
 “In every city there is a thief who is
beaten by every policeman in the city”
x[city(x)  {y((thief(y)  lives_in (y, x))  z(policeman(z, x)  beaten_by (z, y)))}]
Interpretation in Logic

 Logical expressions or formulae are “FORMS”


(placeholders) for whom contents are created
through interpretation.
 Example:
F F (a)  b xP( x)  F ( x)  g x, F h( x) 

 This is a Second Order Predicate Calculus


formula.
 Quantification on ‘F’ which is a function.
Examples

 Interpretation:1
D=N (natural numbers)
a = 0 and b = 1
x∈N
P(x) stands for x > 0
g(m,n) stands for (m x n)
h(x) stands for (x – 1)
 Above interpretation defines Factorial
Examples (contd.)

 Interpretation:2
D={strings)
a=b=λ
P(x) stands for “x is a non empty string”
g(m, n) stands for “append head of m
to n”
h(x) stands for tail(x)
 Above interpretation defines “reversing a string”
Search inside Chess!

Dion Reji & Soham Dahane

IIT Bombay

February 18, 2025

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 1 / 38
Games as Search Problems

Games can be formulated as search problems with:

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
Games as Search Problems

Games can be formulated as search problems with:


State Space

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
Games as Search Problems

Games can be formulated as search problems with:


State Space
Operators

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
Games as Search Problems

Games can be formulated as search problems with:


State Space
Operators
Initial State

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
Games as Search Problems

Games can be formulated as search problems with:


State Space
Operators
Initial State
Goal States

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
Games as Search Problems

Games can be formulated as search problems with:


State Space
Operators
Initial State
Goal States
We consider games with two players - Black and White

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
Games as Search Problems

Games can be formulated as search problems with:


State Space
Operators
Initial State
Goal States
We consider games with two players - Black and White
We visualise these two player games in a game graph

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 2 / 38
State Space Representation

State: Complete description of game position

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 3 / 38
State Space Representation

State: Complete description of game position


Components:

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 3 / 38
State Space Representation

State: Complete description of game position


Components:
Current configuration of the game arena

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 3 / 38
State Space Representation

State: Complete description of game position


Components:
Current configuration of the game arena
Player to move

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 3 / 38
State Space Representation

State: Complete description of game position


Components:
Current configuration of the game arena
Player to move
Additional information (e.g., castling rights)

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 3 / 38
State Space Representation

State: Complete description of game position


Components:
Current configuration of the game arena
Player to move
Additional information (e.g., castling rights)
State transitions occur through operators

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 3 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?


Two distinct sets:

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?


Two distinct sets:
White’s legal moves (Ow )

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?


Two distinct sets:
White’s legal moves (Ow )
Black’s legal moves (Ob )

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?


Two distinct sets:
White’s legal moves (Ow )
Black’s legal moves (Ob )
At each state:

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?


Two distinct sets:
White’s legal moves (Ow )
Black’s legal moves (Ob )
At each state:
Only one set is applicable

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
Operators in Games

Operators = Legal moves. What do you mean by legal?


Two distinct sets:
White’s legal moves (Ow )
Black’s legal moves (Ob )
At each state:
Only one set is applicable
Determined by whose turn it is

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 4 / 38
A Simple Game with Two Players

A B C

A1 A2 A3 C1 C2

C11 C12
C21 C22

C221 C222

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 5 / 38
Chess as a Search Problem

State space:

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess as a Search Problem

State space:
8×8 board configuration

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess as a Search Problem

State space:
8×8 board configuration
Position of all pieces

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess as a Search Problem

State space:
8×8 board configuration
Position of all pieces
Turn indicator

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess as a Search Problem

State space:
8×8 board configuration
Position of all pieces
Turn indicator
Castling rights, en passant possibilities

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess as a Search Problem

State space:
8×8 board configuration
Position of all pieces
Turn indicator
Castling rights, en passant possibilities
Initial state: Standard chess setup

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess as a Search Problem

State space:
8×8 board configuration
Position of all pieces
Turn indicator
Castling rights, en passant possibilities
Initial state: Standard chess setup
Goal states: Checkmate positions

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 6 / 38
Chess Operators

White’s operators (Ow ):

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Chess Operators

White’s operators (Ow ):


All legal moves for white pieces

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Chess Operators

White’s operators (Ow ):


All legal moves for white pieces
Example: e2-e4, Nf3, O-O

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Chess Operators

White’s operators (Ow ):


All legal moves for white pieces
Example: e2-e4, Nf3, O-O
Black’s operators (Ob ):

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Chess Operators

White’s operators (Ow ):


All legal moves for white pieces
Example: e2-e4, Nf3, O-O
Black’s operators (Ob ):
All legal moves for black pieces

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Chess Operators

White’s operators (Ow ):


All legal moves for white pieces
Example: e2-e4, Nf3, O-O
Black’s operators (Ob ):
All legal moves for black pieces
Same move types as white

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Chess Operators

White’s operators (Ow ):


All legal moves for white pieces
Example: e2-e4, Nf3, O-O
Black’s operators (Ob ):
All legal moves for black pieces
Same move types as white
Each operator transforms current state to new state

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 7 / 38
Example

Consider the game of chess with the following configuration of the board.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 8 / 38
Example

Consider the game of chess with the following configuration of the board.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 8 / 38
Example

Consider the game of chess with the following configuration of the board.
Now Black player makes a move (Bc8 → Bg4) indicating an action and
taking to a new game state.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 9 / 38
Example

Consider the game of chess with the following configuration of the board.
Now Black player makes a move (Bc8 → Bg4) indicating an action and
taking to a new game state.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 9 / 38
Example

Consider the game of chess with the following configuration of the board.
Now Black player makes a move (Bc8 → Bg4) indicating an action and
taking to a new game state.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 9 / 38
Snippet of Game Graph of chess

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 10 / 38
Question
How will we solve a game?
What do you mean by solving?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 11 / 38
Solving a Game

Given a player (say, White), we wish to find a winning strategy


Solving a Game

What move should White play at each of his turn

Given a player (say, White), we wish to find a winning strategy


Solving a Game

What move should White play at each of his turn

Given a player (say, White), we wish to find a winning strategy

such that we reach a state where White wins

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 12 / 38
Search and Games

Can we solve a game by Searching?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Search and Games

Can we solve a game by Searching?


Obtain the complete game graph - States, Operator, Initial State,
Goal States

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Search and Games

Can we solve a game by Searching?


Obtain the complete game graph - States, Operator, Initial State,
Goal States
What will be our Goal States?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Search and Games

Can we solve a game by Searching?


Obtain the complete game graph - States, Operator, Initial State,
Goal States
What will be our Goal States? All states where White wins.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Search and Games

Can we solve a game by Searching?


Obtain the complete game graph - States, Operator, Initial State,
Goal States
What will be our Goal States? All states where White wins.
We start searching the Goal States from Initial State

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Search and Games

Can we solve a game by Searching?


Obtain the complete game graph - States, Operator, Initial State,
Goal States
What will be our Goal States? All states where White wins.
We start searching the Goal States from Initial State
What will our search algorithm return?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Search and Games

Can we solve a game by Searching?


Obtain the complete game graph - States, Operator, Initial State,
Goal States
What will be our Goal States? All states where White wins.
We start searching the Goal States from Initial State
What will our search algorithm return? Path from start state to Goal
states.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 13 / 38
Can we getting a winning strategy from
the path found by our search algorithm?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 14 / 38
Limitations of Search

For most games the state space is enoromously large. For chess
∼ 1040 nodes - practically impossible to search.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 15 / 38
Limitations of Search

For most games the state space is enoromously large. For chess
∼ 1040 nodes - practically impossible to search.
Search might not give us a strategy to solve a game. We can rather
focus on simpler problems!

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 15 / 38
Limitations of Search

For most games the state space is enoromously large. For chess
∼ 1040 nodes - practically impossible to search.
Search might not give us a strategy to solve a game. We can rather
focus on simpler problems!
A* excels on simplified subproblems or variants:
1 Knight’s Shortest Path Problem
2 Endgame Tablebase Approximation

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 15 / 38
Knight’s Shortest Path Problem
Objective: Find the minimum number of moves for a knight to travel
from a start square to a target square on an 8 × 8 chessboard.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 16 / 38
Knight’s Shortest Path Problem
Objective: Find the minimum number of moves for a knight to travel
from a start square to a target square on an 8 × 8 chessboard.
State Space:
S = {(i, j) | 1 ≤ i, j ≤ 8}

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 16 / 38
Knight’s Shortest Path Problem
Objective: Find the minimum number of moves for a knight to travel
from a start square to a target square on an 8 × 8 chessboard.
State Space:
S = {(i, j) | 1 ≤ i, j ≤ 8}

Actions: Legal knight moves:

(x + 2, y + 1), (x + 2, y − 1), (x − 2, y + 1), (x − 2, y − 1),


(x + 1, y + 2), (x + 1, y − 2), (x − 1, y + 2), (x − 1, y − 2)

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 16 / 38
Knight’s Shortest Path Problem
Objective: Find the minimum number of moves for a knight to travel
from a start square to a target square on an 8 × 8 chessboard.
State Space:
S = {(i, j) | 1 ≤ i, j ≤ 8}

Actions: Legal knight moves:

(x + 2, y + 1), (x + 2, y − 1), (x − 2, y + 1), (x − 2, y − 1),


(x + 1, y + 2), (x + 1, y − 2), (x − 1, y + 2), (x − 1, y − 2)

Cost Function: g (n) = number of moves taken so far.


Heuristic: A simple estimate:
|x − xt | + |y − yt |
h(n) ≈
3
Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 16 / 38
Knight’s Shortest Path - Start and Target

Target

Start

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 17 / 38
Knight’s Shortest Path - Possible Moves
Knight’s Shortest Path - Possible Moves

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 18 / 38
Knight’s Shortest Path - Shortest Path
Knight’s Shortest Path - Shortest Path
Knight’s Shortest Path - Shortest Path
Knight’s Shortest Path - Shortest Path

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 19 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.
Actions: Legal moves available in the given endgame.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.
Actions: Legal moves available in the given endgame.
Cost Function: g (n) = number of moves made.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.
Actions: Legal moves available in the given endgame.
Cost Function: g (n) = number of moves made.
Heuristic: Estimate based on:
Material advantage.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.
Actions: Legal moves available in the given endgame.
Cost Function: g (n) = number of moves made.
Heuristic: Estimate based on:
Material advantage.
Piece mobility.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.
Actions: Legal moves available in the given endgame.
Cost Function: g (n) = number of moves made.
Heuristic: Estimate based on:
Material advantage.
Piece mobility.
Proximity to key squares.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

Objective: Determine the sequence of moves to checkmate in a


simplified endgame (e.g., King & Queen vs. King).
State Space: Reduced set of positions with only a few pieces.
Actions: Legal moves available in the given endgame.
Cost Function: g (n) = number of moves made.
Heuristic: Estimate based on:
Material advantage.
Piece mobility.
Proximity to key squares.
Think: Where is it be incorporated to avoid stalemate in the game?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 20 / 38
Endgame Tablebase Approximation

In any game the heuristic incorporates multiple strategic factors to


guide A* search.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 21 / 38
Endgame Tablebase Approximation

In any game the heuristic incorporates multiple strategic factors to


guide A* search.
Example Heuristic Function:

h(n) = d(n, edge) + Mobility(Bk ) + M

where:
d(n, edge) is the distance of the Black king from the nearest edge.
Mobility(Bk ) is the number of legal moves available to the Black king.
M is a bonus term if the White king is supporting the queen effectively
which can be the manhattan distance between them for example.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 21 / 38
Endgame Tablebase Approximation

In any game the heuristic incorporates multiple strategic factors to


guide A* search.
Example Heuristic Function:

h(n) = d(n, edge) + Mobility(Bk ) + M

where:
d(n, edge) is the distance of the Black king from the nearest edge.
Mobility(Bk ) is the number of legal moves available to the Black king.
M is a bonus term if the White king is supporting the queen effectively
which can be the manhattan distance between them for example.
Heuristic Rationale:
Encourages restricting the Black king’s movement.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 21 / 38
Endgame Tablebase Approximation

In any game the heuristic incorporates multiple strategic factors to


guide A* search.
Example Heuristic Function:

h(n) = d(n, edge) + Mobility(Bk ) + M

where:
d(n, edge) is the distance of the Black king from the nearest edge.
Mobility(Bk ) is the number of legal moves available to the Black king.
M is a bonus term if the White king is supporting the queen effectively
which can be the manhattan distance between them for example.
Heuristic Rationale:
Encourages restricting the Black king’s movement.
Drives the Black king toward a checkmate-friendly position.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 21 / 38
Endgame Tablebase Approximation

In any game the heuristic incorporates multiple strategic factors to


guide A* search.
Example Heuristic Function:

h(n) = d(n, edge) + Mobility(Bk ) + M

where:
d(n, edge) is the distance of the Black king from the nearest edge.
Mobility(Bk ) is the number of legal moves available to the Black king.
M is a bonus term if the White king is supporting the queen effectively
which can be the manhattan distance between them for example.
Heuristic Rationale:
Encourages restricting the Black king’s movement.
Drives the Black king toward a checkmate-friendly position.
Optimizes coordination between White’s king and queen.

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 21 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 22 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 23 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 24 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 25 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 26 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 27 / 38
Endgame Tablebase Approximation

Black King

Queen

White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 28 / 38
Endgame Tablebase Approximation

Black King

Queen

White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 29 / 38
Endgame Tablebase Approximation

Black King

Queen

White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 30 / 38
Endgame Tablebase Approximation

Black King

Queen

White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 31 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 32 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 33 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 34 / 38
Endgame Tablebase Approximation

Black King

Queen
White King

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 35 / 38
Endgame Tablebase Approximation

Black King

Queen

White King
Checkmate!

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 36 / 38
How else will solve a game?

Minimax Algorithm

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 37 / 38
How else will solve a game?

Minimax Algorithm
Alpha-Beta Pruning

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 37 / 38
How else will solve a game?

Minimax Algorithm
Alpha-Beta Pruning
Can we change the structure of graph?

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 37 / 38
How else will solve a game?

Minimax Algorithm
Alpha-Beta Pruning
Can we change the structure of graph?
Neural Networks

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 37 / 38
Thank You...

Dion Reji & Soham Dahane (IIT Bombay) Search inside Chess! February 18, 2025 38 / 38

You might also like