8 Commits
Author SHA1 Message Date
rektdie 3b2cb8839b minor corrhist | bench 1406680 2026-09-28 21:19:42 +02:00
rektdie ecd57607f3 Merge pull request #187 from rektdie/corrhist-fh
corrhist update on fail high | bench 1202015
2026-09-28 20:51:59 +02:00
rektdie be9982eb75 corrhist update on fail high | bench 1202015 2026-09-28 19:13:14 +02:00
rektdie babe3d0db0 Merge pull request #186 from rektdie/50mr-scaling
50 mr scaling | bench 1331806
2026-09-26 09:52:42 +02:00
rektdie 30e54c2b71 50 mr scaling | bench 1331806 2026-09-19 21:31:08 +02:00
rektdie 1470ad34a8 Merge pull request #185 from rektdie/more-stages
more stages in movepicker | bench 1468577
2026-09-19 21:22:25 +02:00
rektdie f23a59730b more stages in movepicker | bench 1468577 | bench 1468577 2026-09-19 15:59:05 +02:00
rektdie dbd56e0c21 Update README.md 2026-05-13 22:46:52 +02:00
10 changed files with 283 additions and 144 deletions

No files matched your search

+6 -6
View File
@@ -12,12 +12,12 @@
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/rektdie/Eleanor/total?color=orange)
| Version | Release Date | [CCRL 40/15](https://www.computerchess.org.uk/ccrl/4040/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) | [CCRL Blitz](https://www.computerchess.org.uk/ccrl/404/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) |
| --- | --- | --- | --- |
| 4.1 | 2026-04-22 | - | -
| 3.0 | 2025-12-05 | 3405 (#84) | 3495 (#79-80)
| 2.0 | 2025-08-23 | 3312 (#115) | 3392 (#105)
| 1.0 | 2025-06-02 | 2856 (#244) | 2759 (#256)
| Version | Release Date | [CCRL 40/15](https://www.computerchess.org.uk/ccrl/4040/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) | [CCRL Blitz](https://www.computerchess.org.uk/ccrl/404/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) | [CEGT 40/20](http://www.cegt.net/40_40%20Rating%20List/40_40%20SingleVersion/rangliste.html)
| --- | --- | --- | --- | --- |
| 4.1 | 2026-04-22 | 3528 (#60-61) | 3590 (#64) | 3443 (#59)
| 3.0 | 2025-12-05 | 3405 (#84) | 3495 (#79-80) | -
| 2.0 | 2025-08-23 | 3312 (#115) | 3392 (#105) | -
| 1.0 | 2025-06-02 | 2856 (#244) | 2759 (#256) | -
</div>
+6
View File
@@ -45,6 +45,7 @@ void Board::Reset() {
pawnKey = 0ULL;
nonPawnKey = 0ULL;
majorKey = 0ULL;
minorKey = 0ULL;
checkZones = std::array<Bitboard, 4>();
}
@@ -97,6 +98,7 @@ void Board::SetByFen(std::string_view fen) {
pawnKey = 0ULL;
nonPawnKey = 0ULL;
majorKey = 0ULL;
minorKey = 0ULL;
occupied = colors[White] | colors[Black];
hashKey = UTILS::GetHashKey(*this);
@@ -310,6 +312,8 @@ void Board::SetPiece(int piece, int square, bool color) {
if (piece == King || piece == Rook || piece == Queen) {
majorKey ^= UTILS::zKeys[color][piece][square];
} else if (piece == Knight || piece == Bishop) {
minorKey ^= UTILS::zKeys[color][piece][square];
}
}
}
@@ -330,6 +334,8 @@ void Board::RemovePiece(int piece, int square, bool color) {
if (piece == King || piece == Rook || piece == Queen) {
majorKey ^= UTILS::zKeys[color][piece][square];
} else if (piece == Knight || piece == Bishop) {
minorKey ^= UTILS::zKeys[color][piece][square];
}
}
}
+1
View File
@@ -48,6 +48,7 @@ public:
U64 pawnKey = 0ULL;
U64 nonPawnKey = 0ULL;
U64 majorKey = 0ULL;
U64 minorKey = 0ULL;
std::array<Bitboard, 4> checkZones;
+1 -1
View File
@@ -38,7 +38,7 @@ template <MovegenMode mode>
void GenKingMoves(Board &board);
template <MovegenMode mode>
void GenerateMoves(Board &board, bool clear);
void GenerateMoves(Board &board, bool clear, bool recalcThreats = true);
void GenThreatMaps(Board &board);
+3 -3
View File
@@ -270,14 +270,14 @@ void GenKingMoves(Board &board) {
}
template <MovegenMode mode>
void GenerateMoves(Board &board, bool clear) {
void GenerateMoves(Board &board, bool clear, bool recalcThreats) {
if (clear) {
board.ResetMoves();
board.pieceThreats = {};
board.colorThreats = {};
}
if (recalcThreats) {
GenThreatMaps(board);
}
GenPawnMoves<mode>(board);
GenKnightMoves<mode>(board);
+209
View File
@@ -0,0 +1,209 @@
#include "movepicker.h"
#include "search.h"
#include "tunables.h"
#include <utility>
namespace SEARCH {
template <MovegenMode mode>
MovePicker<mode>::MovePicker(Board &b, SearchContext *c, int p, Move tt)
: board(b), ctx(c), ply(p), ttMove(tt), killerMove(), stage(PickStage::TTMove) {
if (!ttMove || !board.IsPseudoLegal(ttMove)) {
ttMove = Move();
}
if constexpr (mode == Noisy) {
if (ttMove && !(ttMove.IsCapture() || ttMove.IsPromo())) {
ttMove = Move();
}
} else {
Move killer = ctx->killerMoves[ply];
if (killer && killer != ttMove && !killer.IsCapture() && !killer.IsPromo()
&& board.IsPseudoLegal(killer)) {
killerMove = killer;
}
}
}
template <MovegenMode mode>
int MovePicker<mode>::ScoreNoisyMove(Move move) {
int score = MoveEstimatedValue(board, move) * noisyScoreScale;
if (move.IsCapture()) {
int attackerType = board.GetPieceType(move.MoveFrom());
int targetType = (move.GetFlags() == epCapture) ? Pawn : board.GetPieceType(move.MoveTo());
score += ctx->capthist[board.sideToMove][attackerType][targetType][move.MoveTo()];
}
return score;
}
template <MovegenMode mode>
int MovePicker<mode>::ScoreQuietMove(Move move) {
bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveFrom());
bool targetThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveTo());
int score = ctx->history[board.sideToMove][move.MoveFrom()][move.MoveTo()][sourceThreatened][targetThreatened];
if (ply > 0) score += ctx->conthist.GetNPly(board, move, ctx, ply, 1);
if (ply > 1) score += ctx->conthist.GetNPly(board, move, ctx, ply, 2);
return score;
}
template <MovegenMode mode>
void MovePicker<mode>::ScoreNoisyRange() {
noisyStart = 0;
MOVEGEN::GenerateMoves<Noisy>(board, true, false);
int rawEnd = board.currentMoveIndex;
int write = noisyStart;
for (int read = noisyStart; read < rawEnd; read++) {
Move m = board.moveList[read];
if (m == ttMove || m == killerMove) continue;
board.moveList[write] = m;
scores[write] = ScoreNoisyMove(m);
write++;
}
noisyEnd = write;
board.currentMoveIndex = noisyEnd;
int goodWrite = noisyStart;
for (int i = noisyStart; i < noisyEnd; i++) {
Move m = board.moveList[i];
if (SEE(board, m, seeOrderingThreshold)) {
if (i != goodWrite) {
std::swap(board.moveList[i], board.moveList[goodWrite]);
std::swap(scores[i], scores[goodWrite]);
}
goodWrite++;
}
}
goodNoisyEnd = goodWrite;
noisyCursor = noisyStart;
badNoisyCursor = goodNoisyEnd;
}
template <MovegenMode mode>
void MovePicker<mode>::ScoreQuietRange() {
quietStart = noisyEnd;
MOVEGEN::GenerateMoves<Quiet>(board, false, false);
int rawEnd = board.currentMoveIndex;
int write = quietStart;
for (int read = quietStart; read < rawEnd; read++) {
Move m = board.moveList[read];
if (m == ttMove || m == killerMove) continue;
board.moveList[write] = m;
scores[write] = ScoreQuietMove(m);
write++;
}
quietEnd = write;
board.currentMoveIndex = quietEnd;
quietCursor = quietStart;
}
template <MovegenMode mode>
Move MovePicker<mode>::PopBest(int &cursor, int end) {
if (cursor >= end) return Move();
int bestIdx = cursor;
for (int i = cursor + 1; i < end; i++) {
if (scores[i] > scores[bestIdx]) bestIdx = i;
}
if (bestIdx != cursor) {
std::swap(board.moveList[bestIdx], board.moveList[cursor]);
std::swap(scores[bestIdx], scores[cursor]);
}
Move best = board.moveList[cursor];
cursor++;
return best;
}
template <MovegenMode mode>
Move MovePicker<mode>::Next() {
while (true) {
switch (stage) {
case PickStage::TTMove: {
stage = PickStage::GenNoisy;
if (ttMove) return ttMove;
continue;
}
case PickStage::GenNoisy: {
ScoreNoisyRange();
stage = PickStage::GoodNoisy;
continue;
}
case PickStage::GoodNoisy: {
Move m = PopBest(noisyCursor, goodNoisyEnd);
if (m) return m;
if constexpr (mode == Noisy) {
stage = PickStage::BadNoisy;
} else {
stage = PickStage::Killer;
}
continue;
}
case PickStage::Killer: {
stage = PickStage::GenQuiet;
if (killerMove) return killerMove;
continue;
}
case PickStage::GenQuiet: {
ScoreQuietRange();
stage = PickStage::Quiet;
continue;
}
case PickStage::Quiet: {
Move m = PopBest(quietCursor, quietEnd);
if (m) return m;
stage = PickStage::BadNoisy;
continue;
}
case PickStage::BadNoisy: {
Move m = PopBest(badNoisyCursor, noisyEnd);
if (m) return m;
stage = PickStage::Finished;
return Move();
}
case PickStage::Finished:
return Move();
default:
return Move();
}
}
}
template class MovePicker<Noisy>;
template class MovePicker<All>;
}
+37 -131
View File
@@ -1,155 +1,61 @@
#pragma once
#include "search.h"
#include <array>
#include "board.h"
#include "movegen.h"
#include <limits>
namespace SEARCH {
using namespace SEARCH;
class SearchContext;
enum class PickStage {
TTMove,
GenNoisy,
GoodNoisy,
Killer,
GenQuiet,
Quiet,
BadNoisy,
Finished
};
template <MovegenMode mode>
class MovePicker {
private:
enum Stage {
TT,
Rest,
End
};
public:
MovePicker(Board &board, SearchContext *ctx, int ply, Move ttMove);
Move Next();
private:
Board &board;
SearchContext *ctx;
Move ttMove;
int ply;
Stage stage;
int index;
bool generated;
Move ttMove;
Move killerMove;
int scores[MAX_MOVES];
PickStage stage;
public:
MovePicker(Board& b, SearchContext* c, int p, Move tt)
: board(b), ctx(c), ttMove(tt), ply(p), stage(TT), index(0), generated(false)
{
}
int noisyStart = 0;
int noisyEnd = 0;
int goodNoisyEnd = 0;
Move Next() {
while (true) {
switch (stage) {
int quietStart = 0;
int quietEnd = 0;
case TT: {
stage = Rest;
int noisyCursor = 0;
int badNoisyCursor = 0;
int quietCursor = 0;
if (ttMove && board.IsPseudoLegal(ttMove))
return ttMove;
break;
}
std::array<int, MAX_MOVES> scores{};
case Rest: {
void ScoreNoisyRange();
if (!generated) {
generated = true;
void ScoreQuietRange();
MOVEGEN::GenerateMoves<mode>(board, true);
int ScoreNoisyMove(Move move);
int ScoreQuietMove(Move move);
ScoreAllMoves();
index = 0;
}
while (index < board.currentMoveIndex) {
int idx = FindNext();
Move m = board.moveList[idx];
if (m == ttMove)
continue;
return m;
}
stage = End;
break;
}
case End:
return Move();
}
}
}
private:
int ScoreMove(Move& move) {
if (move.IsCapture()) {
int attackerType = board.GetPieceType(move.MoveFrom());
int targetType = board.GetPieceType(move.MoveTo());
if (move.GetFlags() == epCapture)
targetType = Pawn;
int capthistScore =
ctx->capthist[board.sideToMove][attackerType][targetType][move.MoveTo()];
return 50000 * SEE(board, move, seeOrderingThreshold)
+ (100 * targetType - attackerType + 105)
+ capthistScore;
}
if (ctx->killerMoves[ply] == move)
return 41000;
bool sourceThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveFrom());
bool targetThreatened = board.IsSquareThreatened(board.sideToMove, move.MoveTo());
int historyScore =
ctx->history[board.sideToMove]
[move.MoveFrom()]
[move.MoveTo()]
[sourceThreatened]
[targetThreatened];
int conthistScore = 0;
if (ply > 0) {
conthistScore = ctx->conthist.GetNPly(board, move, ctx, ply, 1);
if (ply > 1)
conthistScore += ctx->conthist.GetNPly(board, move, ctx, ply, 2);
}
return 20000 + historyScore + conthistScore;
}
void ScoreAllMoves() {
int moveCount = board.currentMoveIndex;
for (int i = 0; i < moveCount; i++)
scores[i] = ScoreMove(board.moveList[i]);
}
int FindNext() {
const auto toU64 = [](int s) {
int64_t widened = s;
widened -= std::numeric_limits<int32_t>::min();
return static_cast<uint64_t>(widened) << 32;
Move PopBest(int &cursor, int end);
};
int moveCount = board.currentMoveIndex;
uint64_t best = toU64(scores[index]) | static_cast<uint64_t>(256 - index);
for (int i = index + 1; i < moveCount; i++) {
uint64_t curr = toU64(scores[i]) | static_cast<uint64_t>(256 - i);
if (curr > best)
best = curr;
}
int bestIdx = 256 - static_cast<int>(best & 0xFFFFFFFF);
if (bestIdx != index) {
std::swap(board.moveList[index], board.moveList[bestIdx]);
std::swap(scores[index], scores[bestIdx]);
}
return index++;
}
};
+12 -1
View File
@@ -78,7 +78,12 @@ static int AdjustEval(Board &board, SearchContext* ctx, int eval) {
int mateFound = MATE_SCORE - MAX_DEPTH;
return std::clamp(eval + corrhist / CORRHIST_GRAIN, -mateFound + 1, mateFound - 1);
int adjusted = eval + corrhist / CORRHIST_GRAIN;
const int scaleNumerator = std::max(0, fiftyMoveScaleBase - board.halfMoves);
adjusted = adjusted * scaleNumerator / fiftyMoveScaleBase;
return std::clamp(adjusted, -mateFound + 1, mateFound - 1);
}
static bool IsTwoFold(Board &board, SearchContext* ctx) {
@@ -775,6 +780,12 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
UpdateCaptHist(seenCaptures[i], -captHistoryMalus);
}
// Corrhist update on fail high
if (!ctx->excluded && !inCheck && currMove.IsQuiet() && score > staticEval) {
int corrHistBonus = std::clamp(score - staticEval, -CORRHIST_LIMIT, CORRHIST_LIMIT);
ctx->corrhist.UpdateAll(board, depth, corrHistBonus);
}
if (!ctx->excluded)
ctx->TT->WriteEntry(board.hashKey, depth, score, CutNode, currMove, ttpv);
return score;
+5 -1
View File
@@ -82,6 +82,7 @@ private:
MultiArray<int, 2, CORRHIST_SIZE> pawnHist;
MultiArray<int, 2, CORRHIST_SIZE> nonPawnHist;
MultiArray<int, 2, CORRHIST_SIZE> majorHist;
MultiArray<int, 2, CORRHIST_SIZE> minorHist;
public:
void Update(Board& board, int depth, int diff, int* entry) {
const int scaledDiff = diff * CORRHIST_GRAIN;
@@ -95,18 +96,21 @@ public:
Update(board, depth, diff, &pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]);
Update(board, depth, diff, &nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]);
Update(board, depth, diff, &majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE]);
Update(board, depth, diff, &minorHist[board.sideToMove][board.minorKey % CORRHIST_SIZE]);
}
int GetAllHist(Board& board) {
return pawnHist[board.sideToMove][board.pawnKey % CORRHIST_SIZE]
+ nonPawnHist[board.sideToMove][board.nonPawnKey % CORRHIST_SIZE]
+ majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE];
+ majorHist[board.sideToMove][board.majorKey % CORRHIST_SIZE]
+ minorHist[board.sideToMove][board.minorKey % CORRHIST_SIZE];
}
void Clear() {
std::fill(&pawnHist[0][0], &pawnHist[0][0] + sizeof(pawnHist) / sizeof(int), 0);
std::fill(&nonPawnHist[0][0], &nonPawnHist[0][0] + sizeof(nonPawnHist) / sizeof(int), 0);
std::fill(&majorHist[0][0], &majorHist[0][0] + sizeof(majorHist) / sizeof(int), 0);
std::fill(&minorHist[0][0], &minorHist[0][0] + sizeof(minorHist) / sizeof(int), 0);
}
};
+3 -1
View File
@@ -41,6 +41,7 @@
X_INT(seeQsThreshold, -13, -120, 120) \
X_INT(seeOrderingThreshold, -102, -200, 0) \
X_INT(ldseMargin, 26, 0, 96) \
X_INT(noisyScoreScale, 32, 0, 96) \
X_INT(historyBonusMultiplier, 306, 280, 320) \
X_INT(historyBonusSub, 252, 235, 265) \
X_INT(historyMalusMultiplier, 301, 280, 320) \
@@ -52,7 +53,8 @@
X_INT(captHistoryBonusMultiplier, 302, 280, 320) \
X_INT(captHistoryBonusSub, 249, 235, 265) \
X_INT(captHistoryMalusMultiplier, 300, 280, 320) \
X_INT(captHistoryMalusSub, 249, 235, 265)
X_INT(captHistoryMalusSub, 249, 235, 265) \
X_INT(fiftyMoveScaleBase, 200, 100, 400)
#ifdef TUNING
#define X_DOUBLE(name, default_val, min_val, max_val) \