61 for (
auto& row : scores)
72 for (
auto& row : scores)
73 std::ranges::transform(row, row.begin(), [](
const std::int16_t score) {
74 return static_cast<std::int16_t>(score / 2);
92 const bool prevMoverIsWhite,
const Move prevMove,
93 const bool moverIsWhite,
const Move move,
94 const int bonus)
noexcept
96 if (prevMove.is_null())
100 scores[piece_to_index(prevMoverIsWhite, prevMove)][piece_to_index(moverIsWhite, move)],
108 const bool prevMoverIsWhite,
const Move prevMove,
109 const bool moverIsWhite,
const Move move)
const noexcept ->
int
111 if (prevMove.is_null())
114 return scores[piece_to_index(prevMoverIsWhite, prevMove)][piece_to_index(moverIsWhite, move)];
118 static constexpr auto NUM_PIECE_TYPES { 6uz };
121 static constexpr auto NUM_PIECE_TO { 2uz * NUM_PIECE_TYPES * 64uz };
125 [[nodiscard]]
static constexpr auto piece_to_index(
const bool isWhite,
const Move move)
noexcept ->
size_t
127 const auto coloredPiece = (isWhite ? 0uz : NUM_PIECE_TYPES)
128 +
static_cast<size_t>(std::to_underlying(move.piece()));
130 return (coloredPiece * 64uz) +
static_cast<size_t>(move.to().index());
133 using Row = std::array<std::int16_t, NUM_PIECE_TO>;
135 std::array<Row, NUM_PIECE_TO> scores { };
auto get(const bool prevMoverIsWhite, const Move prevMove, const bool moverIsWhite, const Move move) const noexcept -> int
void update(const bool prevMoverIsWhite, const Move prevMove, const bool moverIsWhite, const Move move, const int bonus) noexcept
static constexpr auto MAX_SCORE