final refactor | bench 900613

This commit is contained in:
rektdie committed 2025-03-20 21:14:07 +01:00
1 parent f2d76b1133
commit 729ba94123
7 files changed
+15 -7

No files matched your search

+2
View File
@@ -6,6 +6,8 @@
#include "stopwatch.h" #include "stopwatch.h"
#include "tt.h" #include "tt.h"
using namespace SEARCH;
constexpr std::array<std::string_view, 50> fenPositions = { constexpr std::array<std::string_view, 50> fenPositions = {
"rnbq1k1r/ppp1bppp/4pn2/8/2B5/2NP1N2/PPP2PPP/R1BQR1K1 b - - 2 8", "rnbq1k1r/ppp1bppp/4pn2/8/2B5/2NP1N2/PPP2PPP/R1BQR1K1 b - - 2 8",
"rnbq1k1r/pp2bppp/4pn2/2p5/2B2B2/2NP1N2/PPP2PPP/R2QR1K1 b - - 1 9", "rnbq1k1r/pp2bppp/4pn2/2p5/2B2B2/2NP1N2/PPP2PPP/R2QR1K1 b - - 1 9",
+1 -1
View File
@@ -217,7 +217,7 @@ void Board::Promote(int square, int pieceType, int color, bool isCapture) {
} }
void Board::MakeMove(Move move) { void Board::MakeMove(Move move) {
nodes++; SEARCH::nodes++;
// Null Move // Null Move
if (!move) { if (!move) {
+3
View File
@@ -6,6 +6,8 @@
#include "tt.h" #include "tt.h"
#include "stopwatch.h" #include "stopwatch.h"
namespace SEARCH {
U64 nodes = 0; U64 nodes = 0;
bool benchStarted = false; bool benchStarted = false;
@@ -361,3 +363,4 @@ void SearchPosition(Board &board, SearchParams params) {
void StopSearch() { void StopSearch() {
searchStopped = true; searchStopped = true;
} }
}
+3
View File
@@ -5,6 +5,8 @@
#include "move.h" #include "move.h"
#include <algorithm> #include <algorithm>
namespace SEARCH {
constexpr int maxDepth = 64; constexpr int maxDepth = 64;
constexpr int maxHistory = 16384; constexpr int maxHistory = 16384;
@@ -108,3 +110,4 @@ constexpr int moveScoreTable[6][6] = {
}; };
void ListScores(Board &board); void ListScores(Board &board);
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "tt.h" #include "tt.h"
SearchResults TTable::ReadEntry(U64 &hashKey, int depth, int alpha, int beta) { SEARCH::SearchResults TTable::ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
TTEntry *current = &table[hashKey % hashSize]; TTEntry *current = &table[hashKey % hashSize];
if (current->hashKey == hashKey) { if (current->hashKey == hashKey) {
+1 -1
View File
@@ -56,7 +56,7 @@ public:
return count; return count;
} }
SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta); SEARCH::SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta);
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove); void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove);
}; };
+4 -4
View File
@@ -72,7 +72,7 @@ static void ParseGo(Board &board, std::string &command) {
params.btime = ReadParam("movetime", command); params.btime = ReadParam("movetime", command);
} }
auto worker = std::thread(SearchPosition, std::ref(board), params); auto worker = std::thread(SEARCH::SearchPosition, std::ref(board), params);
worker.detach(); worker.detach();
} }
@@ -118,9 +118,9 @@ void UCILoop(Board &board) {
// Clearing // Clearing
TT.Clear(); TT.Clear();
std::memset(killerMoves, 0, sizeof(killerMoves)); std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
history.Clear(); SEARCH::history.Clear();
positionIndex = 0; positionIndex = 0;
continue; continue;
@@ -141,7 +141,7 @@ void UCILoop(Board &board) {
// parse UCI "stop" command // parse UCI "stop" command
if (input.find("stop") != std::string::npos) { if (input.find("stop") != std::string::npos) {
// stop the loop // stop the loop
StopSearch(); SEARCH::StopSearch();
continue; continue;
} }