JVMerlino wrote:If you allow the King to capture a piece in SEE, then isn't a very high King value necessary?
SEE usually has its own piece values, not necessarily equivalent to those in search. But also there you have to add special code for detecting King capture, to avoid King trading. At least, if you also do X-rays. e.g.
[d]8/8/8/8/R2Kpk2/7r/8/8 w
would have SEE = +1 for Kxe4 irrespective of the King value. It must be taught explicitly that after KxP, KxK it cannot continue with RxK to get ahead again.
Value value_to_tt(Value v, int ply) {
assert(v != VALUE_NONE);
return v >= VALUE_MATE_IN_MAX_PLY ? v + ply
: v <= VALUE_MATED_IN_MAX_PLY ? v - ply : v;
}
Value value_from_tt(Value v, int ply) {
return v == VALUE_NONE ? VALUE_NONE
: v >= VALUE_MATE_IN_MAX_PLY ? v - ply
: v <= VALUE_MATED_IN_MAX_PLY ? v + ply : v;
}
If MAX_PLY is the maximum search depth, and could be realistically reached, it is still wrong. If in practice search depth will always stay very much below MAX_PLY, you will probably get away with it.
The system of encoding mate scores and evaluations on the same scale of 16-bit numbers will always limit the maximum mate distance that can be indicated. It seems unlikely, however, that the engine will ever be able to find a mate deeper than mate in 8000. So why not use codes -24,000 to 24,000 to indicate evaluation scores, and 24,000 to 32,000 for mate scores?
Of course it is a bit questionable whether you really want the engine to prefer, say, a mate-in-1000 over a (heuristic evaluation) score of 20,000 milli-Pawns. Even though you have no mathematical prove of the mate, would it really be conceivable that with such a lead it would take more than 1000 ply to force checkmate?
If MAX_PLY is the maximum search depth, and could be realistically reached, it is still wrong. If in practice search depth will always stay very much below MAX_PLY, you will probably get away with it.
Sorry, that's missed:
I have in "AlphaBeta" and in Qsearch this code:
Sure. But if maxDepth is one million, it is not likely this line will ever be triggered. And it is also quite unlikely you will ever to be able to find a mate-in-8000, no matter how large maxDepth is.