Skip to content

Commit

Permalink
add asserts, move to types.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonlinear2 committed Nov 22, 2024
1 parent bb2bfdb commit d811f1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class TranspositionTable;
class ThreadPool;
class OptionsMap;

constexpr bool is_win(Value value) { return value >= VALUE_TB_WIN_IN_MAX_PLY; };
constexpr bool is_loss(Value value) { return value <= VALUE_TB_LOSS_IN_MAX_PLY; }
constexpr bool is_win_or_loss(Value value) { return is_win(value) || is_loss(value); }

namespace Search {

// Stack struct keeps track of the information we need to remember from nodes
Expand Down
13 changes: 13 additions & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ constexpr Value VALUE_TB = VALUE_MATE_IN_MAX_PLY - 1;
constexpr Value VALUE_TB_WIN_IN_MAX_PLY = VALUE_TB - MAX_PLY;
constexpr Value VALUE_TB_LOSS_IN_MAX_PLY = -VALUE_TB_WIN_IN_MAX_PLY;


constexpr bool is_win(Value value) {
assert(value <= VALUE_MATE);
return value >= VALUE_TB_WIN_IN_MAX_PLY;
}

constexpr bool is_loss(Value value) {
assert(value >= -VALUE_MATE);
return value <= VALUE_TB_LOSS_IN_MAX_PLY;
}

constexpr bool is_win_or_loss(Value value) { return is_win(value) || is_loss(value); }

// In the code, we make the assumption that these values
// are such that non_pawn_material() can be used to uniquely
// identify the material on the board.
Expand Down

0 comments on commit d811f1c

Please sign in to comment.