Skip to content

Commit

Permalink
Weak nodes
Browse files Browse the repository at this point in the history
Bench: 1972379
  • Loading branch information
SzilBalazs committed Aug 10, 2023
1 parent cc9902b commit ac74a81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/chess/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ enum Color {
enum NodeType {
ROOT_NODE,
PV_NODE,
NON_PV_NODE
NON_PV_NODE,
WEAK_NODE
};

constexpr PieceType PIECE_TYPES_BY_VALUE[6] = {PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING};
Expand Down
6 changes: 4 additions & 2 deletions src/search/search_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,9 @@ namespace search {
Score search(Depth depth, Score alpha, Score beta, SearchStack *ss) {
constexpr bool root_node = node_type == ROOT_NODE;
constexpr bool non_root_node = !root_node;
constexpr bool pv_node = node_type != NON_PV_NODE;
constexpr bool pv_node = node_type == ROOT_NODE || node_type == PV_NODE;
constexpr bool non_pv_node = !pv_node;
constexpr bool weak_node = node_type == WEAK_NODE;

const chess::Move last_move = ss->ply >= 1 ? (ss - 1)->move : chess::NULL_MOVE;
const Score mate_ply = -MATE_VALUE + ss->ply;
Expand Down Expand Up @@ -376,9 +377,10 @@ namespace search {

R -= pv_node;
R += !improving;
R += weak_node;

Depth D = std::clamp(depth - R, 1, depth - 1);
score = -search<NON_PV_NODE>(D, -alpha - 1, -alpha, ss + 1);
score = -search<WEAK_NODE>(D, -alpha - 1, -alpha, ss + 1);

if (score > alpha && R > 0) {
score = -search<NON_PV_NODE>(depth - 1, -alpha - 1, -alpha, ss + 1);
Expand Down

0 comments on commit ac74a81

Please sign in to comment.