xr_a_y wrote: ↑Sun Dec 08, 2019 7:43 pm
Hi,
I'm having a look to CMH (sorting, pruning and extenting) and I take as a basis of reading the, always very clear, Xiphos code.
Something I don't get in this heuristic is that it uses data from opponent turn (unless I missed something ...) :
In Xiphos code : MAX_CMH_PLY=2, so that when i==1 then pos = sd->pos - i; is opponent data ?
Code: Select all
static inline void set_counter_move_history_pointer
(int16_t **cmh_ptr, search_data_t *sd, int ply)
{
int i, m_to;
position_t *pos;
for (i = 0; i < MAX_CMH_PLY; i ++)
{
pos = sd->pos - i;
if (ply > i && pos->move)
{
m_to = _m_to(pos->move);
cmh_ptr[i] = sd->counter_move_history[pos->board[m_to]][m_to];
}
else
cmh_ptr[i] = NULL;
}
}
It's best to move away from code, and try to understand the idea instead. Then you can implement it your own way.
First there is history: History[move], taking a move as [color][from][to], and giving a score, used for sorting moves, based on how successful it is at raising alpha.
Then all the ways of updating such a table. You want shallow depths to update less, as they are more frequent, and you need some absolute bounds to avoid overflows. Testing is key, there is no absolute truth beyond the experimental evidence. But what seems to work best is the history gravity pionnered by Stockfish, and later copied by everyone else (including Xiphos, Ethereal, Demolito, and probably most strong engines).
Now, history still has the problem of being too global, so every node updates it, and it's hard for it to gain specific / precise knowledge. In a sense, hostory is similar to neural networks, and we need deeper networks with more inputs.
So, again invented by SF, comes CounterMoveHistory[prevMove][move]. Such a table will be too big: 2*64^4 elements. So we shrink the prevMove part into [piece][to] instead of [from][to].
Then, pushing the idea further, SF invented FollowUpHistory, which takes [2movesAgo][move], with the same encoding, ie. piece x square x color x square x square.
Then, as CMH and FMH use quasi identical code, it makes sense to factorize this code, which is what you're looking at here.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.