Implemented the code to detect draw by insufficient mating material.

This commit is contained in:
nodchip
2020-08-10 15:47:11 +09:00
parent 4a87d7b787
commit 3bd3ef0aea

View File

@@ -579,6 +579,48 @@ void MultiThinkGenSfen::thread_worker(size_t thread_id)
}
}
// Draw by insufficient mating material
if (pos.count<ALL_PIECES>() <= 4) {
int pcnt = pos.count<ALL_PIECES>();
// (1) KvK
if (pcnt == 2) {
if (use_draw_in_training_data_generation)
flush_psv(0);
break;
}
// (2) KvK + 1 minor piece
if (pcnt == 3) {
int minor_pc = pos.count<BISHOP>(WHITE) + pos.count<KNIGHT>(WHITE) +
pos.count<BISHOP>(BLACK) + pos.count<KNIGHT>(BLACK);
if (minor_pc == 1) {
if (use_draw_in_training_data_generation)
flush_psv(0);
break;
}
}
// (3) KBvKB, bishops of the same color
else if (pcnt == 4) {
if (pos.count<BISHOP>(WHITE) == 1 && pos.count<BISHOP>(BLACK) == 1) {
// Color of bishops is black.
if ((pos.pieces(WHITE, BISHOP) & DarkSquares)
&& (pos.pieces(BLACK, BISHOP) & DarkSquares))
{
if (use_draw_in_training_data_generation)
flush_psv(0);
break;
}
// Color of bishops is white.
if ((pos.pieces(WHITE, BISHOP) & ~DarkSquares)
&& (pos.pieces(BLACK, BISHOP) & ~DarkSquares))
{
if (use_draw_in_training_data_generation)
flush_psv(0);
break;
}
}
}
}
//// constant track
//if ((m = book.probe(pos)) != MOVE_NONE)
//{