playing matches in datagen | bench 1857933
This commit is contained in:
1 parent
f4eeec2b4e
commit
649bee6490
4 files changed
+52
-43
No files matched your search
+36
-15
@@ -19,16 +19,34 @@ static void PlayRandMoves(Board &board) {
|
||||
bool isLegal = board.MakeMove(board.moveList[dist(rng)]);
|
||||
if (!isLegal) count--;
|
||||
}
|
||||
|
||||
MOVEGEN::GenerateMoves<All>(board);
|
||||
}
|
||||
|
||||
static bool IsGameOver(Board &board) {
|
||||
// TODO
|
||||
bool isDraw = SEARCH::IsDraw(board);
|
||||
if (isDraw) return true;
|
||||
|
||||
int moveSeen = 0;
|
||||
|
||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||
Board copy = board;
|
||||
bool isLegal = copy.MakeMove(board.moveList[i]);
|
||||
|
||||
if (!isLegal) continue;
|
||||
positionIndex--;
|
||||
moveSeen++;
|
||||
}
|
||||
|
||||
if (moveSeen == 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Run(int games) {
|
||||
for (int i = 0; i < games; i++) {
|
||||
Game game;
|
||||
Board board;
|
||||
MarlinFormat position;
|
||||
|
||||
uint8_t wdl = 1;
|
||||
positionIndex = 0;
|
||||
std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
|
||||
@@ -36,25 +54,28 @@ void Run(int games) {
|
||||
|
||||
PlayRandMoves(board);
|
||||
|
||||
int staticEval = HCE::Evaluate(board);
|
||||
|
||||
SEARCH::SearchResults safeResults;
|
||||
|
||||
// while (!IsGameOver(board)) {
|
||||
// SEARCH::SearchResults results = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams());
|
||||
|
||||
// if (!results.bestMove) break;
|
||||
// safeResults = results;
|
||||
MOVEGEN::GenerateMoves<All>(board);
|
||||
|
||||
// board.MakeMove(results.bestMove);
|
||||
// }
|
||||
|
||||
if (std::abs(safeResults.score) >= SEARCH::inf - SEARCH::MAX_DEPTH) {
|
||||
while (!IsGameOver(board)) {
|
||||
SEARCH::SearchResults results = SEARCH::SearchPosition<SEARCH::datagen>(board, SearchParams());
|
||||
|
||||
if (!results.bestMove) break;
|
||||
safeResults = results;
|
||||
|
||||
game.moves.push_back(ScoredMove(results.bestMove, results.score));
|
||||
board.MakeMove(results.bestMove);
|
||||
MOVEGEN::GenerateMoves<All>(board);
|
||||
}
|
||||
|
||||
if (std::abs(safeResults.score) >= std::abs(SEARCH::MATE_SCORE) - SEARCH::MAX_PLY) {
|
||||
wdl = board.sideToMove ? 2 : 0;
|
||||
}
|
||||
|
||||
position.packFrom(board, HCE::Evaluate(board), wdl);
|
||||
board.PrintBoard();
|
||||
std::cout << "Eval: " << position.eval << std::endl;
|
||||
std::cout << "WDL: " << int(position.wdl) << std::endl;
|
||||
game.format.packFrom(board, staticEval, wdl);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user