Go to the documentation of this file.
4 #ifndef EVAL_ML_MINORPIECE_H
5 #define EVAL_ML_MINORPIECE_H
52 template <Player Owner>
55 assert(Owner == king.
owner());
56 const int king_y = (Owner ==
BLACK ?
58 return std::abs(x - king.
square().
x()) * 9 + king_y - 1;
62 return std::abs(x - king.
x());
64 template <
bool Attack>
67 const int king_x = king.
square().
x();
68 const int target_x = (king_x > 5 ? 10 - king_x : king_x);
69 if (king_x >= 6 || (king.
owner() ==
WHITE && king_x == 5))
71 return (x - 1) * 5 + target_x - 1 + (Attack ? 0 : 45);
75 int attack_index,
int defense_index,
76 int attack_index_y,
int defense_index_y,
77 int attack_index_x,
int defense_index_x)
87 int attack_index,
int defense_index,
88 int attack_index_y,
int defense_index_y,
89 int attack_index_x,
int defense_index_x)
125 const int attack_index =
index(kings[1], moved.
to().
x());
126 const int defense_index =
index(kings[0], moved.
to().
x());
127 const int attack_index_x =
128 indexX<true>(king_piece[1], moved.
to().
x());
129 const int defense_index_x =
130 indexX<false>(king_piece[0], moved.
to().
x());
132 const int attack_index_y = indexY<altP>(king_piece[1], moved.
to().
x());
133 const int defense_index_y = indexY<P>(king_piece[0], moved.
to().
x());
134 const int index_x = (moved.
to().
x() > 5 ? 10 -
135 moved.
to().
x() : moved.
to().
x());
204 result -=
value(attack_index, defense_index, attack_index_y,
205 defense_index_y, attack_index_x, defense_index_x);
208 result -=
standValue(attack_index, defense_index, attack_index_y,
209 defense_index_y, attack_index_x, defense_index_x);
214 result +=
value(attack_index, defense_index, attack_index_y,
215 defense_index_y, attack_index_x, defense_index_x);
218 result +=
standValue(attack_index, defense_index, attack_index_y,
219 defense_index_y, attack_index_x, defense_index_x);
225 const int attack_index =
index(kings[1], moved.
to().
x());
226 const int defense_index =
index(kings[0], moved.
to().
x());
227 const int attack_index_x =
228 indexX<true>(king_piece[1], moved.
to().
x());
229 const int defense_index_x =
230 indexX<false>(king_piece[0], moved.
to().
x());
231 const int attack_index_y = indexY<altP>(king_piece[1], moved.
to().
x());
232 const int defense_index_y = indexY<P>(king_piece[0], moved.
to().
x());
235 result +=
value(attack_index, defense_index, attack_index_y,
236 defense_index_y, attack_index_x, defense_index_x);
239 result +=
standValue(attack_index, defense_index, attack_index_y,
240 defense_index_y, attack_index_x, defense_index_x);
245 result -=
value(attack_index, defense_index, attack_index_y,
246 defense_index_y, attack_index_x, defense_index_x);
249 result -=
standValue(attack_index, defense_index, attack_index_y,
250 defense_index_y, attack_index_x, defense_index_x);
253 const int index_x = (moved.
to().
x() > 5 ? 10 -
254 moved.
to().
x() : moved.
to().
x());
334 const int attack_index =
index(kings[0], moved.
to().
x());
335 const int defense_index =
index(kings[1], moved.
to().
x());
336 const int attack_index_x =
337 indexX<true>(king_piece[0], moved.
to().
x());
338 const int defense_index_x =
339 indexX<false>(king_piece[1], moved.
to().
x());
340 const int attack_index_y = indexY<P>(king_piece[0], moved.
to().
x());
341 const int defense_index_y = indexY<altP>(king_piece[1], moved.
to().
x());
344 result -=
value(attack_index, defense_index, attack_index_y,
345 defense_index_y, attack_index_x, defense_index_x);
348 result -=
standValue(attack_index, defense_index, attack_index_y,
349 defense_index_y, attack_index_x, defense_index_x);
354 result +=
value(attack_index, defense_index, attack_index_y,
355 defense_index_y, attack_index_x, defense_index_x);
358 result +=
standValue(attack_index, defense_index, attack_index_y,
359 defense_index_y, attack_index_x, defense_index_x);
365 (moved.
to().
x() > 5 ? 10 - moved.
to().
x() : moved.
to().
x());
503 return (P ==
BLACK ? (pos.
y() - 1) : (9 - pos.
y()));
520 template <osl::Player P>
547 return (P ==
BLACK ? (pos.
y() - 1) : (9 - pos.
y()));
558 if (!canRetreat<P>(state,silver))
572 std::abs(kings[P].x() - silver.
square().
x());
573 const int y_diff = (P ==
BLACK ?
574 silver.
square().
y() - kings[P].y() :
575 kings[P].y() - silver.
square().
y());
576 result +=
head_table[x_diff + 9 * (y_diff + 8)];
607 return (P ==
BLACK ? (pos.
y() - 1) : (9 - pos.
y()));
611 return (pos.
x() > 5 ? 9 - pos.
x() : pos.
x() - 1);
616 return (P ==
BLACK ? (pos.
y() - 1) : (9 - pos.
y())) + 5;
644 assert(P==gold.
owner());
646 if (!canRetreat<P>(state, gold))
650 if (!canMoveToSide<P>(state, gold))
661 const Square king = kings[P];
662 const int x_diff = std::abs(king.
x() - gold.
square().
x());
663 const int y_diff = (P ==
BLACK ?
704 return (P ==
BLACK ? (pos.
y() - 1) : (9 - pos.
y()));
721 if (black_major_count == 4)
723 else if (black_major_count == 0)
749 const int y = (player ==
BLACK ? pos.
y() : 10 - pos.
y()) - 1;
750 return ptype * 9 + y;
771 const int x = (pos.
x() > 5 ? 10 - pos.
x() : pos.
x()) - 1;
772 return ptype * 5 + x;
783 template <Player Defense>
815 template <Player King>
818 return (King ==
BLACK ? y - 1 : 9 - y) ;
874 const int y_index = (P ==
BLACK ? y - 1 : 9 - y);
875 return index(P, up, up_up) + 1024 * y_index;
893 static void adjust(
int index,
int index_attack,
int index_defense,
900 template <
bool attack, Player owner>
903 const int y = (owner ==
BLACK ? king.
y() : 10 - king.
y());
904 return x_diff + (y - 1) * 9 + (attack ? 0 : 81);
923 static void adjust(
int black_turn_king_attack,
924 int black_turn_king_defense,
925 int white_turn_king_attack,
926 int white_turn_king_defense,
929 static int index(
bool same_turn,
bool has_support,
Ptype ptype)
934 template <
bool Attack>
938 const int x_diff = std::abs(position.
x() - king.
x());
939 const int y_diff = (owner ==
BLACK ?
940 position.
y() - king.
y() :
941 king.
y() - position.
y());
942 return ((ptype + (same_turn ? 0 :
PTYPE_SIZE) +
943 (has_support ? 0 :
PTYPE_SIZE * 2)) * 9 + x_diff) * 17 +
944 y_diff + 8 + (Attack ? 0 : 9792);
946 template <
bool Attack>
950 return indexK<Attack>(king, same_turn, has_support,
955 template <Player Attacked>
960 int moved_piece_number,
967 black_old.
reset(moved_piece_number);
968 while (black_old.
any())
971 const bool has_support =
972 new_mask[Attacked].test(piece.
number());
973 const int index_king_black_turn_attack =
974 indexK<true>(kings[
alt(Attacked)], Attacked ==
BLACK, has_support, piece);
975 const int index_king_white_turn_attack =
976 indexK<true>(kings[
alt(Attacked)], Attacked ==
WHITE, has_support, piece);
977 const int index_king_black_turn_defense =
978 indexK<false>(kings[Attacked], Attacked ==
BLACK, has_support, piece);
979 const int index_king_white_turn_defense =
980 indexK<false>(kings[Attacked], Attacked ==
WHITE, has_support, piece);
982 index_king_black_turn_attack, index_king_black_turn_defense,
983 index_king_white_turn_attack, index_king_white_turn_defense,
989 black_new.
reset(moved_piece_number);
990 while (black_new.
any())
993 const bool has_support =
994 effected_mask[Attacked].test(piece.
number());
995 const int index_king_black_turn_attack =
996 indexK<true>(kings[
alt(Attacked)], Attacked ==
BLACK, has_support, piece);
997 const int index_king_white_turn_attack =
998 indexK<true>(kings[
alt(Attacked)], Attacked ==
WHITE, has_support, piece);
999 const int index_king_black_turn_defense =
1000 indexK<false>(kings[Attacked], Attacked ==
BLACK, has_support, piece);
1001 const int index_king_white_turn_defense =
1002 indexK<false>(kings[Attacked], Attacked ==
WHITE, has_support, piece);
1004 index_king_black_turn_attack, index_king_black_turn_defense,
1005 index_king_white_turn_attack, index_king_white_turn_defense,
1009 PieceMask black_self_old = effected_mask[
alt(Attacked)] & new_mask[
alt(Attacked)] &
1010 effected_mask[Attacked] & (~new_mask[Attacked]) & state.
piecesOnBoard(Attacked);
1011 black_self_old.
reset(moved_piece_number);
1012 while (black_self_old.
any())
1015 const int index_king_black_turn_attack =
1016 indexK<true>(kings[
alt(Attacked)], Attacked ==
BLACK,
false, piece);
1017 const int index_king_white_turn_attack =
1018 indexK<true>(kings[
alt(Attacked)], Attacked ==
WHITE,
false, piece);
1019 const int index_king_black_turn_defense =
1020 indexK<false>(kings[Attacked], Attacked ==
BLACK,
false, piece);
1021 const int index_king_white_turn_defense =
1022 indexK<false>(kings[Attacked], Attacked ==
WHITE,
false, piece);
1023 const int index_king_black_turn_attack_old =
1024 indexK<true>(kings[
alt(Attacked)], Attacked ==
BLACK,
true, piece);
1025 const int index_king_white_turn_attack_old =
1026 indexK<true>(kings[
alt(Attacked)], Attacked ==
WHITE,
true, piece);
1027 const int index_king_black_turn_defense_old =
1028 indexK<false>(kings[Attacked], Attacked ==
BLACK,
true, piece);
1029 const int index_king_white_turn_defense_old =
1030 indexK<false>(kings[Attacked], Attacked ==
WHITE,
true, piece);
1032 index_king_black_turn_attack_old, index_king_black_turn_defense_old,
1033 index_king_white_turn_attack_old, index_king_white_turn_defense_old,
1036 index_king_black_turn_attack, index_king_black_turn_defense,
1037 index_king_white_turn_attack, index_king_white_turn_defense,
1041 PieceMask black_self_new = effected_mask[
alt(Attacked)] & new_mask[
alt(Attacked)] &
1042 (~effected_mask[Attacked]) & new_mask[Attacked] & state.
piecesOnBoard(Attacked);
1043 black_self_new.
reset(moved_piece_number);
1044 while (black_self_new.
any())
1047 const int index_king_black_turn_attack =
1048 indexK<true>(kings[
alt(Attacked)], Attacked ==
BLACK,
true, piece);
1049 const int index_king_white_turn_attack =
1050 indexK<true>(kings[
alt(Attacked)], Attacked ==
WHITE,
true, piece);
1051 const int index_king_black_turn_defense =
1052 indexK<false>(kings[Attacked], Attacked ==
BLACK,
true, piece);
1053 const int index_king_white_turn_defense =
1054 indexK<false>(kings[Attacked], Attacked ==
WHITE,
true, piece);
1055 const int index_king_black_turn_attack_old =
1056 indexK<true>(kings[
alt(Attacked)], Attacked ==
BLACK,
false, piece);
1057 const int index_king_white_turn_attack_old =
1058 indexK<true>(kings[
alt(Attacked)], Attacked ==
WHITE,
false, piece);
1059 const int index_king_black_turn_defense_old =
1060 indexK<false>(kings[Attacked], Attacked ==
BLACK,
false, piece);
1061 const int index_king_white_turn_defense_old =
1062 indexK<false>(kings[Attacked], Attacked ==
WHITE,
false, piece);
1065 index_king_black_turn_attack_old, index_king_black_turn_defense_old,
1066 index_king_white_turn_attack_old, index_king_white_turn_defense_old,
1069 index_king_black_turn_attack, index_king_black_turn_defense,
1070 index_king_white_turn_attack, index_king_white_turn_defense,
1118 return (ptype + (same_turn ? 0 :
PTYPE_SIZE) +
1119 (has_support ? 0 :
PTYPE_SIZE * 2)) * 16 + attack_ptype;
1133 template <
bool Plus>
1136 const Ptype attack_ptype,
1140 const int index_black_turn =
index(
BLACK == player, with_support,
1141 ptype, attack_ptype);
1142 const int index_white_turn =
index(
WHITE == player, with_support,
1143 ptype, attack_ptype);
1145 adjust<1>(index_black_turn, index_white_turn, result);
1147 adjust<-1>(index_black_turn, index_white_turn, result);
1153 int captured_number,
1165 const bool has_support =
1166 new_mask[P].test(piece.
number());
1170 attacked_mask[piece.
number()] = attacking;
1171 while (attacking.
any())
1174 evalOnePiece<P == BLACK>(P, piece.
ptype(), attack.
ptype(),
1175 has_support, result);
1181 while (new_without.
any())
1184 const bool has_support =
1185 effected_mask[P].test(piece.
number());
1189 evalOnePiece<P != BLACK>(P, piece.
ptype(), moved.
oldPtype(),
1190 has_support, result);
1193 if (captured_number != -1 && attacking.
test(captured_number))
1196 has_support, result);
1197 attacking.
reset(captured_number);
1199 while (attacking.
any())
1202 evalOnePiece<P != BLACK>(P, piece.
ptype(), attack.
ptype(),
1203 has_support, result);
1211 while (self_old.
any())
1217 evalOnePiece<P != BLACK>(P, piece.
ptype(), moved.
oldPtype(),
1221 if (captured_number != -1 && old_attacking.
test(captured_number))
1225 old_attacking.
reset(captured_number);
1227 while (old_attacking.
any())
1230 evalOnePiece<P != BLACK>(P, piece.
ptype(), attack.
ptype(),
1235 attacked_mask[piece.
number()] = new_attacking;
1236 while (new_attacking.
any())
1239 evalOnePiece<P == BLACK>(P, piece.
ptype(), attack.
ptype(),
1248 while (self_new_with.
any())
1254 evalOnePiece<P != BLACK>(P, piece.
ptype(), moved.
oldPtype(),
1258 if (captured_number != -1 && old_attacking.
test(captured_number))
1262 old_attacking.
reset(captured_number);
1264 while (old_attacking.
any())
1267 evalOnePiece<P != BLACK>(P, piece.
ptype(), attack.
ptype(),
1272 attacked_mask[piece.
number()] = new_attacking;
1273 while (new_attacking.
any())
1276 evalOnePiece<P == BLACK>(P, piece.
ptype(), attack.
ptype(),
1282 effected ^= new_mask[P];
1283 effected = ~effected;
1289 while (attack_changed.
any())
1294 if (captured_number != -1 &&
1295 attack_old_mask.
test(captured_number))
1297 evalOnePiece<P != BLACK>(P, attacked.
ptype(),
1299 new_mask[P].test(attacked.
number()),
1301 attack_old_mask.
reset(captured_number);
1306 evalOnePiece<P != BLACK>(P, attacked.
ptype(),
1308 new_mask[P].test(attacked.
number()),
1315 evalOnePiece<P == BLACK>(P, attacked.
ptype(),
1317 new_mask[P].test(attacked.
number()),
1321 PieceMask gone = attack_old_mask & (~attack_new_mask);
1325 evalOnePiece<P != BLACK>(P, attacked.
ptype(),
1327 effected_mask[P].test(attacked.
number()),
1330 PieceMask added = (~attack_old_mask) & attack_new_mask;
1334 evalOnePiece<P == BLACK>(P, attacked.
ptype(),
1336 new_mask[P].test(attacked.
number()),
1355 template <Player Owner>
1360 const Ptype attack_ptype
1364 return (piece.
ptype() +
1381 template<osl::Player P,osl::Ptype T>
1396 MultiInt &last_value_and_out,
unsigned int &ptypeo_mask);
1436 count - 1) + 720 + 800;
1476 count - 1) + 720 + 800;
1524 PtypeO ptypeO,
bool attack)
1526 const int y_diff = (p ==
BLACK ? king.
y() - pos.
y() : pos.
y() - king.
y());
1527 const int x_diff = std::abs(king.
x() - pos.
x());
1530 ptypeO =
alt(ptypeO);
1532 return y_diff + 8 + x_diff * 17 + (ptypeO -
PTYPEO_MIN) * 17 * 9 +
1533 (attack ? 0 : 4896);
1553 if (player ==
WHITE)
1556 pawn_y = (10 - pawn_y) % 10;
1558 return pawn_y + 10 * (y - 1 + 9 * ptype);
1572 template <Player Defense>
1575 int king_x = (king.
x() > 5 ? 10 - king.
x() : king.
x());
1576 int king_y = (Defense ==
WHITE ? 10 - king.
y() : king.
y());
1577 return king_x - 1 + 5 * (king_y - 1+ 9 * (distance0 + 3 * count));
1582 template <Player Defense>
1584 int count1,
int count2)
1586 int king_x = (king.
x() > 5 ? 10 - king.
x() : king.
x());
1587 int king_y = (Defense ==
WHITE ? 10 - king.
y() : king.
y());
1588 return king_x + 5 * (king_y + 9 * (
std::min(5,count0) + 6 *
1614 if (P==
BLACK) index=((ptypeo_mask>>19)&0x1fc0)|((ptypeo_mask>>18)&0x3f);
1615 else index=((ptypeo_mask>>3)&0x1fc0)|((ptypeo_mask>>2)&0x3f);
1617 return table[index];
1619 return -
table[index];
1635 CArray<std::pair<Square,int>,2>& silver_drop);
1650 template <Player Defense>
1652 std::pair<Square,int>& bishop_drop,
1653 std::pair<Square,int>& rook_drop);
1655 CArray<std::pair<Square,int>,2>& bishop_drop,
1656 CArray<std::pair<Square,int>,2>& rook_drop);
1664 Square center,
bool maybe_empty=
false);
1675 template <Player Defense>
1679 std::pair<Square,int>& knight_drop);
1682 CArray<std::pair<Square,int>,2>& knight_drop);
1687 CArray<std::pair<Square,int>,2>& knight_drop);
1691 int y,
int x0,
int x1);
1702 template <Player P, Player Defense>
1706 template <osl::Player Defense>
1709 bool has_knight,
const BoardMask& knight_fork_squares,
1710 std::pair<Square,int>& knight_drop);
1741 #endif // EVAL_ML_MINORPIECE_H
static CArray< MultiInt, ONE_DIM > table
static void adjust(int black_turn_king_attack, int black_turn_king_defense, int white_turn_king_attack, int white_turn_king_defense, MultiIntPair &result)
static CArray< MultiInt, 9 > table
static int indexBoardCount(int count)
const Piece pieceAt(Square sq) const
static MultiInt evalOne(unsigned int ptypeo_mask)
static void setUp(const Weights &weights)
const PieceMask & piecesOnBoard(Player p) const
static int indexCount(Ptype ptype, int count)
const Piece findCheapAttack(Player P, Square square) const
static CArray< MultiInt, 153 > knight_table
static void setUp(const Weights &weights)
int min(Player p, int v1, int v2)
static void eval(const NumEffectState &state, MultiIntPair &out)
static void setUp(const Weights &weights)
static MultiInt evalWithUpdate(const NumEffectState &, Move moved, MultiInt const &last_value)
static int index(const Player, const Ptype ptype, const Square pos)
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
static int index2(int i0, int i1)
const BoardTable Board_Table
static CArray< MultiInt, 9 > table
static void setUp(const Weights &weights)
static MultiIntPair evalWithUpdate(const NumEffectState &state, Move moved, CArray< BoardMask, 2 > &knight_fork_squares, CArray< std::pair< Square, int >, 2 > &knight_drop)
static MultiIntPair evalOne(const NumEffectState &state, const PieceVector &target, std::pair< Square, int > &bishop_drop, std::pair< Square, int > &rook_drop)
static bool cantAdvance(const NumEffectState &state, const Piece pawn)
static void setUp(const Weights &weights)
constexpr Player alt(Player player)
static void evalWithUpdateBang(const NumEffectState &state, Move last_move, CArray2d< int, 2, PTYPE_SIZE > &ptype_count, CArray2d< int, 2, PTYPE_SIZE > &ptype_board_count, MultiInt &last_value_and_out, unsigned int &ptypeo_mask)
static bool canRetreat(const NumEffectState &state, const Piece silver)
static int indexSideY(Square pos)
static void setUp(const Weights &weights)
static int indexRetreat(Square pos)
const PieceMask effectedChanged(Player pl) const
前の指手でeffectedMask(pl)が変化したか.
const NumBitmapEffect effectSetAt(Square sq) const
static CArray< MultiInt, 9 > y_table
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
Ptype getPtype(PtypeO ptypeO)
static MultiInt eval(const NumEffectState &state, const CArray2d< int, 2, 9 > &pawns)
static CArray< MultiInt, 2240 > xy_attack_table_diff
PtypeO altIfPiece(PtypeO ptypeO)
Pieceの時にはowner を反転する
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights, int stage)
static CArray< MultiInt, 8192 > table
static CArray< MultiInt, 36 > state_king_relative_table
static void evalOnePiece(const Player player, const Ptype ptype, const Ptype attack_ptype, bool with_support, MultiIntPair &result)
static MultiInt eval(const NumEffectState &state)
static int indexRetreat(Square pos)
static MultiInt value(int index_y)
static CArray< MultiInt, 144 > opp_table
static CArray< MultiInt, 81 > defense_y_table
static CArray< MultiInt, 10 > drop_non_drop_table
static bool canMoveToSide(const NumEffectState &state, const Piece gold)
static CArray< MultiInt, 64 > table
static CArray< MultiInt, 144 > table
static void evalWithUpdateBang(const NumEffectState &state, Move moved, const CArray< PieceMask, 2 > &effected_mask, MultiIntPair &last_value_and_out)
static int indexX(const Piece king, int x)
static CArray< MultiInt, 9 > retreat_table
static MultiInt evalOne(const NumEffectState &state, const CArray2d< int, 2, 3 > &gs_count)
Player getOwner(PtypeO ptypeO)
static MultiInt eval(unsigned int ptypeo_mask)
static int indexCombination(const Square king, int count0, int count1, int count2)
static void setUp(const Weights &weights)
static bool cantAdvance(const NumEffectState &state, const PtypeO ptypeO, const Square position)
static int indexY(Player P, PtypeO up, PtypeO up_up, int y)
static int indexCountX(Ptype ptype, int count, int x)
static CArray< MultiInt, 80 > table
static void setUp(const Weights &weights, int stage)
static MultiInt eval(const NumEffectState &state)
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
const PtypeTable Ptype_Table
static int indexCountY(Ptype ptype, int count, int y)
static CArray< MultiInt, 1215 > table
static MultiInt eval(const NumEffectState &state)
static int indexBoardCountY(int count, int y)
static void setUp(const Weights &weights)
static MultiIntPair eval(const NumEffectState &state, CArray< std::pair< Square, int >, 2 > &bishop_drop, CArray< std::pair< Square, int >, 2 > &rook_drop)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const CArray2d< int, 2, 9 > &pawns, const MultiInt &last_value)
static MultiInt evalOne(const NumEffectState &state, const Piece gold, const CArray< Square, 2 > &kings)
const Piece pieceOf(int num) const
static void setUp(const Weights &weights)
static MultiInt eval(const NumEffectState &state, int black_pawn_count)
static void setUp(const Weights &weights)
static CArray< MultiInt, 9 > defense_table
static MultiInt eval(int black_major_count)
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
static bool isTarget(Ptype ptype)
static void setUp(const Weights &weights)
static void eval(const NumEffectState &state, const CArray2d< int, 2, PTYPE_SIZE > &ptype_count, const CArray2d< int, 2, PTYPE_SIZE > &ptype_board_count, MultiInt &out)
static void setUp(const Weights &weights)
static MultiInt eval(const NumEffectState &state)
static int index1(const NumEffectState &state, Piece piece)
static CArray< MultiInt, 18 > stand_table
static MultiInt eval(const NumEffectState &state)
static int index(Player P, PtypeO up, PtypeO up_up)
static CArray< MultiInt, ONE_DIM > table
static int rookIndex(Ptype a, Ptype b)
bool hasEffectByPtypeStrict(Player attack, Square target) const
target に ptype の利きがあるか? 成不成を区別
int getIndexMin(Ptype ptype) const
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
Ptype capturePtype() const
static int indexSideX(Square pos)
static MultiInt eval(const NumEffectState &state)
static MultiInt valueBoardAll(Ptype ptype, int count, int my_king_x, int my_king_y, int op_king_x, int op_king_y)
static void setUp(const Weights &weights)
static CArray< MultiInt, 9 > attack_table
static int index(const Square king, int x)
static MultiInt evalPlayerPtype(const CArray2d< int, 2, PTYPE_SIZE > &ptype_count, const CArray2d< int, 2, PTYPE_SIZE > &ptype_board_count, const osl::CArray< int, 2 > &kings_x, const osl::CArray< int, 2 > &kings_y)
static void setUp(const Weights &weights)
static int index(Ptype a, Ptype b)
static void setUp(const Weights &weights, int stage)
static MultiInt value(int attack_index, int defense_index, int attack_index_y, int defense_index_y, int attack_index_x, int defense_index_x)
static void setUp(const Weights &weights)
static MultiInt eval(const NumEffectState &state)
static int indexBoardCountX(Ptype ptype, int count, int x)
static int index(const Piece piece)
static CArray< MultiInt, 2240 > xy_table
static void evalWithUpdateBang(const NumEffectState &state, Move moved, const CArray< PieceMask, 2 > &effected_mask, CArray< PieceMask, 40 > &attacked_mask, MultiIntPair &last_value_and_out)
static CArray< MultiInt, 1024 > table
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
static CArray< MultiInt, 153 > head_table
static MultiInt evalOne(const NumEffectState &state)
static int indexBoardCount(Ptype ptype, int count)
static CArray< MultiInt, 160 > table
static MultiInt evalOne(const NumEffectState &state, const Piece silver, const CArray< Square, 2 > &kings)
static void adjust(int index, MultiInt &values)
static MultiInt eval(const NumEffectState &state)
static int index(Player player, Ptype ptype, int y, int pawn_y)
static void setUp(const Weights &weights)
static MultiIntPair eval(const NumEffectState &state, CArray< std::pair< Square, int >, 2 > &silver_drop)
static CArray< MultiInt, 9792 > table
static MultiInt valueAll(Ptype ptype, int count, int my_king_x, int my_king_y, int op_king_x, int op_king_y)
static MultiInt eval(const NumEffectState &state)
static std::pair< int, int > matchGold(const NumEffectState &state, Piece gold, const CArray< bool, 2 > &has_silver, Square &silver_drop)
bool hasPieceOnStand(Player player, Ptype ptype) const
static void setUp(const Weights &weights)
int x() const
将棋としてのX座標を返す.
static CArray< MultiInt, 14 > side_table
static void setUp(const Weights &weights)
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
static const Square findDropInLine(const NumEffectState &state, Player defense, const Square a, const Square b, Piece king)
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
constexpr int playerToIndex(Player player)
static bool testCenter(const NumEffectState &state, Player defense, const Square a, const Square b, Piece king, Square center, bool maybe_empty=false)
const Square nextSquare(Player P, Square pos, Direction dr) const
next position from pos for player P.
static MultiInt standValue(int attack_index, int defense_index, int attack_index_y, int defense_index_y, int attack_index_x, int defense_index_x)
static CArray< MultiInt, 90 > x_table
static int indexY(const Piece king, int x)
static int bishopIndex(Ptype a, Ptype b)
const Square neighbor() const
static CArray< MultiInt, ONE_DIM > table
Square kingSquare() const
static int indexCount(int count)
static void setUp(const Weights &weights)
int y() const
将棋としてのY座標を返す.
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
static int index(bool same_turn, bool has_support, Ptype ptype)
static int index(Player P, Square pos)
static MultiInt eval(const NumEffectState &state)
const Square square() const
static int indexCountY(int count, int y)
static int index(Player P, Square pos)
static void setUp(const Weights &weights, int stage)
static int index(const Player player, const Ptype ptype, const Square pos)
static CArray< MultiInt, 162 > y_stand_table
static bool canCheck(const NumEffectState &state)
static MultiIntPair eval(const NumEffectState &state, CArray< BoardMask, 2 > &knight_fork_squares, CArray< std::pair< Square, int >, 2 > &knight_drop)
static CArray< MultiInt, 2240 > xy_attack_table
static int indexK(Square king, bool same_turn, bool has_support, Square position, Player owner, Ptype ptype)
static int indexK(Square king, bool same_turn, bool has_support, Piece piece)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static void updateSquares(const NumEffectState &state, Move moved, BoardMask &knight_fork_squares)
const Piece kingPiece() const
static void evalWithUpdateBang(const NumEffectState &state, Move moved, const CArray2d< int, 2, 9 > &pawns, MultiInt &last_value)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, MultiInt &last_value)
static CArray< MultiInt, 19584 > king_table
static std::pair< int, int > matchRook(const NumEffectState &state, Piece rook, const CArray< bool, 2 > &has_silver, Square &silver_drop)
static CArray< MultiInt, 9 > retreat_table
static void updateChanged(const NumEffectState &state, const Piece p, Move moved, int captured_number, const CArray< PieceMask, 2 > &effected_mask, const CArray< PieceMask, 2 > &new_mask, CArray< PieceMask, 40 > &attacked_mask, MultiIntPair &result)
static void adjust(int black, int white, MultiIntPair &result)
static CArray< MultiInt, 90 > x_stand_table
static MultiIntPair accumulate(const NumEffectState &state, bool has_knight, const BoardMask &knight_fork_squares, std::pair< Square, int > &knight_drop)
static MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 9216 > y_table
static CArray< MultiInt, 9720 > combination_table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static int indexBoardCountY(Ptype ptype, int count, int y)
static CArray< MultiInt, 9 > table
static int index(const Piece piece)
static CArray< MultiInt, ONE_DIM > table
static void eval(const NumEffectState &state, CArray< PieceMask, 40 > &attacked_mask, MultiIntPair &out)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights, int stage)
static bool canRetreat(const NumEffectState &state, const Piece gold)
static MultiInt eval(const NumEffectState &state)
static bool isForkSquare(const NumEffectState &state, Player defense, int y, int x0, int x1)
static MultiInt eval(const NumEffectState &state, const CArray2d< int, 2, 3 > &gs_count)
static void evalWithUpdateBang(const NumEffectState &state, Move moved, MultiInt &last_value)
static CArray< MultiInt, 81 > attack_y_table
static int indexBoardCountX(int count, int x)
static MultiIntPair evalOne(const NumEffectState &state, bool has_knight, BoardMask &knight_fork_squares, std::pair< Square, int > &knight_drop)
static int indexCountX(int count, int x)
static void setUp(const Weights &weights)
bool isPawnMaskSet(Player player, int x) const
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
static int index(bool same_turn, bool has_support, Ptype ptype, Ptype attack_ptype)
static bool cantAdvance(const NumEffectState &state, const Piece knight)
static CArray< MultiInt, 1024 > table
static const Square isBishopForkSquare(const NumEffectState &state, Player defense, const Square a, const Square b, bool maybe_empty=false)
static CArray< MultiInt, 2240 > xy_table_diff
static void updateEffectChanged(const NumEffectState &state, const CArray< PieceMask, 2 > &effected_mask, const CArray< PieceMask, 2 > &new_mask, int moved_piece_number, MultiIntPair &result)
static CArray< MultiInt, 1440 > table
static int index(const Square king, int distance0, int count)
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
static void setUp(const Weights &weights)
static int index(Player p, Square pos, Square king, PtypeO ptypeO, bool attack)
static MultiInt eval(const NumEffectState &state)
static MultiInt evalWithUpdate(const NumEffectState &, Move moved, MultiInt const &last_value)
static const Square isRookForkSquare(const NumEffectState &state, Player defense, const Square a, const Square b)