using pseudo-random generated numbers in PlayRandMoves | bench 1136338
This commit is contained in:
1 parent
ff17972725
commit
1449a1545f
3 files changed
+29
-12
No files matched your search
+5
-7
@@ -9,6 +9,7 @@
|
||||
#include "evaluate.h"
|
||||
#include "search.h"
|
||||
#include "movegen.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -59,17 +60,12 @@ static bool IsGameOver(Board &board, SEARCH::SearchContext& ctx) {
|
||||
}
|
||||
|
||||
static void PlayRandMoves(Board &board, SEARCH::SearchContext& ctx) {
|
||||
std::random_device dev;
|
||||
std::mt19937_64 rng(dev());
|
||||
|
||||
std::uniform_int_distribution<int> moveDist(0, 1);
|
||||
bool plusOne = moveDist(rng);
|
||||
bool plusOne = UTILS::RandomBool();
|
||||
|
||||
for (int count = 0; count < RAND_MOVES + plusOne; count++) {
|
||||
MOVEGEN::GenerateMoves<All>(board);
|
||||
std::uniform_int_distribution<int> dist(0, board.currentMoveIndex - 1);
|
||||
|
||||
bool isLegal = board.MakeMove(board.moveList[dist(rng)]);
|
||||
bool isLegal = board.MakeMove(board.moveList[UTILS::RandomInt(0, board.currentMoveIndex - 1)]);
|
||||
|
||||
if (!isLegal) {
|
||||
count--;
|
||||
@@ -79,6 +75,8 @@ static void PlayRandMoves(Board &board, SEARCH::SearchContext& ctx) {
|
||||
MOVEGEN::GenerateMoves<All>(board);
|
||||
if (IsGameOver(board, ctx)) break;
|
||||
}
|
||||
|
||||
board.PrintBoard();
|
||||
}
|
||||
|
||||
static void WriteToFile(std::vector<Game> &gamesBuffer, std::ofstream &file) {
|
||||
|
||||
Reference in new issue
Block a user