X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=2b41ec448da40db166b8a107e7a529ddc0a491e1;hp=b00c270bbd94bd034dcfe96fcd2bd6d979c0ccbc;hb=962216440c186d067d8946112acab847ccb7249f;hpb=f32992f88c16c6d4c2b72164c88fc4581f8faba7 diff --git a/src/search.cpp b/src/search.cpp index b00c270b..2b41ec44 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -291,8 +291,7 @@ namespace { bool idle_thread_exists(int master); bool split(const Position &pos, SearchStack *ss, int ply, Value *alpha, Value *beta, Value *bestValue, Depth depth, - int *moves, MovePicker *mp, Bitboard dcCandidates, int master, - bool pvNode); + int *moves, MovePicker *mp, int master, bool pvNode); void wake_sleeping_threads(); #if !defined(_MSC_VER) @@ -754,12 +753,12 @@ namespace { if (dbg_show_hit_rate) dbg_print_hit_rate(LogFile); - UndoInfo u; + StateInfo st; LogFile << "Nodes: " << nodes_searched() << std::endl << "Nodes/second: " << nps() << std::endl << "Best move: " << move_to_san(p, ss[0].pv[0]) << std::endl; - p.do_move(ss[0].pv[0], u); + p.do_move(ss[0].pv[0], st); LogFile << "Ponder move: " << move_to_san(p, ss[0].pv[1]) << std::endl << std::endl; } @@ -776,14 +775,13 @@ namespace { Value alpha = -VALUE_INFINITE; Value beta = VALUE_INFINITE, value; - Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move()); // Loop through all the moves in the root move list for (int i = 0; i < rml.move_count() && !AbortSearch; i++) { int64_t nodes; Move move; - UndoInfo u; + StateInfo st; Depth ext, newDepth; RootMoveNumber = i + 1; @@ -809,7 +807,7 @@ namespace { newDepth = (Iteration - 2) * OnePly + ext + InitialDepth; // Make the move, and search it - pos.do_move(move, u, dcCandidates); + pos.do_move(move, st); if (i < MultiPV) { @@ -837,7 +835,7 @@ namespace { } } - pos.undo_move(move, u); + pos.undo_move(move); // Finished searching the move. If AbortSearch is true, the search // was aborted because the user interrupted the search or because we @@ -983,9 +981,9 @@ namespace { Move move, movesSearched[256]; int moveCount = 0; Value value, bestValue = -VALUE_INFINITE; - Bitboard dcCandidates = mp.discovered_check_candidates(); + Color us = pos.side_to_move(); bool isCheck = pos.is_check(); - bool mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move())); + bool mateThreat = pos.has_mate_threat(opposite_color(us)); // Loop through all legal moves until no moves remain or a beta cutoff // occurs. @@ -996,7 +994,7 @@ namespace { assert(move_is_ok(move)); bool singleReply = (isCheck && mp.number_of_moves() == 1); - bool moveIsCheck = pos.move_is_check(move, dcCandidates); + bool moveIsCheck = pos.move_is_check(move); bool moveIsCapture = pos.move_is_capture(move); movesSearched[moveCount++] = ss[ply].currentMove = move; @@ -1013,8 +1011,8 @@ namespace { Depth newDepth = depth - OnePly + ext; // Make and search the move - UndoInfo u; - pos.do_move(move, u, dcCandidates); + StateInfo st; + pos.do_move(move, st); if (moveCount == 1) // The first move in list is the PV value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1, threadID); @@ -1056,7 +1054,7 @@ namespace { } } } - pos.undo_move(move, u); + pos.undo_move(move); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); @@ -1089,7 +1087,7 @@ namespace { && !AbortSearch && !thread_should_stop(threadID) && split(pos, ss, ply, &alpha, &beta, &bestValue, depth, - &moveCount, &mp, dcCandidates, threadID, true)) + &moveCount, &mp, threadID, true)) break; } @@ -1184,8 +1182,8 @@ namespace { { ss[ply].currentMove = MOVE_NULL; - UndoInfo u; - pos.do_null_move(u); + StateInfo st; + pos.do_null_move(st); int R = (depth >= 4 * OnePly ? 4 : 3); // Null move dynamic reduction Value nullValue = -search(pos, ss, -(beta-1), depth-R*OnePly, ply+1, false, threadID); @@ -1203,7 +1201,7 @@ namespace { && pos.see(ss[ply + 1].currentMove) + nullValue >= beta) nullDrivenIID = true; - pos.undo_null_move(u); + pos.undo_null_move(); if (value_is_mate(nullValue)) { @@ -1283,7 +1281,6 @@ namespace { Move move, movesSearched[256]; int moveCount = 0; Value value, bestValue = -VALUE_INFINITE; - Bitboard dcCandidates = mp.discovered_check_candidates(); Value futilityValue = VALUE_NONE; bool useFutilityPruning = UseFutilityPruning && depth < SelectiveDepth @@ -1298,7 +1295,7 @@ namespace { assert(move_is_ok(move)); bool singleReply = (isCheck && mp.number_of_moves() == 1); - bool moveIsCheck = pos.move_is_check(move, dcCandidates); + bool moveIsCheck = pos.move_is_check(move); bool moveIsCapture = pos.move_is_capture(move); movesSearched[moveCount++] = ss[ply].currentMove = move; @@ -1337,8 +1334,8 @@ namespace { } // Make and search the move - UndoInfo u; - pos.do_move(move, u, dcCandidates); + StateInfo st; + pos.do_move(move, st); // Try to reduce non-pv search depth by one ply if move seems not problematic, // if the move fails high will be re-searched at full depth. @@ -1361,7 +1358,7 @@ namespace { ss[ply].reduction = Depth(0); value = -search(pos, ss, -(beta-1), newDepth, ply+1, true, threadID); } - pos.undo_move(move, u); + pos.undo_move(move); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); @@ -1385,7 +1382,7 @@ namespace { && !AbortSearch && !thread_should_stop(threadID) && split(pos, ss, ply, &beta, &beta, &bestValue, depth, &moveCount, - &mp, dcCandidates, threadID, false)) + &mp, threadID, false)) break; } @@ -1470,8 +1467,8 @@ namespace { MovePicker mp = MovePicker(pos, pvNode, MOVE_NONE, EmptySearchStack, depth, isCheck ? NULL : &ei); Move move; int moveCount = 0; - Bitboard dcCandidates = mp.discovered_check_candidates(); - bool enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame; + Color us = pos.side_to_move(); + bool enoughMaterial = pos.non_pawn_material(us) > RookValueMidgame; // Loop through the moves until no moves remain or a beta cutoff // occurs. @@ -1489,7 +1486,7 @@ namespace { && !isCheck && !pvNode && !move_promotion(move) - && !pos.move_is_check(move, dcCandidates) + && !pos.move_is_check(move) && !pos.move_is_passed_pawn_push(move)) { Value futilityValue = staticValue @@ -1516,10 +1513,10 @@ namespace { continue; // Make and search the move. - UndoInfo u; - pos.do_move(move, u, dcCandidates); + StateInfo st; + pos.do_move(move, st); Value value = -qsearch(pos, ss, -beta, -alpha, depth-OnePly, ply+1, threadID); - pos.undo_move(move, u); + pos.undo_move(move); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); @@ -1584,7 +1581,7 @@ namespace { { assert(move_is_ok(move)); - bool moveIsCheck = pos.move_is_check(move, sp->dcCandidates); + bool moveIsCheck = pos.move_is_check(move); bool moveIsCapture = pos.move_is_capture(move); lock_grab(&(sp->lock)); @@ -1608,8 +1605,8 @@ namespace { continue; // Make and search the move. - UndoInfo u; - pos.do_move(move, u, sp->dcCandidates); + StateInfo st; + pos.do_move(move, st); // Try to reduce non-pv search depth by one ply if move seems not problematic, // if the move fails high will be re-searched at full depth. @@ -1631,7 +1628,7 @@ namespace { ss[sp->ply].reduction = Depth(0); value = -search(pos, ss, -(sp->beta - 1), newDepth, sp->ply+1, true, threadID); } - pos.undo_move(move, u); + pos.undo_move(move); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); @@ -1694,7 +1691,7 @@ namespace { && !thread_should_stop(threadID) && (move = sp->mp->get_next_move(sp->lock)) != MOVE_NONE) { - bool moveIsCheck = pos.move_is_check(move, sp->dcCandidates); + bool moveIsCheck = pos.move_is_check(move); bool moveIsCapture = pos.move_is_capture(move); assert(move_is_ok(move)); @@ -1717,8 +1714,8 @@ namespace { Depth newDepth = sp->depth - OnePly + ext; // Make and search the move. - UndoInfo u; - pos.do_move(move, u, sp->dcCandidates); + StateInfo st; + pos.do_move(move, st); // Try to reduce non-pv search depth by one ply if move seems not problematic, // if the move fails high will be re-searched at full depth. @@ -1754,7 +1751,7 @@ namespace { Threads[threadID].failHighPly1 = false; } } - pos.undo_move(move, u); + pos.undo_move(move); assert(value > -VALUE_INFINITE && value < VALUE_INFINITE); @@ -1879,15 +1876,15 @@ namespace { if (includeMove) { // Find a quick score for the move - UndoInfo u; + StateInfo st; SearchStack ss[PLY_MAX_PLUS_2]; moves[count].move = mlist[i].move; moves[count].nodes = 0ULL; - pos.do_move(moves[count].move, u); + pos.do_move(moves[count].move, st); moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1, 0); - pos.undo_move(moves[count].move, u); + pos.undo_move(moves[count].move); moves[count].pv[0] = moves[i].move; moves[count].pv[1] = MOVE_NONE; // FIXME count++; @@ -2113,7 +2110,7 @@ namespace { // Case 4: The destination square for m2 is attacked by the moving piece // in m1: - if(pos.piece_attacks_square(t1, t2)) + if(pos.piece_attacks_square(pos.piece_on(t1), t1, t2)) return true; // Case 5: Discovered check, checking piece is the piece moved in m1: @@ -2675,8 +2672,7 @@ namespace { bool split(const Position &p, SearchStack *sstck, int ply, Value *alpha, Value *beta, Value *bestValue, - Depth depth, int *moves, - MovePicker *mp, Bitboard dcCandidates, int master, bool pvNode) { + Depth depth, int *moves, MovePicker *mp, int master, bool pvNode) { assert(p.is_ok()); assert(sstck != NULL); assert(ply >= 0 && ply < PLY_MAX); @@ -2712,7 +2708,6 @@ namespace { splitPoint->alpha = pvNode? *alpha : (*beta - 1); splitPoint->beta = *beta; splitPoint->pvNode = pvNode; - splitPoint->dcCandidates = dcCandidates; splitPoint->bestValue = *bestValue; splitPoint->master = master; splitPoint->mp = mp;