mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Use a std::vector to store searchMoves
A std::set (that is a rb_tree) seems really overkill to store at most a handful of moves and nothing in the common case. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
72641dcaae
commit
7eb6a488ad
5 changed files with 10 additions and 11 deletions
|
@ -118,7 +118,7 @@ void benchmark(istringstream& is) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Threads.start_searching(pos, limits);
|
Threads.start_searching(pos, limits, vector<Move>());
|
||||||
Threads.wait_for_search_finished();
|
Threads.wait_for_search_finished();
|
||||||
nodes += Search::RootPosition.nodes_searched();
|
nodes += Search::RootPosition.nodes_searched();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char* argv[]) {
|
||||||
std::string args;
|
std::string args;
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
args += std::string(" ") + argv[i];
|
args += std::string(argv[i]) + " ";
|
||||||
|
|
||||||
uci_loop(args);
|
uci_loop(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,7 +429,7 @@ void ThreadsManager::wait_for_search_finished() {
|
||||||
// main_loop() so to start a new search, then returns immediately.
|
// main_loop() so to start a new search, then returns immediately.
|
||||||
|
|
||||||
void ThreadsManager::start_searching(const Position& pos, const LimitsType& limits,
|
void ThreadsManager::start_searching(const Position& pos, const LimitsType& limits,
|
||||||
const std::set<Move>& searchMoves) {
|
const std::vector<Move>& searchMoves) {
|
||||||
wait_for_search_finished();
|
wait_for_search_finished();
|
||||||
|
|
||||||
SearchTime.restart(); // As early as possible
|
SearchTime.restart(); // As early as possible
|
||||||
|
@ -442,7 +442,7 @@ void ThreadsManager::start_searching(const Position& pos, const LimitsType& limi
|
||||||
RootMoves.clear();
|
RootMoves.clear();
|
||||||
|
|
||||||
for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml)
|
for (MoveList<MV_LEGAL> ml(pos); !ml.end(); ++ml)
|
||||||
if (searchMoves.empty() || searchMoves.count(ml.move()))
|
if (searchMoves.empty() || count(searchMoves.begin(), searchMoves.end(), ml.move()))
|
||||||
RootMoves.push_back(RootMove(ml.move()));
|
RootMoves.push_back(RootMove(ml.move()));
|
||||||
|
|
||||||
threads[0]->do_sleep = false;
|
threads[0]->do_sleep = false;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#if !defined(THREAD_H_INCLUDED)
|
#if !defined(THREAD_H_INCLUDED)
|
||||||
#define THREAD_H_INCLUDED
|
#define THREAD_H_INCLUDED
|
||||||
|
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
|
@ -126,7 +125,7 @@ public:
|
||||||
void set_timer(int msec);
|
void set_timer(int msec);
|
||||||
void wait_for_search_finished();
|
void wait_for_search_finished();
|
||||||
void start_searching(const Position& pos, const Search::LimitsType& limits,
|
void start_searching(const Position& pos, const Search::LimitsType& limits,
|
||||||
const std::set<Move>& = std::set<Move>());
|
const std::vector<Move>& searchMoves);
|
||||||
|
|
||||||
template <bool Fake>
|
template <bool Fake>
|
||||||
Value split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value bestValue, Move* bestMove,
|
Value split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value bestValue, Move* bestMove,
|
||||||
|
|
|
@ -212,7 +212,7 @@ namespace {
|
||||||
void go(Position& pos, istringstream& is) {
|
void go(Position& pos, istringstream& is) {
|
||||||
|
|
||||||
Search::LimitsType limits;
|
Search::LimitsType limits;
|
||||||
std::set<Move> searchMoves;
|
vector<Move> searchMoves;
|
||||||
string token;
|
string token;
|
||||||
|
|
||||||
while (is >> token)
|
while (is >> token)
|
||||||
|
@ -239,7 +239,7 @@ namespace {
|
||||||
limits.ponder = true;
|
limits.ponder = true;
|
||||||
else if (token == "searchmoves")
|
else if (token == "searchmoves")
|
||||||
while (is >> token)
|
while (is >> token)
|
||||||
searchMoves.insert(move_from_uci(pos, token));
|
searchMoves.push_back(move_from_uci(pos, token));
|
||||||
}
|
}
|
||||||
|
|
||||||
Threads.start_searching(pos, limits, searchMoves);
|
Threads.start_searching(pos, limits, searchMoves);
|
||||||
|
@ -263,8 +263,8 @@ namespace {
|
||||||
|
|
||||||
int e = time.elapsed();
|
int e = time.elapsed();
|
||||||
|
|
||||||
std::cout << "\nNodes " << n
|
cout << "\nNodes " << n
|
||||||
<< "\nTime (ms) " << e
|
<< "\nTime (ms) " << e
|
||||||
<< "\nNodes/second " << int(n / (e / 1000.0)) << std::endl;
|
<< "\nNodes/second " << int(n / (e / 1000.0)) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue