mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 19:46:55 +08:00
Implemented the code to detect draw by insufficient mating material.
This commit is contained in:
@@ -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)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user