Skip to content

Commit

Permalink
Display wdl calculate with a WDL head during search (#100)
Browse files Browse the repository at this point in the history
Non regr VSTC:
Elo   | 0.50 +- 3.34 (95%)
SPRT  | 2.0+0.02s Threads=1 Hash=4MB
LLR   | 2.91 (-2.25, 2.89) [-5.00, 0.00]
Games | N: 20828 W: 5248 L: 5218 D: 10362
Penta | [262, 2315, 5261, 2283, 293]
https://aytchell.eu.pythonanywhere.com/test/713/

bench 8493466
  • Loading branch information
rn5f107s2 authored Sep 21, 2024
1 parent aebc648 commit a0cd8f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@
Tune tune;
#endif

std::string SearchState::outputWDL(Position &pos) {
for (int i = 0; i < pvLength[0]; i++)
pos.makeMove(pvMoves[0][i]);

std::tuple<float, float, float> wdl = pos.net.getWDL(pos.sideToMove);

for (int i = pvLength[0] - 1; i >= 0; i--)
pos.unmakeMove(pvMoves[0][i]);

std::string values[3] = {std::to_string(int(std::get<2>(wdl) * 1000)),
std::to_string(int(std::get<1>(wdl) * 1000)),
std::to_string(int(std::get<0>(wdl) * 1000))};

bool flip = pvLength[0] % 2 == 0;

return " wdl " + values[flip ? 0 : 2]
+ " " + values[1 ]
+ " " + values[flip ? 2 : 0];
}

int SearchState::startSearch(Position &pos, SearchTime &st, int maxDepth, Move &bestMove) {
int score = iterativeDeepening(pos, st, maxDepth, bestMove);
Expand Down Expand Up @@ -74,6 +93,8 @@ int SearchState::iterativeDeepening(Position &pos, SearchTime &st, int maxDepth
uciOutput += " nps ";
uciOutput += std::to_string((nodeCount / std::max(int(searchTime), 1)) * 1000);

uciOutput += outputWDL(pos);

uciOutput += " pv ";
for (int i = 0; i < pvLength[0]; i++)
uciOutput += moveToString(pvMoves[0][i]) + " ";
Expand Down Expand Up @@ -463,6 +484,8 @@ int SearchState::qsearch(int alpha, int beta, Position &pos, SearchInfo &si, Sea

int bestScore = staticEval = evaluate(pos);

pvLength[stack->plysInSearch] = stack->plysInSearch;

if (bestScore >= beta)
return bestScore;

Expand Down Expand Up @@ -499,6 +522,13 @@ int SearchState::qsearch(int alpha, int beta, Position &pos, SearchInfo &si, Sea

if (score >= beta)
return score;

pvMoves[stack->plysInSearch][stack->plysInSearch] = currentMove;

for (int nextPly = stack->plysInSearch + 1; nextPly < pvLength[stack->plysInSearch + 1]; nextPly++)
pvMoves[stack->plysInSearch][nextPly] = pvMoves[stack->plysInSearch + 1][nextPly];

pvLength[stack->plysInSearch] = pvLength[stack->plysInSearch + 1];
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SearchState {
public:

void clearHistory();
std::string outputWDL(Position &pos);
int startSearch(Position &pos, SearchTime &st, int maxDepth, Move &bestMove = emptyMove);
int iterativeDeepening(Position &pos, SearchTime &st, int maxDepth, [[maybe_unused]] Move &bestMove);
int aspirationWindow(int prevScore, Position &pos, SearchInfo &si, int depth);
Expand Down

0 comments on commit a0cd8f3

Please sign in to comment.