Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions engine/includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ constexpr Value VALUE_INFINITE = 32000;
constexpr Value VALUE_MATE = 30002; // Add 2 as a consequence of our evaluation function only returning MATE when king is taken
constexpr Value VALUE_MATE_MAX_PLY = VALUE_MATE - MAX_PLY;

constexpr Value PawnValue = 100;
constexpr Value PawnValue = 98;
constexpr Value KnightValue = 350;
constexpr Value BishopValue = 350;
constexpr Value RookValue = 525;
constexpr Value QueenValue = 1000;
constexpr Value BishopValue = 348;
constexpr Value RookValue = 526;
constexpr Value QueenValue = 1002;
constexpr Value VALUE_MAX = QueenValue * 9 + (KnightValue + BishopValue + RookValue) * 2;

constexpr Value MAX_HISTORY = 16384;
Expand Down
2 changes: 1 addition & 1 deletion engine/movetimings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
uint64_t timemgmt(int64_t remtime, int64_t inc = 0, bool online = 0) {
// Return time in ms that we can spend on this move
if (online && remtime < 5000) return 100;
return std::max(1ll, (long long)(remtime / 25 + inc * 3 / 5));
return std::max(1ll, (long long)(remtime * 0.0504 + inc * 0.6261));
}
23 changes: 12 additions & 11 deletions engine/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ __attribute__((constructor)) void init_mvvlva() {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
if (i == KING)
MVV_LVA[i][j] = QueenValue * 12 + 1; // Prioritize over all other captures
MVV_LVA[i][j] = QueenValue * 13 + 1; // Prioritize over all other captures
else
MVV_LVA[i][j] = PieceValue[i] * 12 - PieceValue[j];
MVV_LVA[i][j] = PieceValue[i] * 13 - PieceValue[j];
}
}
}
Expand Down Expand Up @@ -222,12 +222,12 @@ pzstd::vector<std::pair<Move, Value>> order_moves(Board &board, pzstd::vector<Mo
score = history[board.side][move.src()][move.dst()];
}
if (move == killer[0][depth]) {
score += 1500; // Killer move bonus
score += 1461; // Killer move bonus
} else if (move == killer[1][depth]) {
score += 800; // Second killer move bonus
score += 831; // Second killer move bonus
}
if (ply && move == cmh[board.side][line[ply-1].src()][line[ply-1].dst()]) {
score += 1000; // Counter-move bonus
score += 1003; // Counter-move bonus
}
scores.push_back({move, score});
}
Expand Down Expand Up @@ -331,7 +331,7 @@ Value __recurse(Board &board, int depth, Value alpha = -VALUE_INFINITE, Value be
bool entry_exists = false;
pzstd::vector<std::pair<Move, Value>> scores = order_moves(board, moves, side, depth, ply, entry_exists);

if (depth > 5 && !entry_exists) {
if (depth > 4 && !entry_exists) {
depth -= 2; // Internal iterative reductions
}

Expand All @@ -346,14 +346,15 @@ Value __recurse(Board &board, int depth, Value alpha = -VALUE_INFINITE, Value be
bool capt = (board.piece_boards[OPPOCC(board.side)] & square_bits(move.dst()));
bool promo = (move.type() == PROMOTION);

if (depth == 1 && i > 0 && !in_check && !capt && !promo && abs(alpha) < VALUE_MATE_MAX_PLY && abs(beta) < VALUE_MATE_MAX_PLY) {
if (depth <= 2 && i > 0 && !in_check && !capt && !promo && abs(alpha) < VALUE_MATE_MAX_PLY && abs(beta) < VALUE_MATE_MAX_PLY) {
/**
* Futility pruning
*
* If we are at the leaf of the search, we can prune moves that are
* probably not going to be better than alpha.
*/
if (cur_eval + FUTILITY_THRESHOLD < alpha) continue;
if (depth == 1 && cur_eval + FUTILITY_THRESHOLD < alpha) continue;
if (depth == 2 && cur_eval + FUTILITY_THRESHOLD2 < alpha) continue;
}

board.make_move(move);
Expand Down Expand Up @@ -407,14 +408,14 @@ Value __recurse(Board &board, int depth, Value alpha = -VALUE_INFINITE, Value be
killer[0][depth] = move; // Update killer moves
}
if (!(board.piece_boards[OPPOCC(board.side)] & square_bits(move.dst()))) { // Not a capture
const Value bonus = depth * depth;
const Value bonus = 1.53 * depth * depth + 0.87 * depth + 0.65;
update_history(board.side, move.src(), move.dst(), bonus);
for (auto &qmove : quiets) {
update_history(board.side, qmove.src(), qmove.dst(), -bonus); // Penalize quiet moves
}
cmh[board.side][line[ply-1].src()][line[ply-1].dst()] = move; // Update counter-move history
} else {
const Value bonus = depth * depth;
const Value bonus = 1.82 * depth * depth + 0.49 * depth + 0.39;
update_capthist(PieceType(board.mailbox[move.src()] & 7), PieceType(board.mailbox[move.dst()] & 7), move.dst(), bonus);
for (auto &cmove : captures) {
update_capthist(PieceType(board.mailbox[cmove.src()] & 7), PieceType(board.mailbox[cmove.dst()] & 7), cmove.dst(), -bonus);
Expand Down Expand Up @@ -615,7 +616,7 @@ std::pair<Move, Value> search(Board &board, int64_t time, bool quiet) {
}

int time_elapsed = (clock() - start) / CLOCKS_PER_MS;
if (time_elapsed > mxtime / 2) {
if (time_elapsed > mxtime * 0.52) {
// We probably won't be able to complete the next ID loop
break;
}
Expand Down
7 changes: 4 additions & 3 deletions engine/search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
// we can afford to lose RFP_THRESHOLD eval units per ply
// and still be in a better position. The lower the value,
// the more aggressive RFP is.
#define RFP_THRESHOLD (128 * CP_SCALE_FACTOR)
#define RFP_THRESHOLD (131 * CP_SCALE_FACTOR)

// Aspiration window size(s)
// The aspiration window is the range of values we search
// for the best move. If we fail to find the best move in
// this range, we expand the window.
#define ASPIRATION_WINDOW (43 * CP_SCALE_FACTOR)
#define ASPIRATION_WINDOW (36 * CP_SCALE_FACTOR)

// Null-move pruning reduction value
// This is the amount of depth we reduce the search by
Expand All @@ -30,7 +30,8 @@

// Futility pruning threshold
// This is the threshold for futility pruning (in centipawns)
#define FUTILITY_THRESHOLD (300 * CP_SCALE_FACTOR)
#define FUTILITY_THRESHOLD (312 * CP_SCALE_FACTOR)
#define FUTILITY_THRESHOLD2 (678 * CP_SCALE_FACTOR)

extern uint64_t nodes;

Expand Down