Threefold #22
No files matched your search
@@ -64,6 +64,7 @@ void RunBenchmark() {
|
|||||||
int ply = 0;
|
int ply = 0;
|
||||||
benchStarted = true;
|
benchStarted = true;
|
||||||
searchStopped = false;
|
searchStopped = false;
|
||||||
|
positionIndex = 0;
|
||||||
|
|
||||||
// Clearing
|
// Clearing
|
||||||
TT.Clear();
|
TT.Clear();
|
||||||
@@ -82,4 +83,5 @@ void RunBenchmark() {
|
|||||||
nodes = 0;
|
nodes = 0;
|
||||||
TT.Clear();
|
TT.Clear();
|
||||||
benchStarted = false;
|
benchStarted = false;
|
||||||
|
positionIndex = 0;
|
||||||
}
|
}
|
||||||
@@ -343,6 +343,9 @@ void Board::MakeMove(Move move) {
|
|||||||
enPassantTarget = newEpTarget;
|
enPassantTarget = newEpTarget;
|
||||||
|
|
||||||
GenAttackMaps(*this);
|
GenAttackMaps(*this);
|
||||||
|
|
||||||
|
positionIndex++;
|
||||||
|
positionHistory[positionIndex] = hashKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Board::InPossibleZug(bool side) {
|
bool Board::InPossibleZug(bool side) {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
constexpr int nullPieceType = 100;
|
constexpr int nullPieceType = 100;
|
||||||
constexpr int noEPTarget = -1;
|
constexpr int noEPTarget = -1;
|
||||||
|
|
||||||
|
inline int positionIndex = 0;
|
||||||
|
inline U64 positionHistory[1000];
|
||||||
|
|
||||||
class Board {
|
class Board {
|
||||||
public:
|
public:
|
||||||
Board() {
|
Board() {
|
||||||
|
|||||||
@@ -83,6 +83,18 @@ void ListScores(Board &board, int ply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsThreefold(Board &board) {
|
||||||
|
for (int i = 0; i < positionIndex; i++) {
|
||||||
|
if (positionHistory[i] == board.hashKey) {
|
||||||
|
// repetition found
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no repetition
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
||||||
if (!benchStarted) {
|
if (!benchStarted) {
|
||||||
if (sw.GetElapsedMS() >= timeToSearch) {
|
if (sw.GetElapsedMS() >= timeToSearch) {
|
||||||
@@ -112,6 +124,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
|||||||
Board copy = board;
|
Board copy = board;
|
||||||
copy.MakeMove(board.moveList[i]);
|
copy.MakeMove(board.moveList[i]);
|
||||||
int score = -Quiescence(copy, -beta, -alpha, ply + 1).score;
|
int score = -Quiescence(copy, -beta, -alpha, ply + 1).score;
|
||||||
|
positionIndex--;
|
||||||
|
|
||||||
if (score >= beta) {
|
if (score >= beta) {
|
||||||
return score;
|
return score;
|
||||||
@@ -140,6 +153,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pvLine.SetLength(ply);
|
pvLine.SetLength(ply);
|
||||||
|
if (ply && IsThreefold(board)) return 0;
|
||||||
|
|
||||||
|
|
||||||
// if NOT PV node then we try to hit the TTable
|
// if NOT PV node then we try to hit the TTable
|
||||||
if (beta - alpha == 1) {
|
if (beta - alpha == 1) {
|
||||||
@@ -217,6 +232,8 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
positionIndex--;
|
||||||
|
|
||||||
// Fail high (beta cutoff)
|
// Fail high (beta cutoff)
|
||||||
if (score >= beta) {
|
if (score >= beta) {
|
||||||
if (!currMove.IsCapture()) {
|
if (!currMove.IsCapture()) {
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ void UCILoop(Board &board) {
|
|||||||
// parse UCI "position" command
|
// parse UCI "position" command
|
||||||
if (input.find("position") != std::string::npos) {
|
if (input.find("position") != std::string::npos) {
|
||||||
ParsePosition(board, input);
|
ParsePosition(board, input);
|
||||||
|
positionIndex = 0;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +120,8 @@ void UCILoop(Board &board) {
|
|||||||
TT.Clear();
|
TT.Clear();
|
||||||
std::memset(killerMoves, 0, sizeof(killerMoves));
|
std::memset(killerMoves, 0, sizeof(killerMoves));
|
||||||
std::memset(historyMoves, 0, sizeof(historyMoves));
|
std::memset(historyMoves, 0, sizeof(historyMoves));
|
||||||
|
positionIndex = 0;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user