Refactor #26

Merged
rektdie merged 11 commits from refactor into main 2025-03-21 10:52:24 +01:00
7 changed files with 26 additions and 18 deletions
Showing only changes of commit 729ba94123 - Show all commits

No files matched your search

+2
View File
@@ -6,6 +6,8 @@
#include "stopwatch.h"
#include "tt.h"
using namespace SEARCH;
constexpr std::array<std::string_view, 50> fenPositions = {
"rnbq1k1r/ppp1bppp/4pn2/8/2B5/2NP1N2/PPP2PPP/R1BQR1K1 b - - 2 8",
"rnbq1k1r/pp2bppp/4pn2/2p5/2B2B2/2NP1N2/PPP2PPP/R2QR1K1 b - - 1 9",
+12 -12
View File
@@ -217,28 +217,28 @@ void Board::Promote(int square, int pieceType, int color, bool isCapture) {
}
void Board::MakeMove(Move move) {
nodes++;
// Null Move
SEARCH::nodes++;
// Null Move
if (!move) {
int newEpTarget = noEPTarget;
int newEpTarget = noEPTarget;
sideToMove = !sideToMove;
hashKey ^= UTILS::zSide;
if (enPassantTarget != noEPTarget) {
hashKey ^= UTILS::zEnPassant[enPassantTarget % 8];
hashKey ^= UTILS::zEnPassant[enPassantTarget % 8];
}
if (newEpTarget != noEPTarget) {
hashKey ^= UTILS::zEnPassant[newEpTarget % 8];
hashKey ^= UTILS::zEnPassant[newEpTarget % 8];
}
enPassantTarget = newEpTarget;
return;
}
int newEpTarget = noEPTarget;
int attackerPiece = GetPieceType(move.MoveFrom());
+3
View File
@@ -6,6 +6,8 @@
#include "tt.h"
#include "stopwatch.h"
namespace SEARCH {
U64 nodes = 0;
bool benchStarted = false;
@@ -361,3 +363,4 @@ void SearchPosition(Board &board, SearchParams params) {
void StopSearch() {
searchStopped = true;
}
}
+3
View File
@@ -5,6 +5,8 @@
#include "move.h"
#include <algorithm>
namespace SEARCH {
constexpr int maxDepth = 64;
constexpr int maxHistory = 16384;
@@ -108,3 +110,4 @@ constexpr int moveScoreTable[6][6] = {
};
void ListScores(Board &board);
}
+1 -1
View File
@@ -1,6 +1,6 @@
#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];
if (current->hashKey == hashKey) {
+1 -1
View File
@@ -56,7 +56,7 @@ public:
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);
};
+4 -4
View File
@@ -72,7 +72,7 @@ static void ParseGo(Board &board, std::string &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();
}
@@ -118,9 +118,9 @@ void UCILoop(Board &board) {
// Clearing
TT.Clear();
std::memset(killerMoves, 0, sizeof(killerMoves));
std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
history.Clear();
SEARCH::history.Clear();
positionIndex = 0;
continue;
@@ -141,7 +141,7 @@ void UCILoop(Board &board) {
// parse UCI "stop" command
if (input.find("stop") != std::string::npos) {
// stop the loop
StopSearch();
SEARCH::StopSearch();
continue;
}