14 for (
size_t i = 0; i < weights.
dimension(); ++i)
16 table[i] = weights.
value(i);
25 while (black_mask.
any())
28 value += table[piece.
ptype()];
30 while (white_mask.
any())
33 value -= table[piece.
ptype()];
45 for (
int y = 0; y <= 16; ++y)
47 for (
int x = 0; x <= 8; ++x)
49 const int distance = x * 17 + y;
50 table[i][distance][stage] =
64 while (black_mask.
any())
67 value += table[piece.
ptype()][index(black_king, piece)];
69 while (white_mask.
any())
72 value -= table[piece.
ptype()][index(white_king, piece)];
87 for (
size_t i = 0; i < ONE_DIM; ++i)
90 table[i][s] = weights.
value(i + ONE_DIM*s);
97 for (
size_t i = 0; i < ONE_DIM; ++i)
100 distance_table[i][s] = weights.
value(i + ONE_DIM*s);
107 for (
size_t i = 0; i < ONE_DIM; ++i)
110 pawn_table[i][s] = weights.
value(i + ONE_DIM*s);
114template <osl::Player Defense>
121 while (pin_mask.any())
123 const Piece piece = state.
pieceOf(pin_mask.takeOneBit());
130 std::abs(king.
x() - piece.
square().
x()) - 1] +
132 if (pawnAttack<Defense>(state, piece))
137 else if (king.
x() == piece.
square().
x())
144 std::abs(king.
y() - piece.
square().
y()) - 1] +
151 std::abs(king.
y() - piece.
square().
y()) - 1] +
162 std::abs(king.
x() - piece.
square().
x()) - 1] +
164 if (pawnAttack<Defense>(state, piece))
173 std::abs(king.
x() - piece.
square().
x()) - 1] +
175 if (pawnAttack<Defense>(state, piece))
188 return evalOne<BLACK>(state) - evalOne<WHITE>(state);
198 for (
size_t i = 0; i < ONE_DIM; ++i)
201 table[i][s] = weights.
value(i + ONE_DIM*s);
205template <osl::Player Defense>
212 while (open_mask.any())
214 const Piece piece = state.
pieceOf(open_mask.takeOneBit());
219 else if (king.
x() == piece.
square().
x())
250 return evalOne<BLACK>(state) - evalOne<WHITE>(state);
void fill(const T_simple &value=T_simple())
const PieceMask checkShadow(Player attack) const
attack の駒で動くと開き王手になる可能性がある集合
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
const PieceMask pin(Player king) const
bool hasEffectByPtypeStrict(Player attack, Square target) const
target に ptype の利きがあるか? 成不成を区別
const Square square() const
const Piece pieceOf(int num) const
Square kingSquare() const
int y() const
将棋としてのY座標を返す.
int x() const
将棋としてのX座標を返す.
static MultiInt evalOne(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
static CArray< MultiInt, 48 > pawn_table
static CArray< MultiInt, 560 > distance_table
static CArray< MultiInt, 80 > table
static MultiInt eval(const NumEffectState &state)
static MultiInt evalOne(const NumEffectState &state)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray2d< MultiInt, PTYPE_SIZE, 17 *9 > table
static MultiInt eval(const NumEffectState &state, PieceMask black_mask, PieceMask white_mask)
static void setUp(const Weights &weights, int stage)
static CArray< int, PTYPE_SIZE > table
int eval(const NumEffectState &state, PieceMask black_mask, PieceMask white_mask) const
static void setUp(const Weights &weights)
constexpr Player alt(Player player)
int value(size_t index) const