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 *
1589 (std::min(5,count1) + 6 * std::min(5,count2))));
1608 static MultiInt eval(
unsigned int ptypeo_mask);
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);
const Square nextSquare(Player P, Square pos, Direction dr) const
next position from pos for player P.
Ptype capturePtype() const
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
const NumBitmapEffect effectSetAt(Square sq) const
const PieceMask effectedChanged(Player pl) const
前の指手でeffectedMask(pl)が変化したか.
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
const Piece findCheapAttack(Player P, Square square) const
const PieceMask & piecesOnBoard(Player p) const
bool hasEffectByPtypeStrict(Player attack, Square target) const
target に ptype の利きがあるか? 成不成を区別
const Square square() const
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
int getIndexMin(Ptype ptype) const
bool hasPieceOnStand(Player player, Ptype ptype) const
const Piece kingPiece() const
const Piece pieceOf(int num) const
Square kingSquare() const
bool isPawnMaskSet(Player player, int x) const
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
const Piece pieceAt(Square sq) const
int y() const
将棋としてのY座標を返す.
const Square neighbor() const
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
int x() const
将棋としてのX座標を返す.
static MultiInt eval(int black_major_count)
static void setUp(const Weights &weights, int stage)
static const Square isRookForkSquare(const NumEffectState &state, Player defense, const Square a, const Square b)
static int bishopIndex(Ptype a, Ptype b)
static int rookIndex(Ptype a, Ptype b)
static MultiIntPair eval(const NumEffectState &state, CArray< std::pair< Square, int >, 2 > &bishop_drop, CArray< std::pair< Square, int >, 2 > &rook_drop)
static MultiIntPair evalOne(const NumEffectState &state, const PieceVector &target, std::pair< Square, int > &bishop_drop, std::pair< Square, int > &rook_drop)
static bool testCenter(const NumEffectState &state, Player defense, const Square a, const Square b, Piece king, Square center, bool maybe_empty=false)
static void setUp(const Weights &weights)
static const Square isBishopForkSquare(const NumEffectState &state, Player defense, const Square a, const Square b, bool maybe_empty=false)
static const Square findDropInLine(const NumEffectState &state, Player defense, const Square a, const Square b, Piece king)
static CArray< MultiInt, ONE_DIM > table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static int index(const Square king, int distance0, int count)
static CArray< MultiInt, 9720 > combination_table
static CArray< MultiInt, 1215 > table
static MultiInt evalOne(const NumEffectState &state, const CArray2d< int, 2, 3 > &gs_count)
static int indexCombination(const Square king, int count0, int count1, int count2)
static int indexSideX(Square pos)
static CArray< MultiInt, 14 > side_table
static MultiInt evalOne(const NumEffectState &state, const Piece gold, const CArray< Square, 2 > &kings)
static MultiInt eval(const NumEffectState &state)
static int indexRetreat(Square pos)
static CArray< MultiInt, 153 > knight_table
static bool canMoveToSide(const NumEffectState &state, const Piece gold)
static int indexSideY(Square pos)
static bool canRetreat(const NumEffectState &state, const Piece gold)
static CArray< MultiInt, 9 > retreat_table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static bool cantAdvance(const NumEffectState &state, const Piece knight)
static CArray< MultiInt, 9 > table
static int index(Player P, Square pos)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static bool canCheck(const NumEffectState &state)
static CArray< MultiInt, 9 > y_table
static MultiInt value(int index_y)
static bool isForkSquare(const NumEffectState &state, Player defense, int y, int x0, int x1)
static CArray< MultiInt, ONE_DIM > table
static MultiIntPair eval(const NumEffectState &state, CArray< BoardMask, 2 > &knight_fork_squares, CArray< std::pair< Square, int >, 2 > &knight_drop)
static MultiIntPair evalWithUpdate(const NumEffectState &state, Move moved, CArray< BoardMask, 2 > &knight_fork_squares, CArray< std::pair< Square, int >, 2 > &knight_drop)
static void updateSquares(const NumEffectState &state, Move moved, BoardMask &knight_fork_squares)
static MultiIntPair evalOne(const NumEffectState &state, bool has_knight, BoardMask &knight_fork_squares, std::pair< Square, int > &knight_drop)
static int index(Ptype a, Ptype b)
static MultiIntPair accumulate(const NumEffectState &state, bool has_knight, const BoardMask &knight_fork_squares, std::pair< Square, int > &knight_drop)
static void setUp(const Weights &weights)
static bool isTarget(Ptype ptype)
static void setUp(const Weights &weights)
static CArray< MultiInt, 144 > opp_table
static CArray< MultiInt, 9 > table
static void setUp(const Weights &weights)
static int index(Player p, Square pos, Square king, PtypeO ptypeO, bool attack)
static void setUp(const Weights &weights)
static CArray< MultiInt, 9792 > table
static void setUp(const Weights &weights, int stage)
static MultiInt eval(const NumEffectState &state, int black_pawn_count)
static void setUp(const Weights &weights)
static int index2(int i0, int i1)
static CArray< MultiInt, ONE_DIM > table
static int index1(const NumEffectState &state, Piece piece)
static void setUp(const Weights &weights)
static MultiInt eval(const NumEffectState &state)
static MultiInt evalOne(const NumEffectState &state)
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 void evalOnePiece(const Player player, const Ptype ptype, const Ptype attack_ptype, bool with_support, MultiIntPair &result)
static CArray< MultiInt, 1024 > 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 setUp(const Weights &weights)
static int index(bool same_turn, bool has_support, Ptype ptype, Ptype attack_ptype)
static void adjust(int black, int white, MultiIntPair &result)
static CArray< MultiInt, 19584 > king_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 int indexK(Square king, bool same_turn, bool has_support, Square position, Player owner, Ptype ptype)
static CArray< MultiInt, 64 > table
static int index(bool same_turn, bool has_support, Ptype ptype)
static void setUp(const Weights &weights)
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 int indexK(Square king, bool same_turn, bool has_support, Piece piece)
static void evalWithUpdateBang(const NumEffectState &state, Move moved, const CArray< PieceMask, 2 > &effected_mask, MultiIntPair &last_value_and_out)
static MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 9 > table
static void setUp(const Weights &weights, int stage)
static int indexY(const Piece king, int x)
static CArray< MultiInt, 81 > defense_y_table
static int index(const Square king, int x)
static CArray< MultiInt, 90 > x_stand_table
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, MultiInt &last_value)
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 CArray< MultiInt, 90 > x_table
static CArray< MultiInt, 162 > y_stand_table
static CArray< MultiInt, 81 > attack_y_table
static CArray< MultiInt, 9 > attack_table
static CArray< MultiInt, 36 > state_king_relative_table
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 MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 10 > drop_non_drop_table
static CArray< MultiInt, 9 > defense_table
static CArray< MultiInt, 18 > stand_table
static int indexX(const Piece king, int x)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights)
static int index(Player P, PtypeO up, PtypeO up_up)
static int indexY(Player P, PtypeO up, PtypeO up_up, int y)
static void setUp(const Weights &weights)
static CArray< MultiInt, 9216 > y_table
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const CArray2d< int, 2, 9 > &pawns, const MultiInt &last_value)
static CArray< MultiInt, 1024 > table
static void setUp(const Weights &weights)
static MultiInt evalOne(unsigned int ptypeo_mask)
static void setUp(const Weights &weights)
static CArray< MultiInt, 8192 > table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static int indexCountX(Ptype ptype, int count, int x)
static int indexBoardCountX(Ptype ptype, int count, int x)
static CArray< MultiInt, 2240 > xy_attack_table
static int indexBoardCount(int count)
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 CArray< MultiInt, 2240 > xy_table_diff
static int indexCountY(int count, int y)
static MultiInt valueBoardAll(Ptype ptype, int count, int my_king_x, int my_king_y, int op_king_x, int op_king_y)
static int indexBoardCountY(Ptype ptype, int count, int y)
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 int indexCountX(int count, int x)
static int indexCount(Ptype ptype, int count)
static CArray< MultiInt, 160 > table
static int indexCount(int count)
static int indexCountY(Ptype ptype, int count, int y)
static int indexBoardCount(Ptype ptype, int count)
static CArray< MultiInt, 2240 > xy_table
static int indexBoardCountY(int count, int y)
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 MultiInt valueAll(Ptype ptype, int count, int my_king_x, int my_king_y, int op_king_x, int op_king_y)
static int indexBoardCountX(int count, int x)
static CArray< MultiInt, 2240 > xy_attack_table_diff
static int index(const Piece piece)
static MultiInt evalWithUpdate(const NumEffectState &, Move moved, MultiInt const &last_value)
static void setUp(const Weights &weights, int stage)
static int index(const Player, const Ptype ptype, const Square pos)
static CArray< MultiInt, 80 > table
static void setUp(const Weights &weights)
static void evalWithUpdateBang(const NumEffectState &state, Move moved, const CArray2d< int, 2, 9 > &pawns, MultiInt &last_value)
static int index(Player player, Ptype ptype, int y, int pawn_y)
static CArray< MultiInt, 1440 > table
static void setUp(const Weights &weights, int stage)
static int index(const Piece piece)
static MultiInt evalWithUpdate(const NumEffectState &, Move moved, MultiInt const &last_value)
static CArray< MultiInt, 144 > table
static int index(const Player player, const Ptype ptype, const Square pos)
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
static MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 9 > retreat_table
static CArray< MultiInt, 153 > head_table
static int indexRetreat(Square pos)
static MultiInt evalOne(const NumEffectState &state, const Piece silver, const CArray< Square, 2 > &kings)
static bool canRetreat(const NumEffectState &state, const Piece silver)
static std::pair< int, int > matchGold(const NumEffectState &state, Piece gold, const CArray< bool, 2 > &has_silver, Square &silver_drop)
static std::pair< int, int > matchRook(const NumEffectState &state, Piece rook, const CArray< bool, 2 > &has_silver, Square &silver_drop)
static CArray< MultiInt, ONE_DIM > table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
const PtypeTable Ptype_Table
Ptype getPtype(PtypeO ptypeO)
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
constexpr int playerToIndex(Player player)
const BoardTable Board_Table
Player getOwner(PtypeO ptypeO)
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
constexpr Player alt(Player player)
PtypeO altIfPiece(PtypeO ptypeO)
Pieceの時にはowner を反転する
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
static void evalWithUpdateBang(const NumEffectState &state, Move moved, MultiInt &last_value)
static void adjust(int index, MultiInt &values)
static bool cantAdvance(const NumEffectState &state, const Piece pawn)
static int index(Player P, Square pos)
static bool cantAdvance(const NumEffectState &state, const PtypeO ptypeO, const Square position)