diff --git a/Makefile b/Makefile index 2e787c8..5b554bc 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,6 @@ $(OBJ_DIR): # Clean up build artifacts .PHONY: clean clean: - $(RM) $(OBJ_DIR) 2>nul || $(DEL) $(OBJ_DIR)\* $(OBJ_DIR) 2>nul - $(RM) $(EXE)$(EXE_EXT) 2>nul || $(DEL) $(EXE)$(EXE_EXT) 2>nul - $(MAKE) \ No newline at end of file + $(RM) $(OBJ_DIR) || $(DEL) $(OBJ_DIR)\* $(OBJ_DIR) + $(RM) $(EXE)$(EXE_EXT) || $(DEL) $(EXE)$(EXE_EXT) + $(MAKE) diff --git a/source/search.cpp b/source/search.cpp index 5e92f63..765c2f5 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -320,4 +320,4 @@ void SearchPosition(Board &board, SearchParams params) { void StopSearch() { searchStopped = true; -} \ No newline at end of file +} diff --git a/source/search.h b/source/search.h index 77cf87a..de1de74 100644 --- a/source/search.h +++ b/source/search.h @@ -55,8 +55,8 @@ public: } void Clear() { - length[maxDepth] = {}; - table[maxDepth][maxDepth] = {}; + length[maxDepth - 1] = {}; + table[maxDepth - 1][maxDepth - 1] = {}; } }; @@ -73,4 +73,4 @@ constexpr int moveScoreTable[6][6] = { 100, 200, 300, 400, 500, 600 }; -void ListScores(Board &board); \ No newline at end of file +void ListScores(Board &board); diff --git a/source/tt.h b/source/tt.h index 886e696..63731ee 100644 --- a/source/tt.h +++ b/source/tt.h @@ -1,7 +1,6 @@ #pragma once #include "board.h" #include "search.h" -#include // 2[colors] * 6[pieces] * 64[squares] extern U64 zKeys[2][6][64]; @@ -30,24 +29,21 @@ public: } }; +// 256 MB +constexpr U64 maxHash = (256 * 1000000) / sizeof(TTEntry); +constexpr U64 defaultHash = (5 * 1000000) / sizeof(TTEntry); + // 5 MB -inline int hashSize = (5 * 1000000) / sizeof(TTEntry); +inline U64 hashSize = defaultHash; + constexpr int invalidEntry = 111111; class TTable { private: - std::vector table; + std::array table; public: - TTable() { - table.reserve(hashSize); - } - - void Resize(int size) { - table.resize(size); - } - void Clear() { - table.clear(); + table.fill(TTEntry{}); } TTEntry* GetRawEntry(U64 &hashKey) { @@ -71,4 +67,4 @@ public: void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove); }; -inline TTable TT; \ No newline at end of file +inline TTable TT; diff --git a/source/uci.cpp b/source/uci.cpp index 4ab1a56..38b6873 100644 --- a/source/uci.cpp +++ b/source/uci.cpp @@ -165,7 +165,6 @@ void ParseGo(Board &board, std::string &command) { static void SetOption(std::string &command) { if (command.find("Hash") != std::string::npos) { hashSize = (ReadParam("value", command) * 1000000) / sizeof(TTEntry); - TT.Resize(hashSize); } }