Skip to content

Commit 66a4008

Browse files
committed
fix movegen and multi-threading bug
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
1 parent c37e166 commit 66a4008

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

Rapfi/core/iohelper.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ int outputCoordYConvert(Pos pos, int boardsize)
8181
return pos.y();
8282
}
8383

84+
Pos parseCoord(std::string coordStr)
85+
{
86+
if (coordStr == "Pass" || coordStr == "pass")
87+
return Pos::PASS;
88+
if (coordStr == "None" || coordStr == "none")
89+
return Pos::NONE;
90+
91+
int x = std::toupper(coordStr[0]) - 'A';
92+
int y = std::atoi(coordStr.data() + 1) - '1';
93+
return Pos(x, y);
94+
}
95+
8496
// -------------------------------------------------
8597

8698
std::ostream &operator<<(std::ostream &out, Pos pos)

Rapfi/core/iohelper.h

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Pos inputCoordConvert(int x, int y, int boardsize);
4747
int outputCoordXConvert(Pos pos, int boardsize);
4848
int outputCoordYConvert(Pos pos, int boardsize);
4949

50+
Pos parseCoord(std::string coordStr);
51+
5052
// -------------------------------------------------
5153
// Formatters
5254

Rapfi/game/movegen.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,8 @@ ScoredMove *findB4F3Defence(const Board &board, ScoredMove *const moveList)
550550

551551
*last++ = b4Pos;
552552

553-
for (int d = 0; d < 4; d++) {
554-
if (d != dir)
555-
last = findAllB3CounterDefence(b4Pos, d, last);
556-
}
553+
for (int d = 0; d < 4; d++)
554+
last = findAllB3CounterDefence(b4Pos, d, last);
557555
}
558556
}
559557

Rapfi/search/searchthread.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,6 @@ void ThreadPool::startThinking(const Board &board, const SearchOptions &options,
314314
assert(size() > 0);
315315
assert(searcher());
316316

317-
// Clear and init all threads state
318-
for (size_t i = 1; i < size(); i++)
319-
(*this)[i]->runTask([this](SearchThread &th) { th.clear(); });
320-
321317
main()->clear();
322318
main()->inPonder = inPonder;
323319
main()->searchOptions = options;
@@ -386,14 +382,14 @@ void ThreadPool::startThinking(const Board &board, const SearchOptions &options,
386382
}
387383
}
388384

389-
// Copy board and root moves from main thread to other threads
385+
// Clear threads state and copy board and root moves to other threads sequentially
390386
for (size_t i = 1; i < size(); i++) {
391-
(*this)[i]->runTask([this](SearchThread &th) {
392-
th.setBoardAndEvaluator(*main()->board);
393-
th.rootMoves = main()->rootMoves;
394-
if (main()->searchOptions.balanceMode == Search::SearchOptions::BALANCE_TWO)
395-
th.balance2Moves = main()->balance2Moves;
396-
});
387+
SearchThread &th = *(*this)[i];
388+
th.clear();
389+
th.setBoardAndEvaluator(*main()->board);
390+
th.rootMoves = main()->rootMoves;
391+
if (main()->searchOptions.balanceMode == Search::SearchOptions::BALANCE_TWO)
392+
th.balance2Moves = main()->balance2Moves;
397393
}
398394

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

0 commit comments

Comments
 (0)