Hi,
I found 2 ways to calculate this : one in https://www.chessprogramming.org/PeSTO% ... n_Function
one in https://www.chessprogramming.org/Tapered_Eval.
The first one use 24 as divider, the other one 256.
The problem is that the two methods don't give the same evaluation.
Im perplexed. Is there a "right" method ?
Thanks for input
Philippe
tapered evaluation
Moderator: Ras
-
- Posts: 162
- Joined: Thu Jan 20, 2022 9:42 am
- Location: France
- Full name: Philippe Chevalier
-
- Posts: 5694
- Joined: Tue Feb 28, 2012 11:56 pm
Re: tapered evaluation
They are the same method, just using a different granularity of "phase".Carbec wrote: ↑Fri Jul 28, 2023 2:08 pmI found 2 ways to calculate this : one in https://www.chessprogramming.org/PeSTO% ... n_Function
one in https://www.chessprogramming.org/Tapered_Eval.
The first one use 24 as divider, the other one 256.
The problem is that the two methods don't give the same evaluation.
When you implement such a method in your chess engine, you will have to make various choices. The number of phases, how to calculate the phase, etc.
-
- Posts: 162
- Joined: Thu Jan 20, 2022 9:42 am
- Location: France
- Full name: Philippe Chevalier
Re: tapered evaluation
Hi,
You are totally right, the two evaluations are identical. One less bug
Thanks for the input.
Philippe
You are totally right, the two evaluations are identical. One less bug

