Skip to content

Commit

Permalink
fix movegen and multi-threading bug
Browse files Browse the repository at this point in the history
Passed non-regressive tests:
Book: f15-500M-12k
TC: 60+0.6
Total/Win/Draw/Lose: 26146 / 4611 / 17013 / 4522
PTNML: 223 / 2205 / 8130 / 2290 / 225
WinRate: 50.17%
ELO: 0.80[-1.85, 3.37]
LOS: 72.63
LLR: 2.20[-2.20, 2.20]

Book: s15-500M-16k
TC: 60+0.6
Total/Win/Draw/Lose: 17288 / 2701 / 11935 / 2652
PTNML: 113 / 1390 / 5620 / 1377 / 144
WinRate: 50.14%
ELO: 0.31[-3.25, 3.62]
LOS: 57.12
LLR: 1.28[-1.10, 1.10]

Book: r15-500M-16k
TC: 60+0.6
Total/Win/Draw/Lose: 20572 / 5827 / 8940 / 5805
PTNML: 502 / 2068 / 5140 / 2058 / 518
WinRate: 50.05%
ELO: -0.59[-5.24, 3.62]
LOS: 39.25
LLR: 1.17[-1.10, 1.10]

bench 454a4d48
bench (msvc clang) 37ddaa3a
  • Loading branch information
dhbloo committed Oct 14, 2024
1 parent c37e166 commit 66a4008
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
12 changes: 12 additions & 0 deletions Rapfi/core/iohelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ int outputCoordYConvert(Pos pos, int boardsize)
return pos.y();
}

Pos parseCoord(std::string coordStr)
{
if (coordStr == "Pass" || coordStr == "pass")
return Pos::PASS;
if (coordStr == "None" || coordStr == "none")
return Pos::NONE;

int x = std::toupper(coordStr[0]) - 'A';
int y = std::atoi(coordStr.data() + 1) - '1';
return Pos(x, y);
}

// -------------------------------------------------

std::ostream &operator<<(std::ostream &out, Pos pos)
Expand Down
2 changes: 2 additions & 0 deletions Rapfi/core/iohelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Pos inputCoordConvert(int x, int y, int boardsize);
int outputCoordXConvert(Pos pos, int boardsize);
int outputCoordYConvert(Pos pos, int boardsize);

Pos parseCoord(std::string coordStr);

// -------------------------------------------------
// Formatters

Expand Down
6 changes: 2 additions & 4 deletions Rapfi/game/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,8 @@ ScoredMove *findB4F3Defence(const Board &board, ScoredMove *const moveList)

*last++ = b4Pos;

for (int d = 0; d < 4; d++) {
if (d != dir)
last = findAllB3CounterDefence(b4Pos, d, last);
}
for (int d = 0; d < 4; d++)
last = findAllB3CounterDefence(b4Pos, d, last);
}
}

Expand Down
18 changes: 7 additions & 11 deletions Rapfi/search/searchthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ void ThreadPool::startThinking(const Board &board, const SearchOptions &options,
assert(size() > 0);
assert(searcher());

// Clear and init all threads state
for (size_t i = 1; i < size(); i++)
(*this)[i]->runTask([this](SearchThread &th) { th.clear(); });

main()->clear();
main()->inPonder = inPonder;
main()->searchOptions = options;
Expand Down Expand Up @@ -386,14 +382,14 @@ void ThreadPool::startThinking(const Board &board, const SearchOptions &options,
}
}

// Copy board and root moves from main thread to other threads
// Clear threads state and copy board and root moves to other threads sequentially
for (size_t i = 1; i < size(); i++) {
(*this)[i]->runTask([this](SearchThread &th) {
th.setBoardAndEvaluator(*main()->board);
th.rootMoves = main()->rootMoves;
if (main()->searchOptions.balanceMode == Search::SearchOptions::BALANCE_TWO)
th.balance2Moves = main()->balance2Moves;
});
SearchThread &th = *(*this)[i];
th.clear();
th.setBoardAndEvaluator(*main()->board);
th.rootMoves = main()->rootMoves;
if (main()->searchOptions.balanceMode == Search::SearchOptions::BALANCE_TWO)
th.balance2Moves = main()->balance2Moves;
}

main()->runTask([searcher = searcher()](SearchThread &th) {
Expand Down

0 comments on commit 66a4008

Please sign in to comment.