It seemed to be working well from some light testing, so I started some more extensive testing in self-play using a 2+0.8s time control format. However, I'm encountering a pretty odd and frustrating issue.
Basically, sometimes Blunder is taking (much) longer than the time allotted for a 1-ply search (in the time control format I'm using, usually ~50-80ms), which means it doesn't have a best move to return.
Of course, it struck me as very odd that Blunder couldn't even finish a 1-ply search in less than ~50ms, so I did some investigating, and I discovered that the culprit causing this issue was the function used to add an entry into the transposition table. What's happening is that every so often, the performance of this function will "spike" and take anywhere from ~100ms to almost a full second, massively inflating the search time.
Here is the code for the function:
Code: Select all
func (tt *TranspositionTable) AddEntry(hash uint64, depth, ply, score int, flag uint8, best engine.Move) {
entry := &tt.table[hash%tt.size]
if entry.Hash == hash && entry.Depth > uint8(depth) {
return
}
if score >= CheckmateThreshold {
score += ply
} else if score <= -CheckmateThreshold {
score -= ply
}
entry.Hash = hash
entry.Depth = uint8(depth)
entry.Score = int16(score)
entry.Flag = flag
entry.Best = best
}But just in case I've missed something important, I've decided to get a second pair of eyes and a second opinion.
My current idea to fix this issue is to simply force Blunder to take as much time as needed to at least finish a 1-ply search, and then work around that. But I'd really rather not have to do this, as this seems hacky and something I really shouldn't have to do. So for now I'll be working on some other features until I can figure this problem out.
