我刚刚实现了锥形评估,但我并不确定是否已经完成,因为它似乎破坏了移动排序。
我使用以下FEN进行测试:r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1
以下是使用锥形评估的信息:
info depth 1 score cp 18.000000 nodes 65 time 116 pv e2a6info depth 2 score cp 18.000000 nodes 165 time 402 pv e2a6 b4c3info depth 3 score cp 18.000000 nodes 457 time 568 pv e2a6 b4c3 d2c3info depth 4 score cp 18.000000 nodes 3833 time 1108 pv e2a6 b4c3 d2c3 h3g2info depth 5 score cp 17.000000 nodes 12212 time 1875 pv e2a6 e6d5 c3d5info depth 6 score cp 17.000000 nodes 77350 time 4348 pv e2a6 e6d5 c3d5bestmove e2a6 ponder e6d5
而没有使用锥形评估时:
info depth 1 score cp 19.000000 nodes 75 time 66 pv e2a6info depth 2 score cp 19.000000 nodes 175 time 182 pv e2a6 b4c3info depth 3 score cp 19.000000 nodes 398 time 371 pv e2a6 b4c3 d2c3info depth 4 score cp 19.000000 nodes 3650 time 947 pv e2a6 b4c3 d2c3 h3g2info depth 5 score cp 18.000000 nodes 10995 time 1849 pv e2a6 e6d5 c3d5info depth 6 score cp 18.000000 nodes 75881 time 4334 pv e2a6 e6d5 c3d5bestmove e2a6 ponder e6d5
你可以看到没有使用锥形评估时实际节点数更少,我只是在想这是不是必要的,或者是我实现得不对。
我的阶段函数如下:
int totalPhase = pawnPhase * 16 + knightPhase * 4 + bishopPhase * 4 + rookPhase * 4 + queenPhase * 2;int phase = totalPhase;for each piece in node { if piece is pawn, phase -= pawnPhase else if piece is knight, phase -= knightPhase ... }return (phase * 256 + (totalPhase / 2)) / totalPhase;
然后我在评估函数中添加了插值:
for (each piece in node) { ...score material weights and positional scores, etc.}evaluation = ((mgEvaluation * (256 - phase)) + (egEvaluation * phase)) / 256;
我从这个网站上得到了公式:锥形评估
如果这确实是必要的,有人能给我一些优化建议吗?
回答:
锥形评估非常有用,需要使用,因为早期/中期的战术与残局的战术大不相同。你没有提到你是如何排序移动的,但由于锥形评估在中局位置上为棋子方格表(PST)提供了不同的数值,因此移动排序自然会与之前略有不同。你得到的结果非常接近,看起来是合理的。
使用锥形评估测试初始位置,并确保它与仅使用开局的PST进行的正常评估结果相同。同样,对残局位置进行测试,仅使用残局的PST也应该得到相同的结果。