Thoughts : Defeating Stockfish-01 !! (Chess Evaluation)

Date :- 12-29-2023 .....

So, I started a .. new folder , git init completed .....

But no idea where to start ...............

So , icoded a basic chess board in c++ (purely)

And .... with no graphics it was only in terminal.. like

float board = {
    {-4,-2,-3,-5,-6,-3,-2,-4},
    {-1,-1,-1,-1,-1,-1,-1,-1},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0},
    {1,1,1,1,1,1,1,1},
    {4,2,3,5,6,3,2,4}
}

And some functions for printing board on terminal ... thats it ...

Date :- 12-20-2023 .....

So , after this , i searched about chess engine and chess programming alottttttttt.....

And now i understand how computers like stockfish , komodo works under the hood...

So , after watching so many tutorials ... i decided to code to find the evaluation of the chess position ..

As i am very good (at least better than my friends) at chess (iplaybullet*)

I know some basics of evaluation , BUT the computers are not human (or they are๐Ÿคจ)

And i learned about piece squares and some scores ..... and a lot

So , should code it right ?

But before coding this i wanted to code to find allll possible positions of a chess position for white and black, But after struggling through hundreds of bugs i finally .. able to get all possible position covered by pawns for white only.

Date :- 12-21-2023

So , to make a ... evaluation function i first need to check whether there is any checkmate or not . (iwilldoitlater)

I know that pieces are stronger in center but weaker at corners (except king in middle games*)

So , i found out that there is something called piece square table

which is the score of a piece at any index (x,y) on board

for example :

// for white pawn
float pawnTable[8][8] = {
    {0, 0, 0, 0, 0, 0, 0, 0},
    {1, 1, 1, 1, 1, 1, 1, 1},
    {0.5, 0.5, 1, 2, 2, 1, 0.5, 0.5},
    {0.2, 0.2, 0.4, 1, 1, 0.4, 0.2, 0.2},
    {0, 0, 0, 1, 1, 0, 0, 0},
    {0.2, -0.2, -0.4, 0, 0, -0.4, -0.2, 0.2},
    {0.2, 0.2, 0.4, -0.5, -0.5, 0.4, 0.2, 0.2},
    {0, 0, 0, 0, 0, 0, 0, 0}};

// for black pawn

float blackPawnTable[8][8] = {
    {0, 0, 0, 0, 0, 0, 0, 0},
    {0.2, 0.2, 0.4, -0.5, -0.5, 0.4, 0.2, 0.2},
    {0.2, -0.2, -0.4, 0, 0, -0.4, -0.2, 0.2},
    {0, 0, 0, 1, 1, 0, 0, 0},
    {0.2, 0.2, 0.4, 1, 1, 0.4, 0.2, 0.2},
    {0.5, 0.5, 1, 2, 2, 1, 0.5, 0.5},
    {1, 1, 1, 1, 1, 1, 1, 1},
    {0, 0, 0, 0, 0, 0, 0, 0}};
.......... // and so on for all pieces

... so for calculating evaluation

we define something called 'score' of a player..

$${SCORE}=\sum_{for\;all\;pieces}^{}{TABLE_{PIECE}[i][j] * POINT_{PIECE}}$$

And subtract the score of white and black

$$EVAL = SCORE_{WHITE}-SCORE_{BLACK}$$

BUT ,, there is a problem ..

In the positions like starting position , it is showing eval of 2 ,but it should be 0 .... i think there is any error .......... in PART 2

Part 2

So after copying some random piece square table from a repo called Shatranj.cs ??

I finnally made a working eval system . Yes it is not that goid for evaluating position .

I can add more things to look at while evaluating ..........

1
Subscribe to my newsletter

Read articles from Rudransh Bhardwaj directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rudransh Bhardwaj
Rudransh Bhardwaj