That follows from your current algorithm to calculate the hash table size in bytes from the requested hash table size in MB, it currently implies a hash table size in bytes that is a power of two since it starts with the value of 2 and continues with further multiplications by 2 or similar operations. For the masking approach (key & (ttsize-1)) to work it is only required that ttsize (which is the number of hash entries) is a power of 2, the hash entry size should not have a direct influence on ttsize. So you might consider to change your algorithm to determine the hash table size in a way that also works for an entry size of, say, 24 bytes. Of course having it fit into 16 bytes would even be better since you can store more information in the same amount of memory.tttony wrote:sizeof(hash_entry_s) must be power of two to make the hash (key & size) work, now it's 32 bytes
The simple solution would have been to move the "bestmove = pv[0]" statement into the loop above PrintUciInfo() so that you always update bestmove immediately unless you consider your pv as invalid due to timeout.tttony wrote:The other bug was that the bestmove was not in the previous pv, example:That's because in the ID I have this: (pseudo)Code: Select all
.. info depth 4 score cp 795 nodes 3935 qnodes 2637 time 0 nps 3935 hashfull 0 pv f7e5 bestmove f7h6 ..
I now just save the score in a global var only in the root (ply == 0)Code: Select all
int bestmove; int pv[64]; for (depth = 0; depth < MAX_DEPTH; depth++) { score = search(..., pv); // <--- Here change if (timeout) // it will not print that pv if timeout break; PrintUciInfo(..., pv); } bestmove = pv[0]; // here is the best move printf("bestmove %s\n", strmove(bestmove));
Here it should be noted that a timeout does not necessarily invalidate the pv. It certainly depends on how you deal with updating the pv within the search (at the root node). As long as you do not update it after searching a root move that has been interrupted by timeout and returns incomplete information, everything is fine, and pv[0] is either
- the best move from the previous iteration (if the timeout came during searching the first root move), or
- the first move from the new iteration (i.e. still the previous best move - if the timeout came after completing the first root move and before finding a different best move), or
- a new best move from the new iteration that may have been found in the meantime before getting the timeout.
Which problem is that?tttony wrote:Now I have problem with mate value, not work in all positions