encapsulated killerMoves and changed it to std::array
This commit is contained in:
1 parent
ac7325f295
commit
dd6f0b94f5
5 files changed
+9
-12
No files matched your search
@@ -69,7 +69,6 @@ void RunBenchmark() {
|
|||||||
|
|
||||||
// Clearing
|
// Clearing
|
||||||
TT.Clear();
|
TT.Clear();
|
||||||
std::memset(killerMoves, 0, sizeof(killerMoves));
|
|
||||||
|
|
||||||
SearchContext ctx;
|
SearchContext ctx;
|
||||||
|
|
||||||
@@ -82,6 +81,5 @@ void RunBenchmark() {
|
|||||||
|
|
||||||
std::cout << ctx.nodes << " nodes " << int(ctx.nodes/sw.GetElapsedSec()) << " nps" << std::endl;
|
std::cout << ctx.nodes << " nodes " << int(ctx.nodes/sw.GetElapsedSec()) << " nps" << std::endl;
|
||||||
TT.Clear();
|
TT.Clear();
|
||||||
std::memset(killerMoves, 0, sizeof(killerMoves));
|
|
||||||
positionIndex = 0;
|
positionIndex = 0;
|
||||||
}
|
}
|
||||||
@@ -102,8 +102,6 @@ void PlayGame(std::atomic<int>& positions, U64 targetPositions, std::vector<Game
|
|||||||
// Since positionIndex is thread-local, no need to protect it
|
// Since positionIndex is thread-local, no need to protect it
|
||||||
positionIndex = 0;
|
positionIndex = 0;
|
||||||
|
|
||||||
std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
|
|
||||||
|
|
||||||
SEARCH::SearchContext ctx;
|
SEARCH::SearchContext ctx;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+4
-4
@@ -40,9 +40,9 @@ static int ScoreMove(Board &board, Move &move, int ply, SearchContext& ctx) {
|
|||||||
|
|
||||||
return moveScoreTable[attackerType][targetType] + 30000;
|
return moveScoreTable[attackerType][targetType] + 30000;
|
||||||
} else {
|
} else {
|
||||||
if (killerMoves[0][ply] == move) {
|
if (ctx.killerMoves[0][ply] == move) {
|
||||||
return 20000;
|
return 20000;
|
||||||
} else if (killerMoves[1][ply] == move) {
|
} else if (ctx.killerMoves[1][ply] == move) {
|
||||||
return 18000;
|
return 18000;
|
||||||
} else {
|
} else {
|
||||||
// Max 16384
|
// Max 16384
|
||||||
@@ -328,8 +328,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply, SearchCo
|
|||||||
// Fail high (beta cutoff)
|
// Fail high (beta cutoff)
|
||||||
if (score >= beta) {
|
if (score >= beta) {
|
||||||
if (!currMove.IsCapture()) {
|
if (!currMove.IsCapture()) {
|
||||||
killerMoves[1][ply] = killerMoves[0][ply];
|
ctx.killerMoves[1][ply] = ctx.killerMoves[0][ply];
|
||||||
killerMoves[0][ply] = currMove;
|
ctx.killerMoves[0][ply] = currMove;
|
||||||
|
|
||||||
int bonus = depth * depth;
|
int bonus = depth * depth;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -22,9 +22,6 @@ constexpr int MAX_HISTORY = 16384;
|
|||||||
|
|
||||||
constexpr int inf = 100000;
|
constexpr int inf = 100000;
|
||||||
|
|
||||||
// [id][ply]
|
|
||||||
inline int killerMoves[2][MAX_PLY];
|
|
||||||
|
|
||||||
inline int lmrTable[MAX_DEPTH+1][MAX_MOVES];
|
inline int lmrTable[MAX_DEPTH+1][MAX_MOVES];
|
||||||
|
|
||||||
void InitLMRTable();
|
void InitLMRTable();
|
||||||
@@ -115,12 +112,15 @@ public:
|
|||||||
PVLine pvLine;
|
PVLine pvLine;
|
||||||
History history;
|
History history;
|
||||||
|
|
||||||
|
std::array<std::array<int, MAX_PLY>, 2> killerMoves{};
|
||||||
|
|
||||||
Stopwatch sw;
|
Stopwatch sw;
|
||||||
|
|
||||||
SearchContext(){
|
SearchContext(){
|
||||||
pvLine.Clear();
|
pvLine.Clear();
|
||||||
history.Clear();
|
history.Clear();
|
||||||
sw.Restart();
|
sw.Restart();
|
||||||
|
killerMoves = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -136,9 +136,10 @@ void UCILoop(Board &board) {
|
|||||||
|
|
||||||
// Clearing
|
// Clearing
|
||||||
TT.Clear();
|
TT.Clear();
|
||||||
std::memset(SEARCH::killerMoves, 0, sizeof(SEARCH::killerMoves));
|
|
||||||
|
|
||||||
|
ctx.killerMoves = {};
|
||||||
ctx.history.Clear();
|
ctx.history.Clear();
|
||||||
|
|
||||||
positionIndex = 0;
|
positionIndex = 0;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in new issue
Block a user