hash eval, hash pawn or twice ?

Discussion of chess software programming and technical issues.

Moderator: Ras

Daniel Anulliero
Posts: 772
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

hash eval, hash pawn or twice ?

Post by Daniel Anulliero »

Hi all !
I've implemented hash eval in Isa , very easy to do and seems working very well .But I wonder if it's useful to implement hash pawns too , or it's better to implement hash pawns instead of hash eval ?
I've seen CPW have twice in his eval , I don't understand why it is useful to have twice in the eval , because in hash eval we have evaluation of pawn structure , right?
All the Bests
Dany
User avatar
hgm
Posts: 28361
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: hash eval, hash pawn or twice ?

Post by hgm »

The point is that the hashed evaluation is only valid for a single position, while the hashed Pawn evaluation would be shared by millions of positions. Evaluating Pawn structure is usually pretty expensive, so being able to fetch it from a table in 99% of the cases would give a significant speedup.
User avatar
Kotlov
Posts: 269
Joined: Fri Jul 10, 2015 9:23 pm
Location: Russia

Re: hash eval, hash pawn or twice ?

Post by Kotlov »

Daniel Anulliero wrote:Hi all !
I've implemented hash eval in Isa , very easy to do and seems working very well .But I wonder if it's useful to implement hash pawns too , or it's better to implement hash pawns instead of hash eval ?
I've seen CPW have twice in his eval , I don't understand why it is useful to have twice in the eval , because in hash eval we have evaluation of pawn structure , right?
All the Bests
Dany
I think both at once
Daniel Anulliero
Posts: 772
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Re: hash eval, hash pawn or twice ?

Post by Daniel Anulliero »

hgm wrote:The point is that the hashed evaluation is only valid for a single position, while the hashed Pawn evaluation would be shared by millions of positions. Evaluating Pawn structure is usually pretty expensive, so being able to fetch it from a table in 99% of the cases would give a significant speedup.
Aah yes true never thought about that ! 😊
When the engine analyse 24 queen moves for exemple , the pawn structure never change (or just for a capture)
Ok I'll try that too
Thanks
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: hash eval, hash pawn or twice ?

Post by cdani »

Daniel Anulliero wrote:
hgm wrote:The point is that the hashed evaluation is only valid for a single position, while the hashed Pawn evaluation would be shared by millions of positions. Evaluating Pawn structure is usually pretty expensive, so being able to fetch it from a table in 99% of the cases would give a significant speedup.
Aah yes true never thought about that ! 😊
When the engine analyse 24 queen moves for exemple , the pawn structure never change (or just for a capture)
Ok I'll try that too
Thanks
Also your pawn evaluation should be at least a bit complicated for you to win something relevant; I suppose is like this.
In Andscacs the pawn hash if 2 MB. Seems enough for it.
Daniel José - :-) http://www.andscacs.com
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: hash eval, hash pawn or twice ?

Post by bob »

Daniel Anulliero wrote:Hi all !
I've implemented hash eval in Isa , very easy to do and seems working very well .But I wonder if it's useful to implement hash pawns too , or it's better to implement hash pawns instead of hash eval ?
I've seen CPW have twice in his eval , I don't understand why it is useful to have twice in the eval , because in hash eval we have evaluation of pawn structure , right?
All the Bests
Dany
Pawn hash is worth it as you will see beyond 95% hits, where eval cache won't be anywhere near that (pawn hash would normally only use pawn positions to compute the signature, eval cache would use normal hash signature). This produces a far greater number of hits for pawns than for the full eval.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: hash eval, hash pawn or twice ?

Post by Henk »

For evaluation of passers it is worthless for pawn table does not tell if passed pawn is blocked by a knight.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: hash eval, hash pawn or twice ?

Post by bob »

Henk wrote:For evaluation of passers it is worthless for pawn table does not tell if passed pawn is blocked by a knight.
However it CAN store a record of which pawns are passed, so you don't have to do THAT part of the passed pawn evaluation...
Daniel Anulliero
Posts: 772
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Re: hash eval, hash pawn or twice ?

Post by Daniel Anulliero »

Thanks to HGM, daniel josé and Bob for your answers !

Well I've implemented the pawn hash today and made some tests , the two versions , with and without pawn hash (too few tests for the moment , it take some time
:wink: )

In the first test I had 330 ms of speed gain
5 moves , one depth more
In the second only 65ms
12 moves , one depth more.

In the first test, 3 times (out of 41 moves), two diferents moves (collisions or search instability?)
In the second test , 6 times (out of 71 moves) two diférents moves (collisions or search instability?)

To be continued ...
:)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: hash eval, hash pawn or twice ?

Post by bob »

Daniel Anulliero wrote:Thanks to HGM, daniel josé and Bob for your answers !

Well I've implemented the pawn hash today and made some tests , the two versions , with and without pawn hash (too few tests for the moment , it take some time
:wink: )

In the first test I had 330 ms of speed gain
5 moves , one depth more
In the second only 65ms
12 moves , one depth more.

In the first test, 3 times (out of 41 moves), two diferents moves (collisions or search instability?)
In the second test , 6 times (out of 71 moves) two diférents moves (collisions or search instability?)

To be continued ...
:)
Pawn hash should change absolutely nothing but speed. If that's not true, you definitely have a bug. Node count should remain identical, as should the score, PV and everything else. You should see an improvement in speed proportional to the time spent in pawn evaluation. If pawn evaluation takes 10% of the execution time when you do a profile run, the pawn hash version should run 10% faster since the pawn eval will hardly ever be executed...

A simple debug test is to look up the pawn eval in hash, save it, then compute the REAL eval anyway and compare the two results. If they are not the same, fix the bug.