mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Pass also opponent time to think()
This patch modifies think() signature to accept also opponent time. This is needed for future changes to time managment. Still no functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4c5eaeb363
commit
d583176baf
4 changed files with 23 additions and 18 deletions
|
@ -124,6 +124,6 @@ void benchmark(const std::string& commandLine) {
|
||||||
{
|
{
|
||||||
Move moves[1] = {MOVE_NONE};
|
Move moves[1] = {MOVE_NONE};
|
||||||
Position pos(*it);
|
Position pos(*it);
|
||||||
think(pos, true, false, 0, 0, 0, 0, 0, secsPerPos * 1000, moves);
|
think(pos, true, false, 0, 0, 0, 0, 0, 0, secsPerPos * 1000, moves);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,9 +300,9 @@ History H; // Should be made local?
|
||||||
/// the program receives the UCI 'go' command. It initializes various
|
/// the program receives the UCI 'go' command. It initializes various
|
||||||
/// search-related global variables, and calls root_search()
|
/// search-related global variables, and calls root_search()
|
||||||
|
|
||||||
void think(const Position &pos, bool infinite, bool ponder, int time,
|
void think(const Position &pos, bool infinite, bool ponder, int side_to_move,
|
||||||
int increment, int movesToGo, int maxDepth, int maxNodes,
|
int time[], int increment[], int movesToGo, int maxDepth,
|
||||||
int maxTime, Move searchMoves[]) {
|
int maxNodes, int maxTime, Move searchMoves[]) {
|
||||||
|
|
||||||
// Look for a book move:
|
// Look for a book move:
|
||||||
if(!infinite && !ponder && get_option_value_bool("OwnBook")) {
|
if(!infinite && !ponder && get_option_value_bool("OwnBook")) {
|
||||||
|
@ -422,24 +422,29 @@ void think(const Position &pos, bool infinite, bool ponder, int time,
|
||||||
assert(thread_is_available(i, 0));
|
assert(thread_is_available(i, 0));
|
||||||
|
|
||||||
// Set thinking time:
|
// Set thinking time:
|
||||||
|
int myTime = time[side_to_move];
|
||||||
|
int myIncrement = increment[side_to_move];
|
||||||
|
int oppTime = time[1 - side_to_move];
|
||||||
|
int oppIncrement = increment[1 - side_to_move];
|
||||||
|
|
||||||
if(!movesToGo) { // Sudden death time control
|
if(!movesToGo) { // Sudden death time control
|
||||||
if(increment) {
|
if(increment) {
|
||||||
MaxSearchTime = time / 30 + increment;
|
MaxSearchTime = myTime / 30 + myIncrement;
|
||||||
AbsoluteMaxSearchTime = Max(time / 4, increment - 100);
|
AbsoluteMaxSearchTime = Max(myTime / 4, myIncrement - 100);
|
||||||
}
|
}
|
||||||
else { // Blitz game without increment
|
else { // Blitz game without increment
|
||||||
MaxSearchTime = time / 40;
|
MaxSearchTime = myTime / 40;
|
||||||
AbsoluteMaxSearchTime = time / 8;
|
AbsoluteMaxSearchTime = myTime / 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // (x moves) / (y minutes)
|
else { // (x moves) / (y minutes)
|
||||||
if(movesToGo == 1) {
|
if(movesToGo == 1) {
|
||||||
MaxSearchTime = time / 2;
|
MaxSearchTime = myTime / 2;
|
||||||
AbsoluteMaxSearchTime = Min(time / 2, time - 500);
|
AbsoluteMaxSearchTime = Min(myTime / 2, myTime - 500);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MaxSearchTime = time / Min(movesToGo, 20);
|
MaxSearchTime = myTime / Min(movesToGo, 20);
|
||||||
AbsoluteMaxSearchTime = Min((4 * time) / movesToGo, time / 3);
|
AbsoluteMaxSearchTime = Min((4 * myTime) / movesToGo, myTime / 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(PonderingEnabled) {
|
if(PonderingEnabled) {
|
||||||
|
|
|
@ -81,9 +81,9 @@ extern History H;
|
||||||
|
|
||||||
extern void init_threads();
|
extern void init_threads();
|
||||||
extern void stop_threads();
|
extern void stop_threads();
|
||||||
extern void think(const Position &pos, bool infinite, bool ponder, int time,
|
extern void think(const Position &pos, bool infinite, bool ponder, int side_to_move,
|
||||||
int increment, int movesToGo, int maxDepth, int maxNodes,
|
int time[], int increment[], int movesToGo, int maxDepth,
|
||||||
int maxTime, Move searchMoves[]);
|
int maxNodes, int maxTime, Move searchMoves[]);
|
||||||
extern int64_t nodes_searched();
|
extern int64_t nodes_searched();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ namespace {
|
||||||
TT.clear();
|
TT.clear();
|
||||||
Position::init_piece_square_tables();
|
Position::init_piece_square_tables();
|
||||||
RootPosition.from_fen(StartPosition);
|
RootPosition.from_fen(StartPosition);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (token == "isready")
|
else if (token == "isready")
|
||||||
std::cout << "readyok" << std::endl;
|
std::cout << "readyok" << std::endl;
|
||||||
|
@ -319,8 +320,7 @@ namespace {
|
||||||
if (moveTime)
|
if (moveTime)
|
||||||
infinite = true; // HACK
|
infinite = true; // HACK
|
||||||
|
|
||||||
think(RootPosition, infinite, ponder, time[RootPosition.side_to_move()],
|
think(RootPosition, infinite, ponder, RootPosition.side_to_move(), time,
|
||||||
inc[RootPosition.side_to_move()], movesToGo, depth, nodes, moveTime,
|
inc, movesToGo, depth, nodes, moveTime, searchMoves);
|
||||||
searchMoves);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue