3 #include <boost/foreach.hpp> 
   11   for (
size_t i = 0; i < weights.
dimension(); ++i)
 
   13     table[i][stage] = weights.
value(i);
 
   23     const int black_count =
 
   25     const int white_count =
 
   27     for (
int j = 0; j < black_count; ++j)
 
   31     for (
int j = 0; j < white_count; ++j)
 
   47   for (
size_t i = 0; i < weights.
dimension(); ++i)
 
   49     table[i][stage] = weights.
value(i);
 
   56   return table[black_count] - table[white_count];
 
   65                                     const CArray<MultiInt, 5625> &values)
 
   68   for (
int rook = 0; rook <= indices[0]; ++rook)
 
   70     for (
int bishop = 0; bishop <= indices[1]; ++bishop)
 
   72       for (
int gold = 0; gold <= indices[2]; ++gold)
 
   74         for (
int silver = 0; silver <= indices[3]; ++silver)
 
   76           for (
int knight = 0; knight <= indices[4]; ++knight)
 
   78             for (
int lance = 0; lance <= indices[5]; ++lance)
 
   80               if (rook + bishop + gold + silver + knight + lance == 0)
 
   84               result += values[index(rook, bishop,
 
   85                                      gold, silver, knight, lance)];
 
   98   CArray<MultiInt, 5625> orig_table;
 
   99   for (
size_t i = 0; i < ONE_DIM; ++i)
 
  103       orig_table[i][s] = weights.
value(i + ONE_DIM*s);
 
  106   CArray<int, 6> indices;
 
  107   for (indices[0] = 0; indices[0] <= 2; ++indices[0])
 
  109     for (indices[1] = 0; indices[1] <= 2; ++indices[1])
 
  111       for (indices[2] = 0; indices[2] <= 4; ++indices[2])
 
  113         for (indices[3] = 0; indices[3] <= 4; ++indices[3])
 
  115           for (indices[4] = 0; indices[4] <= 4; ++indices[4])
 
  117             for (indices[5] = 0; indices[5] <= 4; ++indices[5])
 
  119               table[index(indices[0],
 
  124                           indices[5])] = sumUp(indices, orig_table);
 
  131   table[0] = orig_table[0];
 
  137   CArray<MultiInt, 5625> orig_table;
 
  138   for (
size_t i = 0; i < ONE_DIM; ++i)
 
  142       orig_table[i][s] = weights.
value(i + ONE_DIM*s);
 
  145   CArray<int, 6> indices;
 
  146   for (indices[0] = 0; indices[0] <= 2; ++indices[0])
 
  148     for (indices[1] = 0; indices[1] <= 2; ++indices[1])
 
  150       for (indices[2] = 0; indices[2] <= 4; ++indices[2])
 
  152         for (indices[3] = 0; indices[3] <= 4; ++indices[3])
 
  154           for (indices[4] = 0; indices[4] <= 4; ++indices[4])
 
  156             for (indices[5] = 0; indices[5] <= 4; ++indices[5])
 
  177                                    const CArray<bool, 2> &can_check)
 
  179   const int black_index = index(state.countPiecesOnStand<
ROOK>(
BLACK),
 
  185   const int white_index = index(state.countPiecesOnStand<
ROOK>(
WHITE),
 
  192   result = table[black_index] - table[white_index];
 
  193   if (can_check[
WHITE])
 
  195     result += check_table[black_index];
 
  197   if (can_check[
BLACK])
 
  199     result -= check_table[white_index];
 
  206   const NumEffectState &state,
 
  209   const CArray<bool, 2> &could_check,
 
  210   const CArray<bool, 2> &can_check)
 
  213       could_check[0] == can_check[0] && could_check[1] == can_check[1])
 
  217   return eval(state, can_check);
 
  226   for (
size_t i = 0; i < ONE_DIM; ++i)
 
  229       table[i][s] = weights.
value(i + ONE_DIM*s);
 
  241     const int black_count = state.countPiecesOnStand(
BLACK, ptype);
 
  242     const int white_count = state.countPiecesOnStand(
WHITE, ptype);
 
  243     for (
int j = 0; j < black_count; ++j)
 
  245       const int index_black = index(
BLACK, 
BLACK, ptype, j);
 
  246       const int index_white = index(
BLACK, 
WHITE, ptype, j);
 
  247       result[
BLACK] += table[index_black];
 
  248       result[
WHITE] += table[index_white];
 
  250     for (
int j = 0; j < white_count; ++j)
 
  252       const int index_black = index(
WHITE, 
BLACK, ptype, j);
 
  253       const int index_white = index(
WHITE, 
WHITE, ptype, j);
 
  254       result[
BLACK] -= table[index_black];
 
  255       result[
WHITE] -= table[index_white];
 
  260 template<osl::Player P>
 
  263   const NumEffectState &state,
 
  266   assert(P==moved.
player());
 
  276       state.countPiecesOnStand(P, moved.
ptype());
 
  280       result[
BLACK] -= table[index_black];
 
  281       result[
WHITE] -= table[index_white];
 
  284       result[
BLACK] += table[index_black];
 
  285       result[
WHITE] += table[index_white];
 
  292     const int count = state.countPiecesOnStand(P, ptype) - 1;
 
  293     const int index_black = index(P, 
BLACK, ptype, count);
 
  294     const int index_white = index(P, 
WHITE, ptype, count);
 
  296       result[
BLACK] += table[index_black];
 
  297       result[
WHITE] += table[index_white];
 
  300       result[
BLACK] -= table[index_black];
 
  301       result[
WHITE] -= table[index_white];
 
  315   for (
size_t i = 0; i < ONE_DIM; ++i)
 
  319       y_attack_table[i][s] = weights.