Thanks for the input.
Philippe
-
- Posts: 18
- Joined: Mon Apr 10, 2023 6:33 am
- Full name: Jayden Joo
Re: tapered evaluation
Depending on how fast your engine is, you may want to use a power of 2 because regular integer division is very slow on most CPUs.
-
- Posts: 2695
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: tapered evaluation
Dividing by a fixed amount isn't compiled to an integer division. I don't think that you'll see measurable impact on the engine speed. See Godbolt.org as example for GCC 13 with -O2:AngularMomentum wrote: ↑Fri Jul 28, 2023 8:51 pmDepending on how fast your engine is, you may want to use a power of 2 because regular integer division is very slow on most CPUs.
Code: Select all
int division(int num) {
return num / 24;
}
division(int):
movsx rax, edi
sar edi, 31
imul rax, rax, 715827883
sar rax, 34
sub eax, edi
ret
Code: Select all
int division(int num) {
return num / 256;
}
division(int):
test edi, edi
lea eax, [rdi+255]
cmovns eax, edi
sar eax, 8
ret
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 162
- Joined: Thu Jan 20, 2022 9:42 am
- Location: France
- Full name: Philippe Chevalier
Re: tapered evaluation
Hi,
Back for this problem. In fact the two evaluations are the same in general, but there are numerous occasions where they differ of 1.
This may be little, but in my program have a certain importance, in time, in nodes searched, in sometimes in PV.
Some examples , first KIWIPETE position :
Now, FINE 70 :
Now, a position I call SILVER2 (from the silver suite)
Is this normal ? or something caused by my program ?
As I see, the "phase 24" is better in my case.
Thanks
Philippe
Back for this problem. In fact the two evaluations are the same in general, but there are numerous occasions where they differ of 1.
This may be little, but in my program have a certain importance, in time, in nodes searched, in sometimes in PV.
Some examples , first KIWIPETE position :
Code: Select all
phase 256
info depth 15 seldepth 29 time 486 nodes 1.743.866 nps 3.588.201 score cp -118 pv d5e6 e7e6 e2a6 e6e5 a6b7 h3g2 f3g2 b4c3 d2c3 e5f4 b7a8 b6a8 h2h3 e8g8 e4e5
info depth 16 seldepth 30 time 965 nodes 3.380.015 nps 3.502.606 score cp -98 pv e2a6 b4c3 d2c3 e6d5 e5g4 h3g2 f3g2 e8g8 g4f6 g7f6 c3f6 e7f6 e1g1 d5e4 g2e4
info depth 17 seldepth 30 time 1.614 nodes 5.676.260 nps 3.516.889 score cp -136 pv e2a6 b4c3 d2c3 e6d5 e5g4 f6g4 c3g7 g4e5 g7e5 e7e5 e1g1 h3g2 f3g2 d5e4 h2h3 h8h4 a1e1
info depth 18 seldepth 31 time 2.389 nodes 8.219.554 nps 3.440.583 score cp -89 pv e2a6 b4c3 d2c3 e6d5 e5g4 f6g4 c3g7 h8h4 g2h3 g4e5 f3f6 h4e4 e1f1 b6c4 f1g2 e7f6 g7f6
info depth 19 seldepth 32 time 4.972 nodes 17.212.492 nps 3.461.884 score cp -127 pv e2a6 b4c3 d2c3 e6d5 e5g4 h3g2 h1g1 f6g4 c3g7 g4h2 f3g2 h8h4 e1c1 d5e4 g2g3 h2f3 g3c7 f3g1 d1g1
info depth 20 seldepth 34 time 7.754 nodes 25.979.618 nps 3.350.479 score cp -75 pv e2a6 b4c3 d2c3 e6d5 e5g4 h3g2 f3g2 h8h4 c3f6 g7f6 e1c1 d5e4 c1b1 e8f8 h1e1 a8e8 f2f3 d7d5
phase 24
info depth 15 seldepth 28 time 497 nodes 1.777.346 nps 3.576.148 score cp -118 pv d5e6 e7e6 e2a6 e6e5 a6b7 h3g2 f3g2 b4c3 d2c3 e5f4 b7a8 b6a8 h2h3 e8g8 e4e5
info depth 16 seldepth 30 time 1.217 nodes 4.210.493 nps 3.459.731 score cp -155 pv e2a6 b4c3 d2c3 e6d5 e5g4 f6g4 c3g7 h8h4 e1c1 d5e4 f3g3 h3g2 g3g2 b6a4
info depth 17 seldepth 31 time 1.597 nodes 5.449.742 nps 3.412.487 score cp -136 pv e2a6 b4c3 d2c3 e6d5 e5g4 f6g4 c3g7 g4e5 g7e5 e7e5 g2h3 d5e4 f3a3 e5e7 a3c3 h8h4
info depth 18 seldepth 31 time 2.190 nodes 7.332.419 nps 3.348.136 score cp -123 pv e2a6 b4c3 d2c3 e6d5 e5g4 f6g4 c3g7 g4e5 f3g3 h3g2 g3g2 e7b4 e1f1 b4b2 a1e1 b2a2 g7h8 a2a6 e1e2
info depth 19 seldepth 34 time 3.613 nodes 11.745.577 nps 3.250.920 score cp -123 pv e2a6 b4c3 d2c3 e6d5 e5g4 f6g4 c3g7 g4e5 f3g3 h3g2 g3g2 e7b4 e1f1 b4b2 a1e1 b2a2 g7h8 a2a6 e1e2
info depth 20 seldepth 34 time 6.172 nodes 20.161.033 nps 3.266.531 score cp -110 pv e2a6 e6d5 c3b5 e7e5 d2f4 e5b2 b5c7 e8f8 e1g1 d5e4 f3b3 b2b3 a2b3 h3g2 g1g2 a8d8 f4g5 f8g8 a6b5 h8h5
Code: Select all
phase 256
info depth 40 seldepth 46 time 240 nodes 1.369.620 nps 5.706.750 score cp 280 pv a1b1 a7b7 b1c1 b7c8 c1d2 c8d7 d2c3 d7c7 c3d3 c7b7 d3e3 b7c7 e3f2 c7d7 f2g3 d7e7 g3h4 e7f8
info depth 41 seldepth 49 time 330 nodes 1.903.680 nps 5.768.727 score cp 446 pv a1b1 a7b8 b1c2 b8c7 c2d3 c7b7 d3e3 b7c7 e3f2 c7d7 f2g3 d7e7 g3h4 e7f8 h4g5 f8g7 g5f5 g7f7
info depth 42 seldepth 55 time 574 nodes 3.178.934 nps 5.538.212 score cp 761 pv a1b1 a7b8 b1c2 b8c7 c2d3 c7b7 d3e3 b7c7 e3f2 c7d7 f2g3 d7e7 g3h4 e7f8 h4g5 f8g7 g5f5 g7f7
info depth 43 seldepth 58 time 12.219 nodes 53.108.569 nps 4.346.392 score cp 2.018 pv a1b1 a7b8 b1c2 b8c7 c2d3 c7b7 d3e3 b7c7 e3f2 c7d7 f2g3 d7e7 g3h4 e7f7 h4g5 f7g7 g5f5 g7f7
info depth 44 seldepth 57 time 13.198 nodes 57.298.440 nps 4.341.448 score cp 2.033 pv a1b1 a7b8 b1c2 b8c7 c2d3 c7b7 d3e2 b7c7 e2f2 c7d7 f2g3 d7e7 g3h4 e7f7 h4g5 f7g7 g5f5 g7f7
info depth 45 seldepth 59 time 14.723 nodes 63.715.516 nps 4.327.617 score cp 2.070 pv a1b1 a7b8 b1c2 b8c7 c2d3 c7b7 d3e2 b7c7 e2f2 c7d7 f2g3 d7e7 g3h4 e7f7 h4h5 f7f6 h5h6 f6f7
phase 24
info depth 40 seldepth 49 time 286 nodes 1.586.482 nps 5.547.139 score cp 350 pv a1b1 a7a8 b1b2 a8b7 b2c3 b7c7 c3d3 c7b7 d3e3 b7c8 e3f2 c8d7 f2g3 d7e8 g3h4 e8f8 h4g5 f8g7 g5f5 g7f7 f5e4 f7g6 e4d3 g6f5 d3c4 f5f4 c4b5 f4e4 b5a5 e4d5 a5b6 d5c4 d4d5 c4b4 a4a5 b4b3 a5a6 b3c4
info depth 41 seldepth 49 time 365 nodes 2.020.853 nps 5.536.583 score cp 365 pv a1b1 a7a8 b1b2 a8b7 b2c3 b7c7 c3d3 c7b7 d3e3 b7c8 e3f2 c8d7 f2g3 d7e8 g3h4 e8f8 h4g5 f8g7 g5f5 g7f7 f5e4 f7g6 e4d3 g6f5 d3c4 f5g4 c4b5 g4f4 b5a5 f4e4 a5b6 e4d5 a4a5 d5c4 d4d5 c4b4 a5a6 b4c4
info depth 42 seldepth 54 time 673 nodes 3.295.994 nps 4.897.465 score cp 446 pv a1b1 a7a8 b1b2 a8b7 b2c3 b7c7 c3d3 c7b7 d3e3 b7c8 e3f2 c8d7 f2g3 d7e8 g3h4 e8f8 h4g5 f8g7 g5f5 g7f7 f5e4 f7g6 e4d3 g6f5 d3c4 f5f4 c4b5 f4e4 b5a5 e4d5 a5b5 d5e4 a4a5 e4d3 d4d5 d3d4 b5c6 d4e4 c6d6
info depth 43 seldepth 57 time 938 nodes 4.591.603 nps 4.895.099 score cp 511 pv a1b1 a7a8 b1b2 a8b7 b2c3 b7c7 c3d3 c7b7 d3e3 b7c8 e3f2 c8d7 f2g3 d7e8 g3h4 e8f8 h4g5 f8g7 g5f5 g7f7 f5e4 f7g6 e4d3 g6f5 d3c4 f5f4 c4b5 f4e4 b5a5 e4d5 a5b6 d5e6 b6c6 e6f7 c6d6 f7g6 a4a5 g6h5 a5a6 h5g4
info depth 44 seldepth 57 time 1.309 nodes 6.388.420 nps 4.880.381 score cp 672 pv a1b1 a7a8 b1b2 a8b7 b2c3 b7c7 c3d3 c7b7 d3e3 b7c8 e3f2 c8d7 f2g3 d7e8 g3h4 e8f8 h4g5 f8g7 g5f5 g7f7 f5e4 f7g6 e4d3 g6f6 d3c4 f6f5 c4b5 f5e4 b5c6 e4d4 c6d6 d4c3 d6c6 c3c2 d5d6 c2b1 c6b5 b1c1 b5a5
info depth 45 seldepth 59 time 2.022 nodes 9.750.674 nps 4.822.291 score cp 1.092 pv a1b1 a7a8 b1b2 a8b7 b2c3 b7c7 c3d3 c7b7 d3e2 b7c8 e2f2 c8d7 f2g3 d7e8 g3h4 e8f8 h4g5 f8g7 g5f5 g7f7 f5e4 f7g6
Code: Select all
phase 256
info depth 15 seldepth 28 time 513 nodes 1.537.017 nps 2.996.134 score cp 52 pv f1c4 c6e5 c4e2 d7d5 e1g1 e8g8 b1d2 c7c6 a1c1 c5b6 f2f4 f6h6 g1h1 c6c5 d4b5
info depth 16 seldepth 29 time 825 nodes 2.487.445 nps 3.015.084 score cp 52 pv f1c4 c6e5 c4e2 d7d5 e1g1 e8g8 b1d2 c7c6 a1c1 c5b6 f2f4 f6h6 g1h1 c6c5 d4b5
info depth 17 seldepth 31 time 1.625 nodes 4.933.289 nps 3.035.870 score cp 50 pv f1c4 c6e5 c4e2 d7d5 e1g1 e8g8 b1d2 a7a6 b2b4 c5a7 f2f4 f6h6 g1h1 c8d7 a1b1 c7c6
info depth 18 seldepth 32 time 4.143 nodes 12.672.343 nps 3.058.735 score cp 25 pv f1b5 a7a6 b5c6 d7c6 d1h5 c5d4 c3d4 f6g6 h5g6 h7g6 e1g1 c8e6 b1d2 h8h5 f2f3 e8c8 b2b3 f7f6
info depth 19 seldepth 36 time 9.918 nodes 29.514.036 nps 2.975.805 score cp 39 pv b1d2 c6d4 e4e5 d4c2 d1c2 f6e5 d2c4 e5e6 e1c1 c5e3 c4e3 e6a2 f1c4 a2a1 c1d2 a1a5 b2b4 a5h5 d2c1 e8g8 c1b1
info depth 20 seldepth 33 time 11.919 nodes 35.500.467 nps 2.978.476 score cp 24 pv b1d2 c6d4 e4e5 d4c2 d1c2 f6e5 d2c4 e5e6 e1c1 d7d6 e3c5 d6c5 c4e3 e8g8 f1c4 e6g6 c2g6 e7g6 d1d5 b7b6
phase 24
info depth 15 seldepth 26 time 438 nodes 1.305.749 nps 2.981.162 score cp 53 pv f1c4 c6e5 c4e2 e8g8 b2b4 c5b6 e1g1 c7c5 d4c2 c5b4 c3b4 a7a5 b4a5 b6e3 f2e3
info depth 16 seldepth 28 time 725 nodes 2.179.723 nps 3.006.514 score cp 41 pv f1c4 c6e5 c4e2 e8g8 b2b4 c5b6 e1g1 d7d5 b1d2 c7c5 b4c5 b6c5 f2f4 f6h6 a1b1 a7a6
info depth 17 seldepth 29 time 1.168 nodes 3.541.427 nps 3.032.043 score cp 41 pv f1c4 c6e5 c4e2 e8g8 b2b4 c5b6 e1g1 d7d5 b1d2 c7c6 f2f4 f6h6 h2h3 c8h3 g2h3 h6h3 f4e5
info depth 18 seldepth 34 time 2.509 nodes 7.589.445 nps 3.024.888 score cp 31 pv f1c4 c6e5 c4e2 f6g6 e1g1 d7d6 g1h1 g6e4 b1d2 e4g6 d4b5 e8g8 b5c7 a8b8 d2c4 c5e3 f2e3
info depth 19 seldepth 33 time 4.307 nodes 12.851.959 nps 2.983.970 score cp 28 pv f1c4 c6e5 d1b3 c7c6 e1g1 e8g8 b1d2 e5c4 b3c4 c5b6 a1e1 d7d5 e4d5 e7d5 d2e4 f6g6 c4d3 c8g4 e3g5
info depth 20 seldepth 36 time 10.598 nodes 31.760.799 nps 2.996.867 score cp 29 pv f1c4 c6e5 c4e2 f6g6 e1g1 d7d6 g1h1 g6e4 b1d2 e4g6 d4b5 c5e3 b5c7 e8d8 c7a8 e3f4 g2g3 f4d2 d1d2 c8d7
As I see, the "phase 24" is better in my case.
Thanks
Philippe
-
- Posts: 162
- Joined: Thu Jan 20, 2022 9:42 am
- Location: France
- Full name: Philippe Chevalier
Re: tapered evaluation
I forgot to give the positions :
KIWIPETE = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1";
FINE_70 = "8/k7/3p4/p2P1p2/P2P1P2/8/8/K7 w - -";
SILVER2 = "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1";
KIWIPETE = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1";
FINE_70 = "8/k7/3p4/p2P1p2/P2P1P2/8/8/K7 w - -";
SILVER2 = "r1b1k2r/ppppnppp/2n2q2/2b5/3NP3/2P1B3/PP3PPP/RN1QKB1R w KQkq - 0 1";