PeSTO's Evaluation Function, different"bestmove" for each depth

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

pedrojdm2021
Posts: 157
Joined: Fri Apr 30, 2021 7:19 am
Full name: Pedro Duran

PeSTO's Evaluation Function, different"bestmove" for each depth

Post by pedrojdm2021 »

Hello again guys, i am making good progress in my engine, but i found some moves on searh that i don't know if they are "werid"

i am going to explain myself:

as the title says, i have implemented PeSTO's evaluation function or like many calls it: Tapered evaluation

but i see some weird output at least on my point of view, or it is ok?

look:

Start position on depth 8:

Code: Select all

> go depth 8
bestmove e2e4 score 7 seached nodes 251988
search done in 382ms
Illegal nodes: 1931
Start position on depth 7:

Code: Select all

bestmove g1f3 score 33 seached nodes 55751
search done in 93ms 
Illegal nodes: 92  
start position on depth 6:

Code: Select all

> go depth 6
bestmove g1f3 score 0 seached nodes 36191
search done in 65ms 
Illegal nodes: 94   
start position on depth 4:

Code: Select all

> go depth 4
bestmove d2d4 score 0 seached nodes 2555
search done in 15ms
Illegal nodes: 0
so as you can see i am getting likely different best move on start position for each depth?? is this ok?

i see most engines on the same position does almost always a d2d4 on result for each of these depth's

i am collecting my best move in the following way:

Code: Select all

if (score > alpha)
{
    if(ply == 0) best_move = current_move;
}
this has been making me worried about that i am making mistakes or something else, but i see everything ok...

i have implemented:
- semi open file scoring
- open file scoring
- isolated pawns
- passed pawns
- king safety (very basic, basically a ( count_bits(bitboards[all_pieces][player] & king_attacks[square]) * king_shield_bonus )

no matter if i remove all these listed features from the evaluation function they still giving the same result

i am new on this but this have me thinking and debugging all day :lol:
AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by AndrewGrant »

1. Stronger engines tend to have more stability in their move selection, in my view.
2. All of the moves presented are reasonable to me. Its not clear to me what the world's best opening move is. So why should it be clear to an engine?
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
pedrojdm2021
Posts: 157
Joined: Fri Apr 30, 2021 7:19 am
Full name: Pedro Duran

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by pedrojdm2021 »

AndrewGrant wrote: Thu Jul 15, 2021 7:51 am 1. Stronger engines tend to have more stability in their move selection, in my view.
2. All of the moves presented are reasonable to me. Its not clear to me what the world's best opening move is. So why should it be clear to an engine?
It was just a doubt because i was comparing results with another engines that implements the same or similar evaluation techniques :)
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by mvanthoor »

pedrojdm2021 wrote: Thu Jul 15, 2021 8:21 am It was just a doubt because i was comparing results with another engines that implements the same or similar evaluation techniques :)

Code: Select all

