12 for (
int y = 0; y <= 16; ++y)
14 for (
int x = 0; x <= 8; ++x)
16 const int distance = x * 17 + y;
41 const int attack_index =
index(state,
BLACK,position, w_king);
42 const int defense_index =
index(state,
BLACK,position, b_king);
48 const int attack_index =
index(state,
WHITE,position, b_king);
49 const int defense_index =
index(state,
WHITE,position, w_king);
57template<osl::Player P>
74 const int attack_index =
index(state, ptypeO, moved.
from(),
false);
75 const int defense_index =
index(state,ptypeO, moved.
from(),
true);
88 const int attack_index =
index(state, moved.
ptypeO(), moved.
to(),
false);
89 const int defense_index =
index(state, moved.
ptypeO(), moved.
to(),
true);
105 const int attack_index =
index(state, ptypeO, moved.
to(),
false);
106 const int defense_index =
index(state,ptypeO, moved.
to(),
true);
128 for (
int i = 0; i <
ONE_DIM; ++i)
135template <
int Sign>
inline
162 adjust<1>(index_attack, index_defense, result);
173 adjust<-1>(index_attack, index_defense, result);
204 const int index_attack =
207 const int index_defense =
211 adjust<-1>(index_attack, index_defense, result);
213 adjust<1>(index_attack, index_defense, result);
220 effected_mask[moved.
player()] & (~state.piecesOnBoard(
BLACK)) &
221 (~state.piecesOnBoard(
WHITE));
225 const int index_attack =
228 const int index_defense =
232 adjust<1>(index_attack, index_defense, result);
234 adjust<-1>(index_attack, index_defense, result);
239 const int index_attack =
242 const int index_defense =
246 adjust<1>(index_attack, index_defense, result);
248 adjust<-1>(index_attack, index_defense, result);
253 PieceMask black_old = (~effected_mask[0]) & new_mask[0] & onboard_black;
255 while (black_old.
any())
258 const int index_attack =
260 const int index_defense =
262 adjust<-1>(index_attack, index_defense, result);
265 PieceMask black_new = effected_mask[0] & (~new_mask[0]) & onboard_black;
267 while (black_new.
any())
270 const int index_attack =
272 const int index_defense =
274 adjust<1>(index_attack, index_defense, result);
280 PieceMask white_old = (~effected_mask[1]) & new_mask[1] & onboard_white;
282 while (white_old.
any())
285 const int index_attack =
287 const int index_defense =
289 adjust<1>(index_attack, index_defense, result);
292 PieceMask white_new = effected_mask[1] & (~new_mask[1]) & onboard_white;
294 while (white_new.
any())
297 const int index_attack =
299 const int index_defense =
301 adjust<-1>(index_attack, index_defense, result);
312 for (
int i = 0; i <
ONE_DIM; ++i)
345 adjust<1>(black_index, white_index, result);
367 adjust<-1>(index_black, index_white, result);
377 adjust<-1>(index_black, index_white, result);
385 adjust<1>(index_black, index_white, result);
398 for (
size_t i = 0; i < weights.
dimension(); ++i)
411 const int min_x = std::max(1, king.
x() - 2);
412 const int max_x = std::min(9, king.
x() + 2);
413 const int min_y = std::max(1, king.
y() - 2);
414 const int max_y = std::min(9, king.
y() + 2);
418 for (
int y = min_y; y <= max_y; ++y)
420 for (
int x = min_x; x <= max_x; ++x)
422 const Square target(x, y);
427 effect = std::min(255, count);
429 piece = std::min(16, mask.
countBit());
434 return effect + 128 * piece_count;
440 int black_effect, black_piece, white_effect, white_piece;
454 for (
int i = 0; i <
ONE_DIM; ++i)
463 for (
int i = 0; i <
ONE_DIM; ++i)
478 for (
int i = 0; i <
ONE_DIM; ++i)
487 for (
int i = 0; i < ONE_DIM; ++i)
505 for (
size_t i = 0; i <
DIM/2; ++i)
512template <osl::Player Attack>
522 int &attack_piece_supported,
529 const int min_x = std::max(1, king.
x() - 2);
530 const int max_x = std::min(9, king.
x() + 2);
531 const int min_y = std::max(1, king.
y() - 2);
532 const int max_y = std::min(9, king.
y() + 2);
533 int mask_all=(1<<5)-1;
534 verticals.
fill(mask_all);
535 const int y_mask_base=(1 << (Defense ==
BLACK ? (min_y-king.
y()) + 2 : -(max_y-king.
y()) + 2));
537 mask_all ^= ((1<<(max_y-king.
y()+3))-y_mask_base);
539 mask_all ^= ((1<<(king.
y()-min_y+3))-y_mask_base);
541 int attack_count = 0;
542 int defense_count = 0;
543 for (
int x = min_x; x <= max_x; ++x)
545 int vertical_x=mask_all;
546 int king_vertical_x = 0;
548 int y_mask=y_mask_base;
549 for (
int y = min_y; y <= max_y; ++y, y_mask+=y_mask)
551 const Square target(x, y);
552 const int count = state.
countEffect(Attack, target);
556 attack_count += count;
557 vertical_x |= y_mask;
563 king_vertical_x |= y_mask;
568 int y_mask=y_mask_base;
569 for (
int y = max_y; y >= min_y; --y, y_mask+=y_mask)
571 const Square target(x, y);
572 const int count = state.
countEffect(Attack, target);
576 attack_count += count;
577 vertical_x |= y_mask;
579 const Piece piece = state.
pieceAt(target);
581 (piece.isEmpty() || piece.owner() == Attack))
583 king_vertical_x |= y_mask;
587 const int x_diff = king.
x() - x;
588 verticals[(Defense ==
BLACK ? 2 - x_diff : 2 + x_diff)] = vertical_x;
589 king_verticals[(Defense ==
BLACK ? 2 - x_diff : 2 + x_diff)] =
592 attack_effect = std::min(127, attack_count);
593 defense_effect = std::min(127, defense_count);
595 attack_piece = std::min(16, attack_mask.countBit());
597 defense_piece = std::min(16, defense_mask.countBit());
598 supported_mask = attack_mask & state.
effectedMask(Attack);
599 attack_piece_supported = std::min(16, supported_mask.
countBit());
613 for (
size_t i = 0; i <
DIM/2; ++i)
626 for (
size_t i = 0; i < weights.
dimension(); ++i)
628 table[i] = weights.
value(i);
632template <osl::Player defense>
639 const int min_x = std::max(1, king.x() - 2);
640 const int max_x = std::min(9, king.x() + 2);
641 const int min_y = std::max(1, king.y() - 2);
642 const int max_y = std::min(9, king.y() + 2);
647 for (
int x = min_x; x <= max_x; ++x)
649 for (
int y = min_y; y <= max_y; ++y)
656 if (defense ==
BLACK)
657 result += table[
index(x - king.x(), y - king.y())];
659 result -= table[
index(king.x() - x, king.y() - y)];
666template <osl::Player defense>
671 int result_o = 0, result_e = 0;
674 const int min_x = std::max(1, king.x() - 2);
675 const int max_x = std::min(9, king.x() + 2);
676 const int min_y = std::max(1, king.y() - 2);
677 const int max_y = std::min(9, king.y() + 2);
682 for (
int x = min_x; x <= max_x; ++x)
684 for (
int y = min_y; y <= max_y; ++y)
691 if (defense ==
BLACK)
693 result_o += opening[
index(x - king.x(), y - king.y())];
694 result_e += ending[
index(x - king.x(), y - king.y())];
698 result_o -= opening[
index(king.x() - x, king.y() - y)];
699 result_e -= ending[
index(king.x() - x, king.y() - y)];
704 return std::make_pair(result_o, result_e);
715 return std::make_pair(result_o, result_e);
730 std::pair<int,int> b = update_black
732 : std::make_pair(last_opening_value[0], last_ending_value[0]);
733 std::pair<int,int> w = update_white
735 : std::make_pair(last_opening_value[1], last_ending_value[1]);
738 return std::make_pair(result_o, result_e);
771 for (
size_t i = 0; i < weights.
dimension(); ++i)
778template <osl::Player Defense>
788 const int diff = state.
countEffect(Defense, target) -
794template <osl::Player Defense>
801 const int rel_x = std::abs(king.
x() - target.
x());
803 const int rel_y = (target.
y() - king.
y()) * (Defense ==
BLACK ? 1 : -1);
807 else if (piece.
owner() == Defense)
812 int val = rel_y + 2 + rel_x * 5 +
814 piece_owner * 5 * 3 * 8;
819template <osl::Player Defense>
825 const int min_x = std::max(1, king.
x() - 2);
826 const int max_x = std::min(9, king.
x() + 2);
827 const int min_y = std::max(1, king.
y() - 2);
828 const int max_y = std::min(9, king.
y() + 2);
829 for (
int x = min_x; x <= max_x; ++x)
831 for (
int y = min_y; y <= max_y; ++y)
837 if (Defense ==
BLACK)
864 for (
size_t i = 0; i < weights.
dimension(); ++i)
873 for (
size_t i = 0; i < weights.
dimension(); ++i)
882 for (
size_t i = 0; i < weights.
dimension(); ++i)
891 for (
size_t i = 0; i < weights.
dimension(); ++i)
899 for(
int rel_y_2=0;rel_y_2<5;rel_y_2++)
900 for(
int x_diff_2=0;x_diff_2<5;x_diff_2++)
901 for(
int es=0;es<8;es++)
902 for(
int po=0;po<3;po++)
903 for(
int king_x_1=0;king_x_1<5;king_x_1++){
904 int oldIndex=(rel_y_2+x_diff_2*5+es*5*5+po*5*5*8)*5+king_x_1;
905 int newIndex=po+3*(es+8*(rel_y_2+5*(x_diff_2+5*king_x_1)));
909 for(
int rel_y_2=0;rel_y_2<5;rel_y_2++)
910 for(
int rel_x=0;rel_x<3;rel_x++)
911 for(
int es=0;es<8;es++)
912 for(
int po=0;po<3;po++)
913 for(
int king_y_1=0;king_y_1<9;king_y_1++){
914 int oldIndex=(rel_y_2+rel_x*5+es*5*3+po*5*3*8)*9+king_y_1;
915 int newIndex=po+3*(es+8*(rel_y_2+5*(rel_x+3*king_y_1)));
919 for(
int d_effect=0;d_effect<16;d_effect++){
920 for(
int a_effect=0;a_effect<16;a_effect++){
925 int diff=d_effect-a_effect;
936 for(
int rel_y_2=0;rel_y_2<5;rel_y_2++)
937 for(
int x_diff_2=0;x_diff_2<5;x_diff_2++){
938 int rel_x=std::abs(x_diff_2-2);
939 for(
int es=0;es<8;es++)
940 for(
int po=0;po<3;po++)
941 for(
int king_x_1=0;king_x_1<5;king_x_1++)
942 for (
int king_y_1=0;king_y_1<9;king_y_1++) {
943 int oldIndex=((rel_y_2+x_diff_2*5+es*5*5+po*5*5*8)*9+king_y_1)*5 + king_x_1;
944 int newIndexX=po+3*(es+8*(rel_y_2+5*(x_diff_2+5*king_x_1)));
945 int newIndexY=po+3*(es+8*(rel_y_2+5*(rel_x+3*king_y_1)));
946 int newIndex=po+3*(es+8*(rel_y_2+5*(x_diff_2+5*(king_x_1+5*king_y_1))));
953template <osl::Player Defense>
959 const int d_effect=
effect.countEffect(Defense);
960 const int a_effect=
effect.countEffect(
alt(Defense));
964template <osl::Player Defense>
967 Square target,
int &index_xy,
968 int rel_y,
int king_x,
int king_y,
int x_diff)
975#ifdef __INTEL_COMPILER
976 piece_owner = (
unsigned int)((
int)(ptypeO)>>30);
978 piece_owner |= (ptypeO+14)>>4;
980 piece_owner=((ptypeO+14)>>4)|(((
unsigned int)ptypeO>>30)&0x2);
984 piece_owner=(((ptypeO+14)>>3)&0x2)|((
unsigned int)ptypeO>>31);
986 assert(piece_owner >= 0 && piece_owner < 3);
989 index_xy=piece_owner+effect_state_index+3*(8*((rel_y+2)+5*((x_diff+2)+5*(king_x-1+5*(king_y-1)))));
992template <osl::Player Defense>
998 const int min_dx = std::max(1, king.
x() - 2)-king.
x();
999 const int max_dx = std::min(9, king.
x() + 2)-king.
x();
1000 const int min_dy = std::max(1, king.
y() - 2)-king.
y();
1001 const int max_dy = std::min(9, king.
y() + 2)-king.
y();
1002 const int king_x = (king.
x() > 5 ? 10 - king.
x() : king.
x());
1003 const int king_y = (Defense ==
BLACK ? king.
y() : 10 - king.
y());
1004 if ((Defense ==
BLACK && king.
x() >= 6) ||
1005 (Defense ==
WHITE && king.
x() >= 5)){
1006 for (
int dx = min_dx; dx <= max_dx; ++dx)
1012 for (
int dy = min_dy; dy <= max_dy; ++dy)
1014 const Square target(king.
x()+dx, king.
y()+dy);
1016 const int rel_y = dy * (Defense ==
BLACK ? 1 : -1);
1019 rel_y,king_x,king_y,x_diff);
1025 for (
int dx = min_dx; dx <= max_dx; ++dx)
1031 for (
int dy = min_dy; dy <= max_dy; ++dy)
1033 const Square target(king.
x()+dx, king.
y()+dy);
1035 const int rel_y = dy * (Defense ==
BLACK ? 1 : -1);
1038 rel_y,king_x,king_y,x_diff);
1043 if (Defense !=
BLACK)
1081template <
bool Opening>
1084template <
bool Opening>
1088 for (
size_t i = 0; i < weights.
dimension(); ++i)
1094template <
bool Opening>
1095template <osl::Player player>
1100 if ((player ==
BLACK && king.
x() >= 6) ||
1101 (player ==
WHITE && king.
x() >= 5))
1104 target_x = 10 - target.
x();
1109 target_x = target.
x();
1111 const int y = (player ==
BLACK ? king.
y() : 10 - king.
y());
1112 const int target_y = (player ==
BLACK ? target.
y() : 10 - target.
y());
1114 return target_y - y + 2 + (target_x - x + 2 ) * 5 + (y - 1) * 5 * 5
1115 + (x - 1) * 5 * 5 * 9;
1118template <
bool Opening>
1119template <osl::Player Defense>
1125 const int min_x = std::max(1, king.
x() - 2);
1126 const int max_x = std::min(9, king.
x() + 2);
1127 const int min_y = std::max(1, king.
y() - 2);
1128 const int max_y = std::min(9, king.
y() + 2);
1129 for (
int x = min_x; x <= max_x; ++x)
1131 for (
int y = min_y; y <= max_y; ++y)
1140 if (Defense ==
BLACK)
1146template <
bool Opening>
1153template <
bool Opening>
1164 int result = last_value;
1169 if (std::abs(self_king.
x() - from.
x()) <= 2 &&
1170 std::abs(self_king.
y() - from.
y()) <= 2)
1176 if (std::abs(opp_king.
x() - from.
x()) <= 2 &&
1177 std::abs(opp_king.
y() - from.
y()) <= 2)
1188 if (std::abs(self_king.
x() - to.
x()) <= 2 &&
1189 std::abs(self_king.
y() - to.
y()) <= 2)
1194 if (std::abs(opp_king.
x() - to.
x()) <= 2 &&
1195 std::abs(opp_king.
y() - to.
y()) <= 2)
1211 for (
int i = 0; i <
ONE_DIM; ++i)
1220 for (
int i = 0; i <
X_DIM; ++i)
1225 for (
int i = 0; i <
Y_DIM; ++i)
1232template <osl::Player King>
1237 const int vertical_index =
1241 const int vertical_index_x =
1246 const int vertical_index_y =
1251 const int horizontal_index =
1255 const int horizontal_index_x =
1260 const int horizontal_index_y =
1265 const int diagonal_index1 =
1269 const int diagonal_index2 =
1273 const int diagonal_index1_x =
1278 const int diagonal_index2_x=
1283 const int diagonal_index1_y =
1288 const int diagonal_index2_y =
1294 diagonal_index1, diagonal_index2,
1295 vertical_index_x, horizontal_index_x,
1296 diagonal_index1_x, diagonal_index2_x,
1297 vertical_index_y , horizontal_index_y,
1298 diagonal_index1_y, diagonal_index2_y);
1328 if ((std::abs(last_move.
to().
x() - kings[0].x()) <= 1 &&
1329 std::abs(last_move.
to().
y() - kings[0].y()) <= 1) ||
1330 (std::abs(last_move.
to().
x() - kings[1].x()) <= 1 &&
1331 std::abs(last_move.
to().
y() - kings[1].y()) <= 1))
1335 if ((std::abs(last_move.
from().
x() - kings[0].x()) <= 1 &&
1336 std::abs(last_move.
from().
y() - kings[0].y()) <= 1) ||
1337 (std::abs(last_move.
from().
x() - kings[1].x()) <= 1 &&
1338 std::abs(last_move.
from().
y() - kings[1].y()) <= 1))
1361 for (
int i = 0; i <
ONE_DIM; ++i)
1366 for(
int king_x=0;king_x<5;king_x++)
1367 for(
int king_y=0;king_y<9;king_y++)
1368 for(
int dir=0;dir<8;dir++)
1370 int oldIndex=king_x + 5 * (king_y + 9 * (dir + 8 *
mobility));
1371 int newIndex=
mobility+9*(dir+8*(king_y+9*king_x));
1373 table[newIndex][s]=old_table[oldIndex][s];
1381 for (
int i = 0; i <
ONE_DIM; ++i)
1386 for(
int king_x=0;king_x<5;king_x++)
1387 for(
int king_y=0;king_y<9;king_y++)
1388 for(
int dir=0;dir<8;dir++)
1390 int oldIndex=king_x + 5 * (king_y + 9 * (dir + 8 *
mobility));
1391 int newIndex=
mobility+9*(dir+8*(king_y+9*king_x));
1401 for (
int i = 0; i <
ONE_DIM; ++i)
1406 for(
int king_x=0;king_x<5;king_x++)
1407 for(
int king_y=0;king_y<9;king_y++)
1408 for(
int dir=0;dir<8;dir++)
1410 int oldIndex=king_x + 5 * (king_y + 9 * (dir + 8 *
mobility));
1411 int newIndex=
mobility+9*(dir+8*(king_y+9*king_x));
1415 for(
int i=0;i<3240;i++){
1423template <osl::Player P>
1429 const int king_x = (king.
x() > 5 ? 10 - king.
x() : king.
x()) - 1;
1430 const int king_y = (P ==
BLACK ? king.
y() : 10 - king.
y()) - 1;
1431 int indexBase=9*8*(king_y+9*king_x);
1546 for (
int i = 0; i <
ONE_DIM; ++i)
1551 for(
int king_x=0;king_x<5;king_x++)
1552 for(
int king_y=0;king_y<9;king_y++)
1554 int oldIndex=king_x+5*(king_y+9*(
mobility+8));
1555 int newIndex=
mobility+33*(king_y+9*king_x);
1557 table[newIndex]=old_table[oldIndex];
1561template <osl::Player P>
1571 const int king_x = (king.
x() > 5 ? 10 - king.
x() : king.
x()) - 1;
1572 const int king_y = (P ==
BLACK ? king.
y() : 10 - king.
y()) - 1;
1602 for (
int i = 0; i <
ONE_DIM; ++i)
1611 for (
int i = 0; i <
ONE_DIM; ++i)
1620 for (
int i = 0; i <
ONE_DIM; ++i)
1625 for(
int king_y=1;king_y<=9;king_y++)
1626 for(
int effect1=0;effect1<32;effect1++)
1627 for(
int effect2=0;effect2<32;effect2++)
1628 for(
int i=0;i<8;i++){
1629 int index0=effect1 + 32 * (effect2 + 32 * i);
1630 int index1=king_y - 1 + 9 *(effect1 + 32 * (effect2 + 32 * i));
1635template<osl::Player P>
1641 const int king_y = (P==
BLACK ? king.
y() : 10 - king.
y());
1642 const int king_x = (king.
x() >= 6 ? 10 - king.
x() : king.
x());
1643 if ((P==
BLACK && king.
x() > 5) || (P==
WHITE && king.
x() < 5)){
1698 for (
int i = 0; i <
ONE_DIM; ++i)
1707 for (
int i = 0; i <
ONE_DIM; ++i)
1714template <osl::Player Attack>
1721 const bool with_knight =
1722 (king25 & ~state.promotedPieces()).template selectBit<KNIGHT>().
any();
1726 king25 = king25 | promoted_mask;
1727 const int piece_count = std::min(9, king25.
countBit());
1728 const int stand_count = std::min(9,
1741 while (attacked.
any())
1746 attacking = (attacking & state.
piecesOnBoard(Attack) & ~king25);
1747 const int attacked_count = std::min(5, attacking.countBit());
1748 if (Attack ==
BLACK)
1751 stand_count, stand_with_knight, attacked_count)] +
1753 stand_count, stand_with_knight, attacked_count,
1758 return -(
table[
index(piece_count, with_knight,
1759 stand_count, stand_with_knight, attacked_count)] +
1761 stand_count, stand_with_knight, attacked_count,
1784 for (
int i = 0; i <
ONE_DIM; ++i)
1793 for (
int i = 0; i <
ONE_DIM; ++i)
1802 for (
int i = 0; i <
ONE_DIM; ++i)
1819 for (
size_t i = 1; i < black.
size(); ++i)
1821 result += (
table[
index(black[i - 1], black[i], i - 1)] +
1823 black[i - 1], black[i], i - 1)] +
1825 black[i - 1], black[i], i - 1)]);
1826 result -= (
table[
index(white[i - 1], white[i], i - 1)] +
1828 white[i - 1], white[i], i - 1)] +
1830 white[i - 1], white[i], i - 1)]);
1843 for (
int i = 0; i <
ONE_DIM; ++i)
1852 for (
int i = 0; i <
ONE_DIM; ++i)
1859template <osl::Player Attack>
1873 attack = attack | attack_promoted_mask;
1877 defense = defense | defense_promoted_mask;
1878 const int attack_count = std::min(9,
1884 const int defense_count = std::min(9,
1892 MultiInt result =
table[attack_count + 10 * defense_count] +
1893 y_table[y - 1 + 9 * (attack_count + 10 * defense_count)];
1894 if (Attack ==
BLACK)
1913 for (
size_t i=0; i<weights.
dimension(); ++i)
1925 if (stand_all.
any())
1941template <osl::Player KingOwner>
1952 if (rook[0].owner() == rook[1].owner())
1954 if (rook[0].owner() == KingOwner)
1955 std::swap(rook[0], rook[1]);
1956 int rook_index0 =
indexKing(rook[0].square().squareForBlack(KingOwner));
1957 if (rook_index0 < 0)
1959 int rook_index1 =
indexKing(rook[1].square().squareForBlack(
alt(KingOwner)));
1960 if (rook_index1 < 0)
1966 if (p.
owner() == KingOwner)
1970 if (silver.
size() != 2 || silver[0].x() == silver[1].x())
1973 =
indexSilver((silver[0].x() > silver[1].x()) ? silver[0] : silver[1]);
1974 int index = offset + (king_index*81+silver_index)*90;
1975 return table[index + rook_index0] *
sign(KingOwner)
1976 +
table[index + 45 + rook_index1] *
sign(KingOwner);
1982template <osl::Player KingOwner>
1987 if (king.
y() < 4 || king.
y() > 6)
1990 for (
int x=std::max(1, king.
x()-2); x<=std::min(9, king.
x()+2); ++x) {
1991 for (
int y=king.
y()-2*
sign(KingOwner); 1; y-=
sign(KingOwner)) {
2001 return table[c*(std::min(7, count[0][0]))] *
sign(KingOwner)
2002 +
table[c*(8 +std::min(7, count[0][1]))] *
sign(KingOwner)
2003 +
table[c*(16+std::min(7, count[1][0]))] *
sign(KingOwner)
2004 +
table[c*(24+std::min(7, count[1][1]))] *
sign(KingOwner);
2017 for (
size_t i=0; i<weights.
dimension(); ++i)
2042 template void King25EffectBoth::countEffectAndPiecesBoth<BLACK>(
const NumEffectState&,
PieceMask&,
PieceMask&,
int&,
int&,
int&,
int&,
int&,
CArray<int, 5>&,
CArray<int, 5>&);
2043 template void King25EffectBoth::countEffectAndPiecesBoth<WHITE>(
const NumEffectState&,
PieceMask&,
PieceMask&,
int&,
int&,
int&,
int&,
int&,
CArray<int, 5>&,
CArray<int, 5>&);
void fill(const T_simple &value=T_simple())
void push_back(const T &e)
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
Ptype capturePtype() const
PtypeO capturePtypeO() const
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
const Square from() const
const NumBitmapEffect effectSetAt(Square sq) const
const BoardMask changedEffects(Player pl) const
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
int countEffect(Player player, Square target) const
利きの数を数える.
bool hasEffectByPiece(Piece attack, Square target) const
駒attack が target に利きを持つか (旧hasEffectToと統合)
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
Square kingMobilityAbs(Player p, Direction d) const
const PieceMask promotedPieces() const
const PieceMask & piecesOnBoard(Player p) const
void clearBit()
unpromote(PTYPE) の駒のbit を消す
const Square square() const
bool hasPieceOnStand(Player player, Ptype ptype) const
const Piece nth(int n) const
unpromote(PTYPE)のn番目の駒を帰す.
PieceMask & standMask(Player p)
const Piece kingPiece() const
const Piece pieceOf(int num) const
Square kingSquare() const
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
const Piece pieceAt(Square sq) const
int y() const
将棋としてのY座標を返す.
const Square squareForBlack(Player player) const
bool isOnBoard() const
盤面上を表すかどうかの判定. 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する.
int x() const
将棋としてのX座標を返す.
bool anyInRange(const BoardMask &mask) const
static int indexSilver(Square silver)
static int evalOne(const NumEffectState &state, int offset)
static void setUp(const Weights &weights)
static int indexKing(Square king)
static int eval(const NumEffectState &state)
static CArray< int, DIM > table
static void setUp(const Weights &weights)
static int evalOne(const NumEffectState &state)
static CArray< int, DIM > table
static int eval(const NumEffectState &state)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static int indexX(Square king, int effect1, int effect2, int i, int j)
static void setUp(const Weights &weights)
static int indexY(Square king, int effect1, int effect2, int i)
static MultiInt eval(const NumEffectState &state, const CArray< int, 5 > &black, const CArray< int, 5 > &white)
static CArray< MultiInt, 40960 > x_table
static CArray< MultiInt, 73728 > y_table
static CArray< MultiInt, 8192 > table
static MultiInt evalOne(const NumEffectState &state, const CArray< int, 5 > &effects)
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
static void setUp(const Weights &weights)
static CArray< MultiInt, 21600 > y_table
static MultiInt evalOne(const NumEffectState &state, PieceMask king25)
static int index(int piece_count, bool with_knight, int stand_count, bool with_knight_on_stand, int attacked_count)
static MultiInt eval(const NumEffectState &state, const CArray< PieceMask, 2 > &king25_mask)
static int indexY(int piece_count, bool with_knight, int stand_count, bool with_knight_on_stand, int attacked_count, int king_y)
static CArray< MultiInt, 2400 > table
static void setUp(const Weights &weights)
static CArray< int, 17 *128 > table
static void setUp(const Weights &weights)
static void countEffectAndPiecesBoth(const NumEffectState &state, PieceMask &effect25, PieceMask &effect_supported, int &attack_effect, int &attack_piece, int &defense_effect, int &defence_piece, int &attack_piece_supported, CArray< int, 5 > &effect_vertical, CArray< int, 5 > &king_vertical)
static CArray< int, DIM/2 > attack_table
static CArray< int, DIM/2 > defense_table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, 900 > y_table
static CArray< MultiInt, 100 > table
static MultiInt eval(const NumEffectState &state, const CArray< PieceMask, 2 > &king25)
static MultiInt evalOne(const NumEffectState &state, PieceMask king25)
static CArray< MultiInt, 17 *128 > table
static void setUp(const Weights &weigths)
static void setUp(const Weights &weigths)
static void setUp(const Weights &weigths)
static void setUp(const Weights &weigths)
static CArray< MultiInt, 3240 > y_table
static CArray< int, 256 > effect_state_table
static CArray< MultiInt, 3000 > x_table
static CArray< MultiInt, 5 *3 *8 *3 > table
static int effectStateIndex3(const NumEffectState &state, Square target)
static void evalWithUpdate(const NumEffectState &state, Move last_move, MultiIntPair &values)
static void eval(const NumEffectState &state, MultiIntPair &out)
static CArray< MultiInt, 27000 > xy_table
static void evalOne(const NumEffectState &state, MultiInt &out)
static void index(const NumEffectState &state, Square target, int &index_xy, int rel_y, int king_x, int king_y, int x_diff)
static void setUp(const Weights &weigths)
static void setUp(const Weights &weigths)
static EffectState effectState(const NumEffectState &state, Square target)
static void setUp(const Weights &weigths)
static CArray< int, 5 *3 *8 *3 > table
static int evalOne(const NumEffectState &state)
static int eval(const NumEffectState &state)
static int index(const NumEffectState &state, Square king, Square target)
static CArray< MultiInt, ONE_DIM > table
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
static CArray< int, 17 *128 *9 > table
static CArray< MultiInt, 17 *128 *9 > table
static void setUp(const Weights &weights)
static CArray< int, DIM/2 > attack_table
static CArray< int, DIM/2 > defense_table
static void countEffectAndPieces(const NumEffectState &state, const Player attack, int &effect, int &piece)
static void setUp(const Weights &weights)
static CArray< int, DIM > table
static int index(int effect, int piece_count)
static int eval(const NumEffectState &state)
static void setUp(const Weights &weigths)
static int index(Square king, Square target)
static int eval(const NumEffectState &state)
static CArray< int, 1125 > table
static int evalWithUpdate(const NumEffectState &state, osl::Move moved, int last_value)
static int evalOne(const NumEffectState &state)
static CArray< int, 15 > table
static const CArray< int, 2 > eval(const NumEffectState &state)
static const CArray< int, 2 > eval(const NumEffectState &state)
static CArray< int, 15 > table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, 20480 > x_table
static int indexX(Square king, int effect1, int effect2, int i)
static MultiInt eval(const NumEffectState &state, const CArray< int, 5 > &black, const CArray< int, 5 > &white)
static int indexY(Square king, int effect1, int effect2, int i)
static CArray< MultiInt, 36864 > y_table
static void setUp(const Weights &weights)
static int index(int effect1, int effect2, int i)
static CArray< MultiInt, 4096 > table
static void setUp(const Weights &weights)
static MultiInt evalWithUpdate(const NumEffectState &state, Move last_move, MultiInt &last_value)
static MultiInt value(int vertical_index, int horizontal_index, int diagonal_index1, int diagonal_index2, int vertical_index_x, int horizontal_index_x, int diagonal_index1_x, int diagonal_index2_x, int vertical_index_y, int horizontal_index_y, int diagonal_index1_y, int diagonal_index2_y)
static int indexY(const Square king_position, PtypeO p1, PtypeO p2)
static MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 3072 > table
static void evalOne(const NumEffectState &state, MultiInt &result)
static int indexX(const Square king_position, PtypeO p1, PtypeO p2)
static int index(PtypeO p1, PtypeO p2)
static CArray< MultiInt, 27648 > y_table
static CArray< MultiInt, 15360 > x_table
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, 45 *33 > 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 int mobilityDir(Square king, Square target)
static MultiInt evalOne(const NumEffectState &state)
static CArray< MultiInt, 3240 > rook_bishop_table
static CArray< MultiInt, 3240 > table
static void setUp(const Weights &weights)
static CArray< MultiInt, 3240 > rook_table
static CArray< MultiInt, 3240 > bishop_table
static MultiInt eval(const NumEffectState &state)
static void setUp(const Weights &weights)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const CArray< PieceMask, 2 > &effected_mask, const MultiInt &last_values)
static CArray< MultiInt, ONE_DIM > table
static int index(const Player player, const Square king, const Ptype ptype, const Square pos)
static MultiInt eval(const NumEffectState &state)
static void adjust(int attack, int defense, MultiInt &out)
CArray< CArray< T, Capacity2 >, Capacity1 > CArray2d
const BoardMaskTable5x5 Board_Mask_Table5x5
constexpr int sign(Player player)
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
constexpr Player alt(Player player)
PtypeO newPtypeO(Player player, Ptype ptype)
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
static std::pair< CArray< int, 2 >, CArray< int, 2 > > evalWithUpdate(const NumEffectState &state, Move last_move, const CArray< int, 15 > &opening, const CArray< int, 15 > &ending, const CArray< int, 2 > &last_opening_value, const CArray< int, 2 > &last_ending_value)
static int evalOne(const NumEffectState &state, const CArray< int, 15 > &table)
static std::pair< CArray< int, 2 >, CArray< int, 2 > > eval(const NumEffectState &state, const CArray< int, 15 > &opening, const CArray< int, 15 > &ending)
static void setUpBase(const Weights &weigths, CArray< int, 15 > &table)
static int index(int rel_x, int rel_y)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_values)
static table_t attack_table
static void setUp(const Weights &weights, int stage)
static table_t defense_table
static int index(const NumEffectState &, Player owner, const Square position, Square king)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static CArray< MultiInt, 2592 > table
static void setUp(const Weights &weights)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_values)
static void adjust(int black, int white, MultiInt &out)
static int index(const Piece p, const Square king)
int value(size_t index) const