value(i + ONE_DIM * 2 * s);
 
  320       y_defense_table[i][s] = weights.
value(i + ONE_DIM * 2 * s + ONE_DIM);
 
  323   for (
int i=0;i<7;i++){
 
  326     for(
int king_y=1;king_y<=9;king_y++){
 
  331         int newIndex=(king_y - 1) * 7*19 + i*19 + 
count;
 
  336         y_attack_table_sum[newIndex]=attack_sum;
 
  337         y_defense_table_sum[newIndex]=defense_sum;
 
  338         if(
count==ptypeSize) 
break;
 
  339         attack_sum += y_attack_table[oldIndex];
 
  340         defense_sum += y_defense_table[oldIndex];
 
  355   result += y_attack_table_sum[attack_index_1] - y_attack_table_sum[attack_index_2] +
 
  356     y_defense_table_sum[defense_index_1] - y_defense_table_sum[defense_index_2];
 
  363   const CArray<Square,2> kings = {{ 
 
  364       state.kingSquare(
BLACK),
 
  365       state.kingSquare(
WHITE),
 
  367   updateResult(state,result,0,
ROOK,kings);
 
  368   updateResult(state,result,1,
BISHOP,kings);
 
  369   updateResult(state,result,2,
GOLD,kings);
 
  370   updateResult(state,result,3,
SILVER,kings);
 
  371   updateResult(state,result,4,
KNIGHT,kings);
 
  372   updateResult(state,result,5,
LANCE,kings);
 
  373   updateResult(state,result,6,
PAWN,kings);
 
  377 template<osl::Player P>
 
  380   const NumEffectState &state,
 
  391       state.countPiecesOnStand(P, ptype);
 
  392     const int attack_index = index(ptype, P,
 
  393                                    state.kingSquare(
alt(P)),
 
  395     const int defense_index = index(ptype, P,
 
  399       result -= y_attack_table[attack_index] +y_defense_table[defense_index];
 
  401       result += y_attack_table[attack_index] +y_defense_table[defense_index];
 
  406     const int count = state.countPiecesOnStand(P, ptype)-1;
 
  407     const int attack_index = index(ptype, P,
 
  408                                    state.kingSquare(
alt(P)),
 
  410     const int defense_index = index(ptype, P,
 
  414       result += y_attack_table[attack_index] +y_defense_table[defense_index];
 
  416       result -= y_attack_table[attack_index] +y_defense_table[defense_index];
 
  426   for (
size_t i = 0; i < ONE_DIM; ++i)
 
  428     int low = (i & 0x7F);
 
  432     for (
int s = 0; s < 
NStages; ++s)
 
  434       table[i][s] = weights.
value(i + ONE_DIM*s);
 
  437         table[(low << 7) | high][s] = -table[i][s];
 
  448   black_index |= ((state.hasPieceOnStand<
ROOK>(
BLACK) ? 1 : 0) << 6);
 
  449   black_index |= ((state.hasPieceOnStand<
BISHOP>(
BLACK) ? 1 : 0) << 5);
 
  450   black_index |= ((state.hasPieceOnStand<
GOLD>(
BLACK) ? 1 : 0) << 4);
 
  451   black_index |= ((state.hasPieceOnStand<
SILVER>(
BLACK) ? 1 : 0) << 3);
 
  452   black_index |= ((state.hasPieceOnStand<
KNIGHT>(
BLACK) ? 1 : 0) << 2);
 
  453   black_index |= ((state.hasPieceOnStand<
LANCE>(
BLACK) ? 1 : 0) << 1);
 
  454   black_index |= ((state.hasPieceOnStand<
PAWN>(
BLACK) ? 1 : 0) << 0);
 
  455   white_index |= ((state.hasPieceOnStand<
ROOK>(
WHITE) ? 1 : 0) << 6);
 
  456   white_index |= ((state.hasPieceOnStand<
BISHOP>(
WHITE) ? 1 : 0) << 5);
 
  457   white_index |= ((state.hasPieceOnStand<
GOLD>(
WHITE) ? 1 : 0) << 4);
 
  458   white_index |= ((state.hasPieceOnStand<
SILVER>(
WHITE) ? 1 : 0) << 3);
 
  459   white_index |= ((state.hasPieceOnStand<
KNIGHT>(
WHITE) ? 1 : 0) << 2);
 
  460   white_index |= ((state.hasPieceOnStand<
LANCE>(
WHITE) ? 1 : 0) << 1);
 
  461   white_index |= ((state.hasPieceOnStand<
PAWN>(
WHITE) ? 1 : 0) << 0);
 
  462   return table[(black_index << 7) | white_index];
 
  472       template void NonPawnPieceStandTurn::evalWithUpdateBang<BLACK>(
const NumEffectState &, 
Move, 
MultiIntPair &);
 
  473       template void NonPawnPieceStandTurn::evalWithUpdateBang<WHITE>(
const NumEffectState &, 
Move, 
MultiIntPair &);
 
  474       template MultiInt PieceStandY::evalWithUpdate<BLACK>(
const NumEffectState &, 
Move, 
const MultiInt &);
 
  475       template MultiInt PieceStandY::evalWithUpdate<WHITE>(
const NumEffectState &, 
Move, 
const MultiInt &);