info score cp 29 depth 1 seldepth 1 time 0 nodes 24 nps 0 pv d2d4
info score cp 0 depth 2 seldepth 2 time 0 nodes 90 nps 0 pv d2d4 d7d5
info score cp 27 depth 3 seldepth 5 time 0 nodes 672 nps 0 pv d2d4 d7d5 g1f3
info score cp 0 depth 4 seldepth 8 time 0 nodes 2350 nps 0 pv d2d4 d7d5 g1f3 g8f6
info score cp 27 depth 5 seldepth 9 time 1 nodes 12431 nps 12431000 pv d2d4 d7d5 g1f3 b8c6 b1c3
info score cp 0 depth 6 seldepth 18 time 12 nodes 66349 nps 5529083 pv d2d4 d7d5 g1f3 g8f6 f3e5 f6e4
info score cp 19 depth 7 seldepth 18 time 46 nodes 284799 nps 6191283 hashfull 1 pv d2d4 d7d5 g1f3 g8f6 b1c3 b8c6 f3g5
info score cp 8 depth 8 seldepth 23 time 357 nodes 1725142 nps 4832331 hashfull 4 pv e2e4 e7e5 b1c3 b8c6 g1f3 g8f6 d2d4 e5d4 f3d4 c6d4 d1d4
info score cp 28 depth 9 seldepth 23 time 1011 nodes 5190999 nps 5134519 hashfull 11 pv e2e4 b8c6 d2d4 d7d5 e4e5 g8h6 c1h6 g7h6 g1f3
info score cp 6 depth 10 seldepth 25 time 5581 nodes 23334936 nps 4181139 hashfull 64 pv e2e4 e7e5 b1c3 b8c6 g1f3 g8f6 f1c4 f8d6 e1g1 e8g8
info score cp 21 depth 11 seldepth 27 time 19792 nodes 89803784 nps 4537378 hashfull 197 pv e2e4 e7e5 g1f3 g8f6 f3e5 d7d6 e5f3 f6e4 d2d3 e4c5 b1c3
info score cp 11 depth 12 seldepth 31 time 123958 nodes 530086383 nps 4276339 hashfull 862 pv e2e4 e7e5 g1f3 g8f6 b1c3 b8c6 f1c4 f6e4 c3e4 d7d5 c4d3 d5e4 d3e4
How moch the engine switches around the PV depends on your PST's, at least in the beginning of the development. My engine switches from a "d4 d5" closed game to "e4 e5" open game, and after that, it can't really decide between the Scottisch Four Knights game, the Petrov, or a (weird) variation of the Italian Four Knights game.

In the end it doesn't matter too much, because most engines will end up playing the first 4 to 8 full moves (8-16 ply) from an opening book, either one provided by the GUI, or by implementing the OwnBook function.

PS: My engine only has a tapered evaluation at the moment. Up to and including about 2100 CCRL Elo (maybe even 2200), you don't need any other terms but a tapered evaluation. I'm now testing with that myself, and I estimate my engine somewhere around 2150 (+/- 30) with only the tapered evaluation. (And the basic features: MVV-LVA, TT, and killer moves.)
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
pedrojdm2021
Posts: 157
Joined: Fri Apr 30, 2021 7:19 am
Full name: Pedro Duran

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by pedrojdm2021 »

mvanthoor wrote: Thu Jul 15, 2021 10:33 am
pedrojdm2021 wrote: Thu Jul 15, 2021 8:21 am It was just a doubt because i was comparing results with another engines that implements the same or similar evaluation techniques :)

Code: Select all

info score cp 29 depth 1 seldepth 1 time 0 nodes 24 nps 0 pv d2d4
info score cp 0 depth 2 seldepth 2 time 0 nodes 90 nps 0 pv d2d4 d7d5
info score cp 27 depth 3 seldepth 5 time 0 nodes 672 nps 0 pv d2d4 d7d5 g1f3
info score cp 0 depth 4 seldepth 8 time 0 nodes 2350 nps 0 pv d2d4 d7d5 g1f3 g8f6
info score cp 27 depth 5 seldepth 9 time 1 nodes 12431 nps 12431000 pv d2d4 d7d5 g1f3 b8c6 b1c3
info score cp 0 depth 6 seldepth 18 time 12 nodes 66349 nps 5529083 pv d2d4 d7d5 g1f3 g8f6 f3e5 f6e4
info score cp 19 depth 7 seldepth 18 time 46 nodes 284799 nps 6191283 hashfull 1 pv d2d4 d7d5 g1f3 g8f6 b1c3 b8c6 f3g5
info score cp 8 depth 8 seldepth 23 time 357 nodes 1725142 nps 4832331 hashfull 4 pv e2e4 e7e5 b1c3 b8c6 g1f3 g8f6 d2d4 e5d4 f3d4 c6d4 d1d4
info score cp 28 depth 9 seldepth 23 time 1011 nodes 5190999 nps 5134519 hashfull 11 pv e2e4 b8c6 d2d4 d7d5 e4e5 g8h6 c1h6 g7h6 g1f3
info score cp 6 depth 10 seldepth 25 time 5581 nodes 23334936 nps 4181139 hashfull 64 pv e2e4 e7e5 b1c3 b8c6 g1f3 g8f6 f1c4 f8d6 e1g1 e8g8
info score cp 21 depth 11 seldepth 27 time 19792 nodes 89803784 nps 4537378 hashfull 197 pv e2e4 e7e5 g1f3 g8f6 f3e5 d7d6 e5f3 f6e4 d2d3 e4c5 b1c3
info score cp 11 depth 12 seldepth 31 time 123958 nodes 530086383 nps 4276339 hashfull 862 pv e2e4 e7e5 g1f3 g8f6 b1c3 b8c6 f1c4 f6e4 c3e4 d7d5 c4d3 d5e4 d3e4
How moch the engine switches around the PV depends on your PST's, at least in the beginning of the development. My engine switches from a "d4 d5" closed game to "e4 e5" open game, and after that, it can't really decide between the Scottisch Four Knights game, the Petrov, or a (weird) variation of the Italian Four Knights game.

