mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 16:47:37 +00:00
Move public search/qsearch interface from namespace Learner to namespace Search
This commit is contained in:
@@ -673,7 +673,7 @@ namespace Learner
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Learner::search(pos, random_multi_pv_depth, random_multi_pv);
|
Search::search(pos, random_multi_pv_depth, random_multi_pv);
|
||||||
|
|
||||||
// Select one from the top N hands of root Moves
|
// Select one from the top N hands of root Moves
|
||||||
auto& rm = pos.this_thread()->rootMoves;
|
auto& rm = pos.this_thread()->rootMoves;
|
||||||
@@ -790,7 +790,7 @@ namespace Learner
|
|||||||
const int depth = search_depth_min + (int)prng.rand(search_depth_max - search_depth_min + 1);
|
const int depth = search_depth_min + (int)prng.rand(search_depth_max - search_depth_min + 1);
|
||||||
|
|
||||||
// Starting search calls init_for_search
|
// Starting search calls init_for_search
|
||||||
auto [search_value, search_pv] = search(pos, depth, 1, nodes);
|
auto [search_value, search_pv] = Search::search(pos, depth, 1, nodes);
|
||||||
|
|
||||||
// This has to be performed after search because it needs to know
|
// This has to be performed after search because it needs to know
|
||||||
// rootMoves which are filled in init_for_search.
|
// rootMoves which are filled in init_for_search.
|
||||||
|
|||||||
+3
-3
@@ -824,7 +824,7 @@ namespace Learner
|
|||||||
// The value of evaluate() may be used, but when calculating loss, learn_cross_entropy and
|
// The value of evaluate() may be used, but when calculating loss, learn_cross_entropy and
|
||||||
// Use qsearch() because it is difficult to compare the values.
|
// Use qsearch() because it is difficult to compare the values.
|
||||||
// EvalHash has been disabled in advance. (If not, the same value will be returned every time)
|
// EvalHash has been disabled in advance. (If not, the same value will be returned every time)
|
||||||
const auto [_, pv] = qsearch(task_pos);
|
const auto [_, pv] = Search::qsearch(task_pos);
|
||||||
|
|
||||||
const auto rootColor = task_pos.side_to_move();
|
const auto rootColor = task_pos.side_to_move();
|
||||||
|
|
||||||
@@ -962,7 +962,7 @@ namespace Learner
|
|||||||
|
|
||||||
// Determine if the teacher's move and the score of the shallow search match
|
// Determine if the teacher's move and the score of the shallow search match
|
||||||
{
|
{
|
||||||
const auto [value, pv] = search(task_pos, 1);
|
const auto [value, pv] = Search::search(task_pos, 1);
|
||||||
if ((uint16_t)pv[0] == ps.move)
|
if ((uint16_t)pv[0] == ps.move)
|
||||||
move_accord_count.fetch_add(1, std::memory_order_relaxed);
|
move_accord_count.fetch_add(1, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
@@ -1186,7 +1186,7 @@ namespace Learner
|
|||||||
goto RETRY_READ;
|
goto RETRY_READ;
|
||||||
|
|
||||||
// Evaluation value of shallow search (qsearch)
|
// Evaluation value of shallow search (qsearch)
|
||||||
const auto [_, pv] = qsearch(pos);
|
const auto [_, pv] = Search::qsearch(pos);
|
||||||
|
|
||||||
// Evaluation value of deep search
|
// Evaluation value of deep search
|
||||||
const auto deep_value = (Value)ps.score;
|
const auto deep_value = (Value)ps.score;
|
||||||
|
|||||||
+2
-7
@@ -1968,9 +1968,7 @@ void Tablebases::rank_root_moves(Position& pos, Search::RootMoves& rootMoves) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- expose the functions such as fixed depth search used for learning to the outside
|
// --- expose the functions such as fixed depth search used for learning to the outside
|
||||||
|
namespace Search
|
||||||
|
|
||||||
namespace Learner
|
|
||||||
{
|
{
|
||||||
// For learning, prepare a stub that can call search,qsearch() from one thread.
|
// For learning, prepare a stub that can call search,qsearch() from one thread.
|
||||||
// From now on, it is better to have a Searcher and prepare a substitution table for each thread like Apery.
|
// From now on, it is better to have a Searcher and prepare a substitution table for each thread like Apery.
|
||||||
@@ -1978,7 +1976,7 @@ namespace Learner
|
|||||||
|
|
||||||
// Initialization for learning.
|
// Initialization for learning.
|
||||||
// Called from Learner::search(),Learner::qsearch().
|
// Called from Learner::search(),Learner::qsearch().
|
||||||
void init_for_search(Position& pos, Stack* ss)
|
static void init_for_search(Position& pos, Stack* ss)
|
||||||
{
|
{
|
||||||
|
|
||||||
// RootNode requires ss->ply == 0.
|
// RootNode requires ss->ply == 0.
|
||||||
@@ -2046,9 +2044,6 @@ namespace Learner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A pair of reader and evaluation value. Returned by Learner::search(),Learner::qsearch().
|
|
||||||
typedef std::pair<Value, std::vector<Move> > ValueAndPV;
|
|
||||||
|
|
||||||
// Stationary search.
|
// Stationary search.
|
||||||
//
|
//
|
||||||
// Precondition) Search thread is set by pos.set_this_thread(Threads[thread_id]).
|
// Precondition) Search thread is set by pos.set_this_thread(Threads[thread_id]).
|
||||||
|
|||||||
+4
-7
@@ -110,15 +110,12 @@ extern LimitsType Limits;
|
|||||||
void init();
|
void init();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
} // namespace Search
|
// A pair of reader and evaluation value. Returned by Learner::search(),Learner::qsearch().
|
||||||
|
using ValueAndPV = std::pair<Value, std::vector<Move>>;
|
||||||
|
|
||||||
namespace Learner {
|
ValueAndPV qsearch(Position& pos);
|
||||||
|
ValueAndPV search(Position& pos, int depth_, size_t multiPV = 1, uint64_t nodesLimit = 0);
|
||||||
|
|
||||||
// A pair of reader and evaluation value. Returned by Learner::search(),Learner::qsearch().
|
|
||||||
using ValueAndPV = std::pair<Value, std::vector<Move>>;
|
|
||||||
|
|
||||||
ValueAndPV qsearch(Position& pos);
|
|
||||||
ValueAndPV search(Position& pos, int depth_, size_t multiPV = 1, uint64_t nodesLimit = 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifndef SEARCH_H_INCLUDED
|
#endif // #ifndef SEARCH_H_INCLUDED
|
||||||
|
|||||||
+2
-2
@@ -254,7 +254,7 @@ double UCI::win_rate_model_double(double v, int ply) {
|
|||||||
void qsearch_cmd(Position& pos)
|
void qsearch_cmd(Position& pos)
|
||||||
{
|
{
|
||||||
cout << "qsearch : ";
|
cout << "qsearch : ";
|
||||||
auto pv = Learner::qsearch(pos);
|
auto pv = Search::qsearch(pos);
|
||||||
cout << "Value = " << pv.first << " , " << UCI::value(pv.first) << " , PV = ";
|
cout << "Value = " << pv.first << " , " << UCI::value(pv.first) << " , PV = ";
|
||||||
for (auto m : pv.second)
|
for (auto m : pv.second)
|
||||||
cout << UCI::move(m, false) << " ";
|
cout << UCI::move(m, false) << " ";
|
||||||
@@ -275,7 +275,7 @@ void search_cmd(Position& pos, istringstream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << "search depth = " << depth << " , multi_pv = " << multi_pv << " : ";
|
cout << "search depth = " << depth << " , multi_pv = " << multi_pv << " : ";
|
||||||
auto pv = Learner::search(pos, depth, multi_pv);
|
auto pv = Search::search(pos, depth, multi_pv);
|
||||||
cout << "Value = " << pv.first << " , " << UCI::value(pv.first) << " , PV = ";
|
cout << "Value = " << pv.first << " , " << UCI::value(pv.first) << " , PV = ";
|
||||||
for (auto m : pv.second)
|
for (auto m : pv.second)
|
||||||
cout << UCI::move(m, false) << " ";
|
cout << UCI::move(m, false) << " ";
|
||||||
|
|||||||
Reference in New Issue
Block a user