Please help the rookie.
I?m trying to get rid of my engine?s ridiculous behavior when giving mate. The first obvious change was to give a different mate score depending on the depth (like it?s probably implemented in all other engines), so I simply subtract ply from MATE (which is 9999).
That work wonders in the absence of transposition tables (like you all already know) or if I clean the transposition table in the beginning of every search, as if in analysis, but then I lose too much performance.
So I decided to translate mate scores from and to the ttables. Firstly I decided to do something like this, both in beta and alpha nodes:
- Code: Select all
hashScore = beta;
if (hashScore >= LIM_MATE && hashScore < INFINITO)
hashScore += ply;
if (hashScore <= -LIM_MATE && hashScore > -INFINITO)
hashScore -= ply;
UpdateTTable();
Where LIM_MATE is something to make sure this is a mate score, so it?s actually MATE ? 100 (I?m assuming my engine will never find a mate in 50). Of course this is the beta cut-off code, so I do the exact same thing in the alpha update.
This correctly stores the mate scores in the hash table for the first mate found, but during the search if I?m at ply 10, and I find it?s a mate in one (score == 9997), I?ll store 10007 in the ttable.
So I figured out I should also translate back the mate scores when I find them in the ttable, by doing the opposite operation. So, if I?m at ply 10 and searching the ttable I find out it?s a mate in one (9997), I translate it into mate in 6 (9987).
- Code: Select all
if (hashValue >= LIM_MATE && hashValue < INFINITO)
hashValue -= ply;
if (hashValue <= -LIM_MATE && hashValue > -INFINITO)
hashValue += ply;
This ALMOST works. For some reason, the engine actively search for the fastest mate, but always showing a slightly wrong score, and effectively misses the quickest mate by one or two moves.
It wouldn?t be so bad if the moves where missed while somewhere between mate in 10 and mate in 5, but for my despair and embarrassment it always misses the mate in one.
So I?m officially out of ideas. Can you please give/rent/sell me some?