In the end it doesn't matter too much, because most engines will end up playing the first 4 to 8 full moves (8-16 ply) from an opening book, either one provided by the GUI, or by implementing the OwnBook function.

PS: My engine only has a tapered evaluation at the moment. Up to and including about 2100 CCRL Elo (maybe even 2200), you don't need any other terms but a tapered evaluation. I'm now testing with that myself, and I estimate my engine somewhere around 2150 (+/- 30) with only the tapered evaluation. (And the basic features: MVV-LVA, TT, and killer moves.)
That's really great to know, Thanks for clearing up my doubts :D i am nearly to finish my very first engine, it feels great :mrgreen:
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by amanjpro »

A very small comment, tapered eval and PeSTO are not the same thing.

PeSTO is an instance of Tapered Eval, a set of arrays that represent the positional awards/penalties for each piece for both middle and endgame. It is tuned by Texel optimization.

Tapered Eval simply means, to have two separate evaluation terms for both middle game and endgame and transition between them smoothly. My engine for example implements tapered eval, but doesn't use PeSTO. Actually most of the engines are like that.


As for your question, if the bestmove wouldn't have changed between iterations, we would have searched much shallower. There is the reason that the deeper an engine thinks the better it is
pedrojdm2021
Posts: 157
Joined: Fri Apr 30, 2021 7:19 am
Full name: Pedro Duran

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by pedrojdm2021 »

amanjpro wrote: Fri Jul 16, 2021 10:21 pm A very small comment, tapered eval and PeSTO are not the same thing.

PeSTO is an instance of Tapered Eval, a set of arrays that represent the positional awards/penalties for each piece for both middle and endgame. It is tuned by Texel optimization.

Tapered Eval simply means, to have two separate evaluation terms for both middle game and endgame and transition between them smoothly. My engine for example implements tapered eval, but doesn't use PeSTO. Actually most of the engines are like that.


As for your question, if the bestmove wouldn't have changed between iterations, we would have searched much shallower. There is the reason that the deeper an engine thinks the better it is
Ok but i see that both has a transition of "Piece square tables" from A (middle game) to B (End game), so in my point of view i see almost no difference
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by amanjpro »

pedrojdm2021 wrote: Sat Jul 17, 2021 1:20 am
amanjpro wrote: Fri Jul 16, 2021 10:21 pm A very small comment, tapered eval and PeSTO are not the same thing.

PeSTO is an instance of Tapered Eval, a set of arrays that represent the positional awards/penalties for each piece for both middle and endgame. It is tuned by Texel optimization.

Tapered Eval simply means, to have two separate evaluation terms for both middle game and endgame and transition between them smoothly. My engine for example implements tapered eval, but doesn't use PeSTO. Actually most of the engines are like that.


