From 3bd3ef0aeabb59ffa0584a95369b79fdf85822be Mon Sep 17 00:00:00 2001 From: nodchip Date: Mon, 10 Aug 2020 15:47:11 +0900 Subject: [PATCH] Implemented the code to detect draw by insufficient mating material. --- src/learn/learner.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/learn/learner.cpp b/src/learn/learner.cpp index 68bbc835..b81009c7 100644 --- a/src/learn/learner.cpp +++ b/src/learn/learner.cpp @@ -579,6 +579,48 @@ void MultiThinkGenSfen::thread_worker(size_t thread_id) } } + // Draw by insufficient mating material + if (pos.count() <= 4) { + int pcnt = pos.count(); + // (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(WHITE) + pos.count(WHITE) + + pos.count(BLACK) + pos.count(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(WHITE) == 1 && pos.count(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) //{