36     const CArray<int,19*9> yss_bonus = {{
 
   38          50,  50,  50,  50,  50,  50,  0,  0,  0, 
 
   39          50,  50,  50,  50,  50,  50,  0,  0,  0, 
 
   40          50,  50,  50,  50,  50,  50,  0,  0,  0, 
 
   41          62,  60,  58,  52,  50,  50,  0,  0,  0, 
 
   42          80,  78,  72,  67,  55,  51,  0,  0,  0, 
 
   43         100,  99,  95,  87,  78,  69,  0,  0,  0, 
 
   44         140, 130, 110, 100,  95,  75,  0,  0,  0, 
 
   45         170, 160, 142, 114,  98,  80,  0,  0,  0,
 
   46         170, 165, 150, 121,  94,  78,  0,  0,  0, 
 
   47         170, 145, 137, 115,  91,  75,  0,  0,  0,
 
   48         132, 132, 129, 102,  84,  71,  0,  0,  0, 
 
   49         100,  97,  95,  85,  70,  62,  0,  0,  0, 
 
   50          90,  85,  80,  68,  60,  53,  0,  0,  0, 
 
   51          70,  66,  62,  55,  52,  50,  0,  0,  0, 
 
   52          54,  53,  51,  50,  50,  50,  0,  0,  0, 
 
   53          50,  50,  50,  50,  50,  50,  0,  0,  0, 
 
   54          50,  50,  50,  50,  50,  50,  0,  0,  0, 
 
   55          50,  50,  50,  50,  50,  50,  0,  0,  0,
 
   56          50,  50,  50,  50,  50,  50,  0,  0,  0, 
 
   58     inline int toEven(
int value) 
 
   66     inline int multiply(
int value, 
int bonus)
 
   69       return toEven(value * bonus / 120); 
 
   71     inline void adhoc_adjust(
int& value, 
double scale)
 
   73       value = toEven(static_cast<int>(value * scale));
 
   83   for (
int ptype = 
PPAWN; ptype <= 
ROOK; ptype++)
 
   87       adhoc_adjust(
valueOf(king, player, attack,
 
   88                            static_cast<osl::Ptype>(ptype)), 1.25);
 
   98   adhoc_adjust(valueOf(king, player, attack,
 
  100   adhoc_adjust(valueOf(king, player, attack,
 
  104     adhoc_adjust(valueOf(king, player, attack,
 
  105                          static_cast<osl::Ptype>(ptype)), 1.25);
 
  114   for (
int king_x=1; king_x<=9; ++king_x)
 
  116     for (
int king_y=1; king_y<=9; ++king_y)
 
  118       const Square king(king_x, king_y);
 
  125         const int ptype_value
 
  128         const int stand_bonus 
 
  140         for (
int attack_x=1; attack_x<=9; ++attack_x)
 
  142           const int relative_x = abs(king_x - attack_x);
 
  143           for (
int attack_y=1; attack_y<=9; ++attack_y)
 
  145             const Square attacker(attack_x, attack_y);
 
  146             if (basic_type == 
KING)
 
  149               valueOf(king, 
WHITE, attacker, ptype) = ptype_value;
 
  153             const int relative_y_white_king 
 
  155                  ? attack_y - king_y - 1 
 
  156                  : attack_y - king_y);
 
  158             const int bonus_white_king
 
  159               = yss_bonus[relative_x + (-relative_y_white_king+9)*9];
 
  161             const int black_attack =  multiply(ptype_value,bonus_white_king);
 
  166               const int relative_y = abs(king_y - attack_y);
 
  167               const int diff1 = king_x + king_y - (attack_x + attack_y);
 
  168               const int diff2 = king_x - king_y - (attack_x - attack_y);
 
  170               if ((basic_type == 
ROOK &&
 
  173                    ((-1 <= diff1 && diff1 <= 1) ||
 
  174                     (-1 <= diff2 && diff2 <= 1))))
 
  176                 valueOf(king, 
WHITE, attacker, ptype) 
 
  181                   adhoc_adjust(valueOf(king, 
WHITE, attacker, ptype),
 
  188                 valueOf(king, 
WHITE, attacker, ptype) 
 
  189                   = multiply(ptype_value, 90);
 
  194             if ((ptype == 
PAWN && attack_y >= 5) ||
 
  195                 (ptype == 
KNIGHT && attack_y >= 6))
 
  197               int new_black_attack = black_attack;
 
  198               adhoc_adjust(new_black_attack, 0.95);
 
  199               valueOf(king, 
WHITE, attacker, ptype) = new_black_attack;
 
  202               valueOf(king, 
WHITE, attacker, ptype) = black_attack;
 
  208   for (
int king_x=1; king_x<=9; ++king_x)
 
  210     for (
int king_y=1; king_y<=9; ++king_y)
 
  212       const Square king(king_x, king_y);
 
  214       for (
int x=1; x<=9; ++x)
 
  225       for (
int x=1; x<=9; ++x)
 
  228         if (x <= 2 || x >= 8)
 
  230           adhoc_adjust(valueOf(king, 
WHITE, b, 
GOLD),    0.25);
 
  235           adhoc_adjust(valueOf(king, 
WHITE, b, 
GOLD),    0.5);
 
  239         adhoc_adjust(valueOf(king, 
WHITE, b, 
PLANCE),  0.5);
 
  240         adhoc_adjust(valueOf(king, 
WHITE, b, 
PPAWN),   0.5);
 
  245         for (
int x = 1; x <= 9; ++x) {
 
  247           for (
int ptype = 
PPAWN; ptype <= 
ROOK; ptype++)
 
  250               adhoc_adjust(valueOf(king, 
WHITE, three,
 
  251                                    static_cast<osl::Ptype>(ptype)), 1.25);
 
  257         for (
int x = 
std::max(king_x - 1, 2);
 
  265       if (king_x == 1 || king_x == 9)
 
  267         int next = king_x == 1 ? 2 : 8;
 
  268         adhoc_edge_king_1(
WHITE, king, 
Square(next, king_y));
 
  271           adhoc_edge_king_1(
WHITE, king, 
Square(next, king_y + 1));
 
  276           adhoc_edge_king_1(
WHITE, king, 
Square(next, king_y + 2));
 
  315   for (
int x = 1; x <= 9; x++)
 
  317     for (
int y = 1; y <= 9; y++)
 
  330                              static_cast<osl::Ptype>(ptype)), 1.05);
 
  332                              static_cast<osl::Ptype>(ptype)), 1.05);
 
  340   for (
int king_x=1; king_x<=9; ++king_x) {
 
  341     for (
int king_y=1; king_y<=9; ++king_y) {
 
  342       const Square king_b(king_x, king_y);
 
  354         for (
int attack_x=1; attack_x<=9; ++attack_x) {
 
  355           for (
int attack_y=1; attack_y<=9; ++attack_y) {
 
  356             const Square attack_b(attack_x, attack_y); 
 
  359             valueOf(king_b, 
BLACK, attack_w, ptype) 
 
  360               = - valueOf(king_w, 
WHITE, attack_b, ptype);
 
  371   table.saveText(filename);