As for your question, if the bestmove wouldn't have changed between iterations, we would have searched much shallower. There is the reason that the deeper an engine thinks the better it is
Ok but i see that both has a transition of "Piece square tables" from A (middle game) to B (End game), so in my point of view i see almost no difference
PeSTO has stricktly 12 arrays, and that is it, no more no less... It was introduced by RofChade (and PeSTO engine), and if you only have this, your engine might be strong, but very tasteless and play somewhat stupidly. As it won't be understanding anything.

But, tapered eval can have any thing like king safety, mobility, bishop pair, endgame evaluation and more... Usually, engines become different from others by incorporating different combinations of such evaluation terms. Zahak for example produces open games, and full of action. Probably not always ends up well for itself, but still. There are other engines that are more solid, for example Nalwald's evaluation is centered around King Safety. As a mother of fact, it has 12 arrays per each of the 64 squares that a king can be on.

So, saying PeSTO and Tapered Eval are the same, is going to hurt your understanding of chess programming, and probably will hurt your engine too
pedrojdm2021
Posts: 157
Joined: Fri Apr 30, 2021 7:19 am
Full name: Pedro Duran

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by pedrojdm2021 »

amanjpro wrote: Sat Jul 17, 2021 6:22 am
pedrojdm2021 wrote: Sat Jul 17, 2021 1:20 am
amanjpro wrote: Fri Jul 16, 2021 10:21 pm A very small comment, tapered eval and PeSTO are not the same thing.

PeSTO is an instance of Tapered Eval, a set of arrays that represent the positional awards/penalties for each piece for both middle and endgame. It is tuned by Texel optimization.

Tapered Eval simply means, to have two separate evaluation terms for both middle game and endgame and transition between them smoothly. My engine for example implements tapered eval, but doesn't use PeSTO. Actually most of the engines are like that.


As for your question, if the bestmove wouldn't have changed between iterations, we would have searched much shallower. There is the reason that the deeper an engine thinks the better it is
Ok but i see that both has a transition of "Piece square tables" from A (middle game) to B (End game), so in my point of view i see almost no difference
PeSTO has stricktly 12 arrays, and that is it, no more no less... It was introduced by RofChade (and PeSTO engine), and if you only have this, your engine might be strong, but very tasteless and play somewhat stupidly. As it won't be understanding anything.

But, tapered eval can have any thing like king safety, mobility, bishop pair, endgame evaluation and more... Usually, engines become different from others by incorporating different combinations of such evaluation terms. Zahak for example produces open games, and full of action. Probably not always ends up well for itself, but still. There are other engines that are more solid, for example Nalwald's evaluation is centered around King Safety. As a mother of fact, it has 12 arrays per each of the 64 squares that a king can be on.

So, saying PeSTO and Tapered Eval are the same, is going to hurt your understanding of chess programming, and probably will hurt your engine too

ah that was the difference lol well... i actually do have that too :lol: i have: passed pawns, isolated pawns, open file scoring, king safety included into the evaluation function, and yes mobility bonus too, but i didn't knew that adding these things could be named as a "tapered" i thought it was the same thing, just with some "extras"
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: PeSTO's Evaluation Function, different"bestmove" for each depth

Post by lithander »

PeSTO literally means "Piece Square Tables Only" but it's also the name of the strongest engine that uses such a simple evaluation and has made the approach popular. The set of values that PeSTO uses (or used at some point) have been posted on this forum by the author. So I think there are two interpretations where you could say an engine uses PeSTO:

(1) It uses tapered eval based on PSTs only and no other evaluation terms.
(2) It uses tapered eval based on PSTs only AND also uses the PST values from PeSTO which were published on this forum.

I personally first used PeSTO in the sense of (2) but never published that version.
Then I tuned my own set of PST-values which look and play distinctly different so version 0.4.1 of MinimalChess used PeSTO in the sense of (1).
Afterwards I added a 13th table for another dynamic, mobility and attacks based evaluation term so I'd say now I'm just using a simple tapered evaluation in version 0.5.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess