Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e984510434 | ||
|
|
c7b545101e |
No files matched your search
@@ -484,6 +484,22 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
if (ply > ctx->seldepth)
|
if (ply > ctx->seldepth)
|
||||||
ctx->seldepth = ply;
|
ctx->seldepth = ply;
|
||||||
|
|
||||||
|
if (ply) {
|
||||||
|
const int matedScore = -MATE_SCORE + ply;
|
||||||
|
if (matedScore > alpha) {
|
||||||
|
alpha = matedScore;
|
||||||
|
if (alpha >= beta)
|
||||||
|
return alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int mateScore = MATE_SCORE - ply;
|
||||||
|
if (mateScore < beta) {
|
||||||
|
beta = mateScore;
|
||||||
|
if (alpha >= beta)
|
||||||
|
return beta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx->pvLine.SetLength(ply);
|
ctx->pvLine.SetLength(ply);
|
||||||
if (ply && (IsDraw(board, ctx))) return 0;
|
if (ply && (IsDraw(board, ctx))) return 0;
|
||||||
|
|
||||||
|
|||||||
+13
-16
@@ -2,7 +2,6 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "uci.h"
|
#include "uci.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "move.h"
|
#include "move.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -86,12 +85,9 @@ public:
|
|||||||
|
|
||||||
class CorrHist {
|
class CorrHist {
|
||||||
private:
|
private:
|
||||||
struct Tables {
|
MultiArray<int, 2, CORRHIST_SIZE> pawnHist;
|
||||||
MultiArray<int, 2, CORRHIST_SIZE> pawnHist{};
|
MultiArray<int, 2, CORRHIST_SIZE> nonPawnHist;
|
||||||
MultiArray<int, 2, CORRHIST_SIZE> nonPawnHist{};
|
MultiArray<int, 2, CORRHIST_SIZE> majorHist;
|
||||||
MultiArray<int, 2, CORRHIST_SIZE> majorHist{};
|
|
||||||
};
|
|
||||||
std::shared_ptr<Tables> t = std::make_shared<Tables>();
|
|
||||||
public:
|
public:
|
||||||
void Update(Board& board, int depth, int diff, int* entry) {
|
void Update(Board& board, int depth, int diff, int* entry) {
|
||||||
const int scaledDiff = diff * CORRHIST_GRAIN;
|
const int scaledDiff = diff * CORRHIST_GRAIN;
|
||||||
@@ -102,21 +98,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdateAll(Board& board, int depth, int diff) {
|
void UpdateAll(Board& board, int depth, int diff) {
|
||||||
Update(board, depth, diff, &t->pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]);
|
Update(board, depth, diff, &pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]);
|
||||||
Update(board, depth, diff, &t->nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]);
|
Update(board, depth, diff, &nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]);
|
||||||
Update(board, depth, diff, &t->majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE]);
|
Update(board, depth, diff, &majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetAllHist(Board& board) {
|
int GetAllHist(Board& board) {
|
||||||
return t->pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]
|
return pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]
|
||||||
+ t->nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]
|
+ nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]
|
||||||
+ t->majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE];
|
+ majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
std::fill(&t->pawnHist[0][0], &t->pawnHist[0][0] + sizeof(t->pawnHist) / sizeof(int), 0);
|
std::fill(&pawnHist[0][0], &pawnHist[0][0] + sizeof(pawnHist) / sizeof(int), 0);
|
||||||
std::fill(&t->nonPawnHist[0][0], &t->nonPawnHist[0][0] + sizeof(t->nonPawnHist) / sizeof(int), 0);
|
std::fill(&nonPawnHist[0][0], &nonPawnHist[0][0] + sizeof(nonPawnHist) / sizeof(int), 0);
|
||||||
std::fill(&t->majorHist[0][0], &t->majorHist[0][0] + sizeof(t->majorHist) / sizeof(int), 0);
|
std::fill(&majorHist[0][0], &majorHist[0][0] + sizeof(majorHist) / sizeof(int), 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -280,6 +276,7 @@ public:
|
|||||||
void CopyLearningFrom(const SearchContext& other) {
|
void CopyLearningFrom(const SearchContext& other) {
|
||||||
history = other.history;
|
history = other.history;
|
||||||
conthist = other.conthist;
|
conthist = other.conthist;
|
||||||
|
corrhist = other.corrhist;
|
||||||
capthist = other.capthist;
|
capthist = other.capthist;
|
||||||
killerMoves = other.killerMoves;
|
killerMoves = other.killerMoves;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user