diff --git a/Rapfi/search/ab/search.cpp b/Rapfi/search/ab/search.cpp index fd12c08..4a5006c 100644 --- a/Rapfi/search/ab/search.cpp +++ b/Rapfi/search/ab/search.cpp @@ -1483,7 +1483,6 @@ Value vcfsearch(Board &board, SearchStack *ss, Value alpha, Value beta, Depth de // Step 1. Initialize node SearchThread *thisThread = board.thisThread(); - ABSearchData *searchData = thisThread->searchDataAs(); thisThread->numNodes.fetch_add(1, std::memory_order_relaxed); Color self = board.sideToMove(), oppo = ~self; @@ -1505,10 +1504,6 @@ Value vcfsearch(Board &board, SearchStack *ss, Value alpha, Value beta, Depth de if (board.movesLeft() == 0 || board.nonPassMoveCount() >= thisThread->options().maxMoves) return getDrawValue(board, thisThread->options(), ss->ply); - // Check if we reached the max ply - if (ss->ply >= MAX_PLY) - return Evaluation::evaluate(board, alpha, beta); - // Check for immediate winning if ((value = quickWinCheck(board, ss->ply, beta)) != VALUE_ZERO) { // Do not return mate that longer than maxMoves option @@ -1518,6 +1513,10 @@ Value vcfsearch(Board &board, SearchStack *ss, Value alpha, Value beta, Depth de return value; } + // Check if we reached the max ply + if (ss->ply >= MAX_PLY) + return Evaluation::evaluate(board, alpha, beta); + // Step 3. Mate distance pruning alpha = std::max(mated_in(ss->ply), alpha); beta = std::min(mate_in(ss->ply + 1), beta); @@ -1681,31 +1680,27 @@ Value vcfdefend(Board &board, SearchStack *ss, Value alpha, Value beta, Depth de Color self = board.sideToMove(), oppo = ~self; uint16_t oppo5 = board.p4Count(oppo, A_FIVE); // opponent five - Value value; // Update selDepth (selDepth counts from 1, ply from 0) if (PvNode && thisThread->selDepth <= ss->ply) thisThread->selDepth = ss->ply + 1; // Step 2. Check for immediate evaluation, draw and winning - // Return evaluation immediately if there is no vcf threat - if (!oppo5) - return Evaluation::evaluate(board, alpha, beta); - // Check if the board has been filled or we have reached the max game ply. if (board.movesLeft() == 0 || board.nonPassMoveCount() >= thisThread->options().maxMoves) return getDrawValue(board, thisThread->options(), ss->ply); - // Check if we reached the max ply - if (ss->ply >= MAX_PLY) + // Check if we reached the max ply or if there is no vcf threat + if (ss->ply >= MAX_PLY || !oppo5) return Evaluation::evaluate(board, alpha, beta); // Step 3. Search the only defence move Pos move = board.stateInfo().lastPattern4(oppo, A_FIVE); assert(board.cell(move).pattern4[oppo] == A_FIVE); - // For renju, if black's defence move is a forbidden point, black loses in two steps. + Value value; if (Rule == Rule::RENJU && self == BLACK && board.checkForbiddenPoint(move)) { + // For renju, if black's defence move is a forbidden point, black loses in two steps. value = mated_in(ss->ply + 2); } else {