My Project
progress.cc
Go to the documentation of this file.
1 #include "osl/progress.h"
2 #include "osl/eval/weights.h"
3 #include "osl/eval/midgame.h"
4 #include "osl/eval/minorPiece.h"
5 #include "osl/additionalEffect.h"
7 #include "osl/oslConfig.h"
8 #include <iostream>
9 #include <fstream>
10 
12 operator==(const NewProgressData& l, const NewProgressData& r)
13 {
14  return l.progresses == r.progresses
18  && l.defenses == r.defenses
19  && l.rook == r.rook && l.bishop == r.bishop && l.gold == r.gold
20  && l.silver == r.silver && l.promoted == r.promoted
25 }
26 
53 
54 bool osl::progress::ml::NewProgress::setUp(const char *filename)
55 {
56  if (initialized_flag)
57  return true;
58 
59  static CArray<int, 25> effect_weight;
60  static CArray<int, 225> effect_x_weight, effect_y_weight;
61  static CArray<int, 25> effect_defense_weight;
62  static CArray<int, 225> effect_per_effect;
63  static CArray<int, 225> effect_per_effect_defense;
64  static CArray<int, 2025> effect_per_effect_y, effect_per_effect_x;
65  std::ifstream is(filename);
66  int read_count = 0;
67 
68  osl::eval::ml::Weights weights(25);
69  for (size_t i = 0; i < weights.dimension(); ++i)
70  {
71  int val;
72  is >> val;
73  effect_weight[i] = val;
74  ++read_count;
75  }
76  for (size_t i = 0; i < 225; ++i)
77  {
78  int val;
79  is >> val;
80  effect_x_weight[i] = val;
81  ++read_count;
82  }
83  for (size_t i = 0; i < 225; ++i)
84  {
85  int val;
86  is >> val;
87  effect_y_weight[i] = val;
88  ++read_count;
89  }
90  weights.resetDimension(25);
91  for (size_t i = 0; i < weights.dimension(); ++i)
92  {
93  int val;
94  is >> val;
95  effect_defense_weight[i] = val;
96  ++read_count;
97  }
98  weights.resetDimension(225);
99  for (size_t i = 0; i < weights.dimension(); ++i)
100  {
101  int val;
102  is >> val;
103  effect_per_effect[i] = val;
104  ++read_count;
105  }
106  weights.resetDimension(225);
107  for (size_t i = 0; i < weights.dimension(); ++i)
108  {
109  int val;
110  is >> val;
111  effect_per_effect_defense[i] = val;
112  ++read_count;
113  }
114 
115  weights.resetDimension(2025);
116  for (size_t i = 0; i < weights.dimension(); ++i)
117  {
118  int val;
119  is >> val;
120  effect_per_effect_y[i] = val;
121  ++read_count;
122  }
123  weights.resetDimension(2025);
124  for (size_t i = 0; i < weights.dimension(); ++i)
125  {
126  int val;
127  is >> val;
128  effect_per_effect_x[i] = val;
129  ++read_count;
130  }
131  weights.resetDimension(Piece::SIZE);
132  for (size_t i = 0; i < weights.dimension(); ++i)
133  {
134  int val;
135  is >> val;
136  stand_weight[i] = val;
137  ++read_count;
138  }
139  weights.resetDimension(1125);
140  for (size_t i = 0; i < weights.dimension(); ++i)
141  {
142  int val;
143  is >> val;
144  attack5x5_weight[i] = val;
145  ++read_count;
146  }
147  weights.resetDimension(75);
148  for (size_t i = 0; i < weights.dimension(); ++i)
149  {
150  int val;
151  is >> val;
152  effectstate_weight[i] = val;
153  ++read_count;
154  }
155  weights.resetDimension(5625);
156  for (size_t i = 0; i < weights.dimension(); ++i)
157  {
158  int val;
159  is >> val;
160  attack5x5_x_weight[i] = val;
161  ++read_count;
162  }
163  weights.resetDimension(10125);
164  for (size_t i = 0; i < weights.dimension(); ++i)
165  {
166  int val;
167  is >> val;
168  attack5x5_y_weight[i] = val;
169  ++read_count;
170  }
171  weights.resetDimension(4284);
172  for (size_t i = 0; i < weights.dimension(); ++i)
173  {
174  int val;
175  is >> val;
176  king_relative_weight[i] = val;
177  ++read_count;
178  }
179  weights.resetDimension(262144);
180  for (size_t i = 0; i < weights.dimension(); ++i)
181  {
182  int val;
183  is >> val;
185  ++read_count;
186  }
187  weights.resetDimension(10);
188  for (size_t i = 0; i < weights.dimension(); ++i)
189  {
190  int val;
191  is >> val;
192  pawn_facing_weight[i] = val;
193  ++read_count;
194  }
195  weights.resetDimension(16);
196  for (size_t i = 0; i < weights.dimension(); ++i)
197  {
198  int val;
199  is >> val;
200  promotion37_weight[i] = val;
201  ++read_count;
202  }
203  weights.resetDimension(56);
204  for (size_t i = 0; i < weights.dimension(); ++i)
205  {
206  int val;
207  is >> val;
208  piecestand7_weight[i] = val;
209  ++read_count;
210  }
211  {
212  int val;
213  is >> val;
214  max_progress = val;
215  ++read_count;
216 #ifdef EVAL_QUAD
217  while (((max_progress/ProgressScale) % 3) && max_progress > 0)
218  --max_progress;
219 #endif
220  }
221  for(int king_x=1;king_x<=9;king_x++){
222  for(int king_y=1;king_y<=9;king_y++){
223  Square king(king_x,king_y);
224  int king_index=(king_x-1)*9+king_y-1;
225  const Square center = Centering5x3::adjustCenter(king);
226  const int min_x = center.x() - 2;
227  const int min_y = center.y() - 1;
228  int i=0;
229  for (int dx=0; dx<5; ++dx)
230  {
231  for (int dy=0; dy<3; ++dy,++i)
232  {
233  const Square target(min_x+dx,min_y+dy);
234  int index0=king_index*15+i;
235  int index_a=index0*10;
236  int index_d=index0*10;
237  attack_relative[index_a]=
238  effect_weight[index<BLACK>(king, target)] +
239  effect_x_weight[indexX<BLACK>(king, target)] +
240  effect_y_weight[indexY<BLACK>(king, target)];
241  defense_relative[index_d]=
242  effect_defense_weight[index<BLACK>(king, target)];
243  for(int count=0;count<=8;count++){
244  attack_relative[index_a+count+1]=
245  effect_per_effect[indexPerEffect<BLACK>(king, target, count)] +
246  effect_per_effect_y[indexPerEffectY<BLACK>(king, target, count)] +
247  effect_per_effect_x[indexPerEffectX<BLACK>(king, target, count)];
248  defense_relative[index_d+count+1]=
249  effect_per_effect_defense[indexPerEffect<BLACK>(king, target, count)];
250  }
251  }
252  }
253  }
254  }
255  for(int king_x=1;king_x<=5;king_x++)
256  for(int promoted=0;promoted<=4;promoted++)
257  for(int silver=0;silver<=4;silver++)
258  for(int gold=0;gold<=4;gold++)
259  for(int bishop=0;bishop<=2;bishop++)
260  for(int rook=0;rook<=2;rook++){
261  int index0=promoted + 5 * (silver + 5 * (gold + 5 * (bishop + 3 * rook)));
262  int index1=king_x - 1 + 5 * (promoted + 5 * (silver + 5 * (gold + 5 * (bishop + 3 * rook))));
263  attack5x5_x_weight[index1]+=attack5x5_weight[index0];
264  }
265  for (int i=0; i<PTYPE_SIZE*2*PTYPE_SIZE; ++i)
266  for (int j=i+1; j<PTYPE_SIZE*2*PTYPE_SIZE; ++j) {
269  }
270  // set sum of [1..i] into [i], keep [0] as is.
271  for (int i=2; i<10; ++i)
273 
274  initialized_flag = static_cast<bool>(is);
275  if (!initialized_flag)
276  {
277  std::cerr << "Failed to load NewProgress data " << read_count
278  << " from file " << filename << std::endl;
279  }
280  return initialized_flag;
281 }
282 
284 {
285  return setUp(defaultFilename().c_str());
286 }
287 
289 {
290  std::string filename = OslConfig::home();
291  filename += "/data/progress.txt";
292  return filename;
293 }
294 
295 template <osl::Player P>
297  const NumEffectState &state, int &attack, int &defense)
298 {
299  const Square king = state.kingSquare<P>();
300  const Square center = Centering5x3::adjustCenter(king);
301  const int min_x = center.x() - 2;
302  const int min_y = center.y() - 1;
303 
304  attack = defense = 0;
305  Square kingRel=king;
306  if(P==WHITE){
307  kingRel=kingRel.rotate180();
308  }
309  int index0=((kingRel.x()-1)*9+kingRel.y()-1)*15;
310  int index_a=index0*10 + (P==WHITE ? 10*14 : 0);
311  for (int dx=0; dx<5; ++dx)
312  {
313  for (int dy=0; dy<3; ++dy)
314  {
315  const Square target(min_x+dx,min_y+dy);
316  const int attack_count =
317  state.countEffect(alt(P), target);
318  const int defense_count =
319  state.countEffect(P, target);
320  attack += attack_count *attack_relative[index_a]+
321  attack_relative[index_a+std::min(attack_count,8)+1];
322  defense +=
323  defense_count * defense_relative[index_a]+
324  defense_relative[index_a+std::min(defense_count,8)+1];
325  if(P==BLACK){
326  index_a+=10;
327  }
328  else{
329  index_a-=10;
330  }
331  }
332  }
333 }
334 
335 template <osl::Player P>
337  const NumEffectState &state)
338 {
339  const Square king = state.kingSquare<P>();
340  const int min_x = std::max(1, king.x() - 2);
341  const int max_x = std::min(9, king.x() + 2);
342  const int min_y = std::max(1, king.y() - 2);
343  const int max_y = std::min(9, king.y() + 2);
344  effect_progresses[P] = 0;
345 
346  PieceMask mask;
347  for (int y = min_y; y <= max_y; ++y)
348  {
349  for (int x = min_x; x <= max_x; ++x)
350  {
351  const Square target(x, y);
352  const NumBitmapEffect effect = state.effectSetAt(target);
353  const int effect_diff =
354  effect.countEffect(alt(P)) - effect.countEffect(P);
355  const int x_diff = std::abs(x - king.x());
356  const int y_diff = (P == WHITE ? king.y() - y : y - king.y());
357  int index = std::max(std::min(effect_diff, 2), -2) + 2 + 5 * x_diff +
358  5 * 3 * (y_diff + 2);
359  effect_progresses[P] += effectstate_weight[index];
360  mask |= effect;
361  }
362  }
363  updateAttack5x5Pieces<P>(mask, state);
364 }
365 
366 template <osl::Player P>
368  PieceMask mask, const NumEffectState& state)
369 {
370  const Player attack = alt(P);
371  mask &= state.piecesOnBoard(attack);
372 
373  rook[attack] = mask.selectBit<ROOK>().countBit();
374  bishop[attack] = mask.selectBit<BISHOP>().countBit();
375  gold[attack] = mask.selectBit<GOLD>().countBit();
376  silver[attack] =
377  (mask & ~state.promotedPieces()).selectBit<SILVER>().countBit();
378  PieceMask promoted_pieces = mask & state.promotedPieces();
379  promoted_pieces.clearBit<ROOK>();
380  promoted_pieces.clearBit<BISHOP>();
381  promoted[attack] =
382  std::min(promoted_pieces.countBit(), 4);
383 }
384 
385 template <osl::Player P>
387  const NumEffectState &state) const
388 {
389  const Player attack = alt(P);
390  int king_x = state.kingSquare<P>().x();
391  if (king_x > 5)
392  king_x = 10 - king_x;
393  const int king_y = (P == BLACK ? state.kingSquare<P>().y() :
394  10 - state.kingSquare<P>().y());
395  return (attack5x5_x_weight[index5x5x(
396  rook[attack] + state.countPiecesOnStand<ROOK>(attack),
397  bishop[attack] + state.countPiecesOnStand<BISHOP>(attack),
398  gold[attack] + state.countPiecesOnStand<GOLD>(attack),
399  silver[attack] + state.countPiecesOnStand<SILVER>(attack),
400  promoted[attack], king_x)] +
401  attack5x5_y_weight[index5x5y(
402  rook[attack] + state.countPiecesOnStand<ROOK>(attack),
403  bishop[attack] + state.countPiecesOnStand<BISHOP>(attack),
404  gold[attack] + state.countPiecesOnStand<GOLD>(attack),
405  silver[attack] + state.countPiecesOnStand<SILVER>(attack),
406  promoted[attack], king_y)]);
407 }
408 
409 void
411  const NumEffectState &state)
412 {
413  const CArray<Square,2> kings = {{
414  state.kingSquare(BLACK),
415  state.kingSquare(WHITE),
416  }};
417  king_relative_attack.fill(0);
418  king_relative_defense.fill(0);
419  for (int i = 0; i < Piece::SIZE; ++i)
420  {
421  const Piece piece = state.pieceOf(i);
422  if (piece.ptype() == osl::KING || !piece.isOnBoard())
423  continue;
424  Player pl = piece.owner();
425  const int index_attack = indexRelative(piece.owner(), kings[alt(pl)],
426  piece);
427  const int index_defense = indexRelative(piece.owner(), kings[pl],
428  piece) + 2142;
429  king_relative_attack[pl] += king_relative_weight[index_attack];
430  king_relative_defense[pl] += king_relative_weight[index_defense];
431  }
432 }
433 
434 template <osl::Player Owner>
437 {
438  PieceMask attacked = state.effectedMask(alt(Owner)) & state.piecesOnBoard(Owner);
439  attacked.reset(state.kingPiece<Owner>().number());
440  mask_t ppawn = state.promotedPieces().getMask<PAWN>() & attacked.selectBit<PAWN>();
441  attacked.clearBit<PAWN>();
442  attacked.orMask(PtypeFuns<PAWN>::indexNum, ppawn);
443  PieceVector pieces;
444  while (attacked.any())
445  {
446  const Piece piece = state.pieceOf(attacked.takeOneBit());
447  pieces.push_back(piece);
448  }
449  typedef eval::ml::NonPawnAttackedPtypePair feature_t;
450  int result = 0;
451  MultiInt result_eval;
452  for (size_t i=0; i<pieces.size(); ++i) {
453  const int i0 = feature_t::index1(state, pieces[i]);
454  result += attacked_ptype_pair_weight[feature_t::index2(0,i0)];
455  for (size_t j=i+1; j<pieces.size(); ++j) {
456  const int i1 = feature_t::index1(state, pieces[j]);
457  result += attacked_ptype_pair_weight[feature_t::index2(i0,i1)];
458  if (Owner == BLACK)
459  result_eval += feature_t::table[feature_t::index2(i0, i1)];
460  else
461  result_eval -= feature_t::table[feature_t::index2(i0, i1)];
462  }
463  }
464  non_pawn_ptype_attacked_pair[Owner] = result;
465  non_pawn_ptype_attacked_pair_eval[Owner] = result_eval;
466 }
467 
470 {
471  updateNonPawnAttackedPtypePairOne<BLACK>(state);
472  updateNonPawnAttackedPtypePairOne<WHITE>(state);
473 }
474 
476 updatePawnFacing(const NumEffectState& state)
477 {
478  PieceMask attacked = state.effectedMask(WHITE) & state.piecesOnBoard(BLACK);
479  mask_t pawn = attacked.selectBit<PAWN>()
480  & ~(state.promotedPieces().getMask<PAWN>());
481  int count = 0;
482  while (pawn.any()) {
483  const Piece p(state.pieceOf(pawn.takeOneBit()+PtypeFuns<PAWN>::indexNum*32));
484  if (state.hasEffectByPtypeStrict<PAWN>(WHITE, p.square()))
485  ++count;
486  }
487  pawn_facing = pawn_facing_weight[count];
488 }
489 
490 template <osl::Player P>
492 NewProgress::promotion37One(const NumEffectState& state, int rank)
493 {
494  typedef eval::ml::Promotion37 feature_t;
495  CArray<int,PTYPE_SIZE> count = {{ 0 }};
496  for (int x=1; x<=9; ++x) {
497  const Square target(x, rank);
498  if (! state[target].isEmpty())
499  continue;
500  int a = state.countEffect(P, target);
501  const int d = state.countEffect(alt(P), target);
502  if (a > 0 && a == d)
503  a += AdditionalEffect::hasEffect(state, target, P);
504  if (a <= d)
505  continue;
506  const Ptype ptype = state.findCheapAttack(P, target).ptype();
507  if (isPiece(ptype) && ! isPromoted(ptype))
508  count[ptype]++;
509  }
510  for (int p=PTYPE_BASIC_MIN; p<=PTYPE_MAX; ++p) {
511  if (count[p] > 0) {
512  promotion37 += promotion37_weight[p];
513  promotion37_eval += feature_t::table[p]*sign(P);
514  }
515  if (count[p] > 1) {
516  promotion37 += promotion37_weight[p-8]*(count[p]-1);
517  promotion37_eval += feature_t::table[p-8]*(sign(P)*(count[p]-1));
518  }
519  }
520 }
521 
523 updatePromotion37(const NumEffectState& state)
524 {
525  promotion37 = 0;
526  promotion37_eval = MultiInt();
527  promotion37One<BLACK>(state, 3);
528  promotion37One<WHITE>(state, 7);
529 }
530 
532 updatePieceStand7(const NumEffectState& state)
533 {
534  piecestand7 = 0;
535  for (int z=0; z<2; ++z) {
536  CArray<int,7> stand = {{ 0 }};
537  int filled = 0;
538  for (Ptype ptype: PieceStand::order)
539  if (state.hasPieceOnStand(indexToPlayer(z), ptype))
540  stand[filled++] = ptype-PTYPE_BASIC_MIN;
541  for (int i=0; i<std::min(7,filled+1); ++i)
542  piecestand7 += piecestand7_weight[stand[i] + 8*i];
543  }
544 }
545 
547  const NumEffectState &state)
548 {
549  assert(initialized_flag);
550 
551  progressOne<BLACK>(state,
552  progresses[BLACK],
553  defenses[WHITE]);
554  progressOne<WHITE>(state,
555  progresses[WHITE],
556  defenses[BLACK]);
557  updateAttack5x5PiecesAndState<BLACK>(state);
558  updateAttack5x5PiecesAndState<WHITE>(state);
559  attack5x5_progresses[BLACK] =
560  attack5x5Value<BLACK>(state);
561  attack5x5_progresses[WHITE] =
562  attack5x5Value<WHITE>(state);
563  stand_progresses.fill(0);
564  for (Ptype ptype: PieceStand::order)
565  {
566  const int black_count =
567  state.countPiecesOnStand(BLACK, ptype);
568  const int white_count =
569  state.countPiecesOnStand(WHITE, ptype);
570  for (int j = 0; j < black_count; ++j)
571  {
572  stand_progresses[WHITE] +=
573  stand_weight[Ptype_Table.getIndexMin(ptype) + j];
574  }
575  for (int j = 0; j < white_count; ++j)
576  {
577  stand_progresses[BLACK] +=
578  stand_weight[Ptype_Table.getIndexMin(ptype) + j];
579  }
580  }
581  updatePieceKingRelativeBonus(state);
582  updateNonPawnAttackedPtypePair(state);
583  updatePawnFacing(state);
584  updatePromotion37(state);
585  updatePieceStand7(state);
586 }
587 
588 template<osl::Player P>
589 inline
591  const NumEffectState &new_state,
592  Move last_move)
593 {
594  const Player altP=alt(P);
595  assert(new_state.turn()==altP);
596  assert(last_move.player()==P);
597  const Square kb = new_state.kingSquare<BLACK>(), kw = new_state.kingSquare<WHITE>();
598  const BoardMask mb = new_state.changedEffects(BLACK), mw = new_state.changedEffects(WHITE);
599  const bool king_move = last_move.ptype() == KING;
600  if ((king_move && altP == BLACK) || mb.anyInRange(Board_Mask_Table5x3_Center.mask(kw)) || mw.anyInRange(Board_Mask_Table5x3_Center.mask(kw)))
601  {
602  progressOne<WHITE>(new_state,progresses[WHITE],defenses[BLACK]);
603  }
604  if ((king_move && altP == WHITE) || mw.anyInRange(Board_Mask_Table5x3_Center.mask(kb)) || mb.anyInRange(Board_Mask_Table5x3_Center.mask(kb)))
605  {
606  progressOne<BLACK>(new_state,progresses[BLACK],defenses[WHITE]);
607  }
608 
609  const Ptype captured = last_move.capturePtype();
610 
611  if (last_move.isDrop())
612  {
613  const int count =
614  new_state.countPiecesOnStand(P, last_move.ptype()) + 1;
615  const int value =
616  stand_weight[Ptype_Table.getIndexMin(last_move.ptype()) + count - 1];
617  stand_progresses[altP] -= value;
618  }
619  else if (captured != PTYPE_EMPTY)
620  {
621  Ptype ptype = unpromote(captured);
622  const int count = new_state.countPiecesOnStand(P, ptype);
623  const int value =
624  stand_weight[(Ptype_Table.getIndexMin(ptype) + count - 1)];
625  stand_progresses[altP] += value;
626  }
627 
628  if (king_move)
629  {
630  updatePieceKingRelativeBonus(new_state);
631  }
632  else
633  {
634  const CArray<Square,2> kings = {{
635  new_state.kingSquare(BLACK),
636  new_state.kingSquare(WHITE),
637  }};
638  if (!last_move.isDrop())
639  {
640  const int index_attack =
641  indexRelative<P>(kings[altP],
642  last_move.oldPtype(), last_move.from());
643  const int index_defense =
644  indexRelative<P>(kings[P],
645  last_move.oldPtype(), last_move.from()) + 2142;
646  king_relative_attack[P] -=
647  king_relative_weight[index_attack];
648  king_relative_defense[P] -=
649  king_relative_weight[index_defense];
650  }
651  {
652  const int index_attack =
653  indexRelative<P>(kings[altP],
654  last_move.ptype(), last_move.to());
655  const int index_defense =
656  indexRelative<P>(kings[P],
657  last_move.ptype(), last_move.to()) + 2142;
658  king_relative_attack[P] +=
659  king_relative_weight[index_attack];
660  king_relative_defense[P] +=
661  king_relative_weight[index_defense];
662  }
663  if (captured != PTYPE_EMPTY)
664  {
665  const int index_attack =
666  indexRelative<altP>(kings[P],
667  captured, last_move.to());
668  const int index_defense =
669  indexRelative<altP>(kings[altP],
670  captured, last_move.to()) + 2142;
671  king_relative_attack[altP] -=
672  king_relative_weight[index_attack];
673  king_relative_defense[altP] -=
674  king_relative_weight[index_defense];
675  }
676  }
677  updateNonPawnAttackedPtypePair(new_state);
678  updatePawnFacing(new_state);
679  updatePromotion37(new_state);
680  updatePieceStand7(new_state);
681 }
682 
683 template<osl::Player P>
685  const NumEffectState &new_state,
686  Move last_move)
687 {
688  const Player altP=alt(P);
689  assert(new_state.turn()==altP);
690  if (last_move.isPass())
691  return;
692  const Square kb = new_state.kingSquare<BLACK>(), kw = new_state.kingSquare<WHITE>();
693  const BoardMask mb = new_state.changedEffects(BLACK), mw = new_state.changedEffects(WHITE);
694  const bool king_move = last_move.ptype() == KING;
695  const Ptype captured = last_move.capturePtype();
696 
697  if ((king_move && altP == BLACK) ||
699  mw.anyInRange(Board_Mask_Table5x5.mask(kw)))
700  {
701  updateAttack5x5PiecesAndState<WHITE>(new_state);
702  attack5x5_progresses[WHITE] =
703  attack5x5Value<WHITE>(new_state);
704  }
705  else if (altP == WHITE &&(last_move.isDrop() || captured != PTYPE_EMPTY))
706  {
707  attack5x5_progresses[WHITE] =
708  attack5x5Value<WHITE>(new_state);
709  }
710  if ((king_move && altP == WHITE) ||
711  mw.anyInRange(Board_Mask_Table5x5.mask(kb)) ||
713  {
714  updateAttack5x5PiecesAndState<BLACK>(new_state);
715  attack5x5_progresses[BLACK] =
716  attack5x5Value<BLACK>(new_state);
717  }
718  else if (altP == BLACK && (last_move.isDrop() || captured != PTYPE_EMPTY))
719  {
720  attack5x5_progresses[BLACK] =
721  attack5x5Value<BLACK>(new_state);
722  }
723  updateMain<P>(new_state, last_move);
724 }
725 
727 {
729 
730  info.black_values[NewProgressDebugInfo::ATTACK_5X3] = progresses[0];
732  info.black_values[NewProgressDebugInfo::ATTACK5X5] = attack5x5_progresses[0];
733  info.black_values[NewProgressDebugInfo::STAND] = stand_progresses[0];
734  info.black_values[NewProgressDebugInfo::EFFECT5X5] = effect_progresses[0];
735  info.black_values[NewProgressDebugInfo::KING_RELATIVE_ATTACK] = king_relative_attack[0];
736  info.black_values[NewProgressDebugInfo::KING_RELATIVE_DEFENSE] = king_relative_defense[0];
737  info.black_values[NewProgressDebugInfo::NON_PAWN_ATTACKED_PAIR] = non_pawn_ptype_attacked_pair[0];
738 
739  info.white_values[NewProgressDebugInfo::ATTACK_5X3] = progresses[1];
741  info.white_values[NewProgressDebugInfo::ATTACK5X5] = attack5x5_progresses[1];
742  info.white_values[NewProgressDebugInfo::STAND] = stand_progresses[1];
743  info.white_values[NewProgressDebugInfo::EFFECT5X5] = effect_progresses[1];
744  info.white_values[NewProgressDebugInfo::KING_RELATIVE_ATTACK] = king_relative_attack[1];
745  info.white_values[NewProgressDebugInfo::KING_RELATIVE_DEFENSE] = king_relative_defense[1];
746  info.white_values[NewProgressDebugInfo::NON_PAWN_ATTACKED_PAIR] = non_pawn_ptype_attacked_pair[1];
747 
748  return info;
749 }
750 
751 namespace osl
752 {
753  namespace progress
754  {
755  namespace ml
756  {
757  template void osl::progress::ml::NewProgress::updateSub<osl::BLACK>(const NumEffectState &new_state,Move last_move);
758  template void osl::progress::ml::NewProgress::updateSub<osl::WHITE>(const NumEffectState &new_state,Move last_move);
759  }
760  }
761 }
762 
763 // ;;; Local Variables:
764 // ;;; mode:c++
765 // ;;; c-basic-offset:2
766 // ;;; End:
osl::PieceMask::selectBit
const mask_t selectBit() const
unpromote(PTYPE) の駒のbit だけ取り出す
Definition: pieceMask.h:66
osl::progress::ml::NewProgressDebugInfo::white_values
CArray< int, FEATURE_LIMIT > white_values
Definition: progress.h:62
osl::progress::ml::NewProgress::effectstate_weight
static CArray< int, 75 > effectstate_weight
Definition: progress.h:85
osl::Piece::number
int number() const
Definition: basic_type.h:828
osl::PieceMask::getMask
const mask_t getMask(int num) const
Definition: pieceMask.h:59
osl::effect_util::AdditionalEffect::hasEffect
static bool hasEffect(const NumEffectState &, Square target, Player attack)
target に attack の追加利きが一つでもあるか. 相手の影利きが先にある場合は対象としない.
Definition: additionalEffect.cc:5
osl::Square
Definition: basic_type.h:532
osl::container::PieceMask64::countBit
int countBit() const
Definition: pieceMask64.h:78
osl::NumEffectState::piecesOnBoard
const PieceMask & piecesOnBoard(Player p) const
Definition: numEffectState.h:63
osl::NumEffectState::findCheapAttack
const Piece findCheapAttack(Player P, Square square) const
Definition: numEffectState.h:560
osl::progress::ml::NewProgressData::king_relative_defense
CArray< int, 2 > king_relative_defense
Definition: progress.h:72
osl::PieceMask::reset
void reset(int num)
Definition: pieceMask.h:54
osl::progress::ml::NewProgressDebugInfo::ATTACK_5X3
@ ATTACK_5X3
Definition: progress.h:51
osl::eval::min
int min(Player p, int v1, int v2)
Definition: evalTraits.h:92
osl::container::QuadInt
Definition: quadInt.h:43
osl::FixedCapacityVector::size
size_t size() const
Definition: container.h:243
osl::WHITE
@ WHITE
Definition: basic_type.h:10
osl::progress::ml::NewProgress::updatePieceKingRelativeBonus
void updatePieceKingRelativeBonus(const NumEffectState &state)
Definition: progress.cc:410
centering5x3.h
osl::Piece::SIZE
static const int SIZE
Definition: basic_type.h:794
osl::eval::ml::NonPawnAttackedPtypePair::index2
static int index2(int i0, int i1)
Definition: minorPiece.h:1367
osl::progress::ml::NewProgress::promotion37One
void promotion37One(const NumEffectState &state, int rank)
Definition: progress.cc:492
osl::progress::ml::NewProgress::attack_relative
static CArray< int, 81 *15 *10 > attack_relative
Definition: progress.h:86
osl::progress::ml::NewProgress::attack5x5_y_weight
static CArray< int, 10125 > attack5x5_y_weight
Definition: progress.h:84
osl::alt
constexpr Player alt(Player player)
Definition: basic_type.h:13
osl::container::BoardMaskTable5x3Center::mask
const BoardMask & mask(Square p) const
p中心の5x3 の範囲のbitを立てたもの, centering
Definition: boardMask.h:133
osl::PTYPE_SIZE
const int PTYPE_SIZE
Definition: basic_type.h:107
osl::progress::ml::NewProgress::updateSub
void updateSub(const NumEffectState &new_state, Move last_move)
Definition: progress.cc:684
osl::Centering5x3::adjustCenter
static const Square adjustCenter(Square src)
Definition: centering5x3.h:23
osl::NumEffectState::effectSetAt
const NumBitmapEffect effectSetAt(Square sq) const
Definition: numEffectState.h:258
weights.h
osl::progress::ml::NewProgressData::promoted
CArray< int, 2 > promoted
Definition: progress.h:71
osl::PtypeFuns
Definition: ptypeTraits.h:311
osl::progress::ml::NewProgressData::bishop
CArray< int, 2 > bishop
Definition: progress.h:71
osl::progress::ml::NewProgressDebugInfo::NON_PAWN_ATTACKED_PAIR
@ NON_PAWN_ATTACKED_PAIR
Definition: progress.h:58
osl::Move
圧縮していない moveの表現 .
Definition: basic_type.h:1052
osl::progress::ml::NewProgress::updatePromotion37
void updatePromotion37(const NumEffectState &state)
Definition: progress.cc:523
osl::progress::ml::NewProgress::NewProgress
NewProgress(const NumEffectState &state)
Definition: progress.cc:546
osl::eval::ml::Weights
Definition: weights.h:18
osl::progress::ml::NewProgress::updateAttack5x5Pieces
void updateAttack5x5Pieces(PieceMask, const NumEffectState &)
Definition: progress.cc:367
osl::progress::ml::NewProgress::promotion37_weight
static CArray< int, 16 > promotion37_weight
Definition: progress.h:91
osl::progress::ml::NewProgressDebugInfo::DEFENSE_5X3
@ DEFENSE_5X3
Definition: progress.h:52
osl::progress::ml::NewProgressData::effect_progresses
CArray< int, 2 > effect_progresses
Definition: progress.h:70
osl::progress::ml::NewProgress::pawn_facing_weight
static CArray< int, 10 > pawn_facing_weight
Definition: progress.h:90
osl::NumEffectState::effectedMask
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
Definition: numEffectState.h:130
osl::misc::mask_t
GeneralMask< mask_int_t > mask_t
Definition: mask.h:351
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::progress::ml::NewProgressData::stand_progresses
CArray< int, 2 > stand_progresses
Definition: progress.h:69
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition: tables.cc:97
osl::Piece
駒.
Definition: basic_type.h:788
osl::progress::ml::NewProgress::stand_weight
static CArray< int, Piece::SIZE > stand_weight
Definition: progress.h:81
osl::GOLD
@ GOLD
Definition: basic_type.h:94
osl::eval::max
int max(Player p, int v1, int v2)
Definition: evalTraits.h:84
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition: simpleState.h:76
osl::eval::ml::Promotion37
Definition: minorPiece.h:1724
osl::Move::oldPtype
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
Definition: basic_type.h:1174
osl::progress::ml::NewProgress::debugInfo
NewProgressDebugInfo debugInfo() const
Definition: progress.cc:726
osl::eval::ml::Weights::resetDimension
void resetDimension(size_t new_dim)
Definition: weights.cc:26
osl::PTYPE_MAX
@ PTYPE_MAX
Definition: basic_type.h:105
osl::KING
@ KING
Definition: basic_type.h:93
osl::container::BoardMaskTable5x5::mask
const BoardMask & mask(Square p) const
p中心の5x5 の範囲のbitを立てたもの, centeringなし
Definition: boardMask.h:113
osl::progress::ml::operator==
bool operator==(const NewProgressData &l, const NewProgressData &r)
Definition: progress.cc:12
osl::progress::ml::NewProgressDebugInfo::KING_RELATIVE_ATTACK
@ KING_RELATIVE_ATTACK
Definition: progress.h:56
osl::NumEffectState::hasEffectByPtypeStrict
bool hasEffectByPtypeStrict(Player attack, Square target) const
target に ptype の利きがあるか? 成不成を区別
Definition: numEffectState.h:363
osl::PtypeTable::getIndexMin
int getIndexMin(Ptype ptype) const
Definition: ptypeTable.h:88
osl::BISHOP
@ BISHOP
Definition: basic_type.h:99
osl::container::PieceMask64::takeOneBit
int takeOneBit()
Definition: pieceMask64.h:82
osl::Move::capturePtype
Ptype capturePtype() const
Definition: basic_type.h:1180
midgame.h
osl::Move::isDrop
bool isDrop() const
Definition: basic_type.h:1150
osl::PAWN
@ PAWN
Definition: basic_type.h:95
osl::progress::ml::NewProgress::attacked_ptype_pair_weight
static CArray< int, 262144 > attacked_ptype_pair_weight
Definition: progress.h:89
osl::indexToPlayer
constexpr Player indexToPlayer(int n)
Definition: basic_type.h:19
osl::progress::ml::NewProgress::updatePieceStand7
void updatePieceStand7(const NumEffectState &state)
Definition: progress.cc:532
osl::progress::ml::NewProgress::attack5x5Value
int attack5x5Value(const NumEffectState &state) const
Definition: progress.cc:386
osl::progress::ml::NewProgressData::rook
CArray< int, 2 > rook
Definition: progress.h:71
osl::progress::ml::NewProgress::updatePawnFacing
void updatePawnFacing(const NumEffectState &state)
Definition: progress.cc:476
osl::PieceVector
Definition: container.h:305
osl::progress::ml::NewProgressData::non_pawn_ptype_attacked_pair_eval
CArray< MultiInt, 2 > non_pawn_ptype_attacked_pair_eval
Definition: progress.h:67
osl::progress::ml::NewProgress::max_progress
static int max_progress
Definition: progress.h:93
osl::progress::ml::NewProgress::updateMain
void updateMain(const NumEffectState &new_state, Move last_move)
Definition: progress.cc:590
osl::OslConfig::home
static const std::string & home(const std::string &initialize_if_first_invocation="")
compile時に指定されたディレクトリを返す.
Definition: oslConfig.cc:239
oslConfig.h
osl::NumEffectState::promotedPieces
const PieceMask promotedPieces() const
Definition: numEffectState.h:64
osl::progress::ml::NewProgress::updateAttack5x5PiecesAndState
void updateAttack5x5PiecesAndState(const NumEffectState &state)
Definition: progress.cc:336
minorPiece.h
osl::Piece::owner
Player owner() const
Definition: basic_type.h:963
osl::progress::ml::NewProgressData::non_pawn_ptype_attacked_pair
CArray< int, 2 > non_pawn_ptype_attacked_pair
Definition: progress.h:72
osl::Move::from
const Square from() const
Definition: basic_type.h:1125
osl::progress::ml::NewProgressDebugInfo
Definition: progress.h:48
osl::PieceStand::order
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
Definition: bits/pieceStand.h:41
osl::progress::ml::NewProgress::defense_relative
static CArray< int, 81 *15 *10 > defense_relative
Definition: progress.h:87
osl::SimpleState::hasPieceOnStand
bool hasPieceOnStand(Player player, Ptype ptype) const
Definition: simpleState.h:191
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition: basic_type.h:563
osl::captured
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
Definition: basic_type.h:264
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
osl::progress::ml::NewProgress::defaultFilename
static std::string defaultFilename()
Definition: progress.cc:288
osl::progress::ml::NewProgressData::attack5x5_progresses
CArray< int, 2 > attack5x5_progresses
Definition: progress.h:69
osl::progress::ml::NewProgressData
Definition: progress.h:66
osl::ROOK
@ ROOK
Definition: basic_type.h:100
osl::progress::ml::NewProgressData::king_relative_attack
CArray< int, 2 > king_relative_attack
Definition: progress.h:72
osl::PieceMask::orMask
void orMask(int index, mask_t val)
Definition: pieceMask.h:42
additionalEffect.h
osl::effect::NumBitmapEffect
現在の定義 (2005/3/4以降)
Definition: numBitmapEffect.h:29
osl::isPiece
constexpr bool isPiece(Ptype ptype)
ptypeが空白やEDGEでないかのチェック
Definition: basic_type.h:120
osl::SimpleState::kingSquare
Square kingSquare() const
Definition: simpleState.h:94
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition: basic_type.h:567
osl::sign
constexpr int sign(Player player)
Definition: basic_type.h:23
osl::progress::ml::NewProgress::king_relative_weight
static CArray< int, 4284 > king_relative_weight
Definition: progress.h:88
osl::isPromoted
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
Definition: basic_type.h:137
osl::MultiInt
QuadInt MultiInt
Definition: midgame.h:13
osl::container::BoardMask::anyInRange
bool anyInRange(const BoardMask &mask) const
Definition: boardMask.h:57
osl::Piece::square
const Square square() const
Definition: basic_type.h:832
osl::progress::ml::NewProgress::attack5x5_weight
static CArray< int, 1125 > attack5x5_weight
Definition: progress.h:82
osl::PieceMask::any
bool any() const
Definition: pieceMask.h:57
osl::progress::ml::NewProgressDebugInfo::EFFECT5X5
@ EFFECT5X5
Definition: progress.h:55
osl::Piece::ptype
Ptype ptype() const
Definition: basic_type.h:821
progress.h
osl::progress::ml::NewProgressData::defenses
CArray< int, 2 > defenses
Definition: progress.h:70
osl::effect::NumBitmapEffect::countEffect
int countEffect(Player pl) const
Definition: numBitmapEffect.h:81
osl::Move::isPass
bool isPass() const
Definition: basic_type.h:1092
osl::progress::ml::NewProgress::updateNonPawnAttackedPtypePairOne
void updateNonPawnAttackedPtypePairOne(const NumEffectState &state)
Definition: progress.cc:436
osl::Move::ptype
Ptype ptype() const
Definition: basic_type.h:1155
osl::BLACK
@ BLACK
Definition: basic_type.h:9
osl::progress::ml::NewProgress::initialized_flag
static bool initialized_flag
Definition: progress.h:80
osl::progress::ml::NewProgress::setUp
static bool setUp()
Definition: progress.cc:283
osl::progress::ml::NewProgressData::silver
CArray< int, 2 > silver
Definition: progress.h:71
osl::container::Board_Mask_Table5x5
const BoardMaskTable5x5 Board_Mask_Table5x5
Definition: tables.cc:119
osl::PTYPE_BASIC_MIN
@ PTYPE_BASIC_MIN
Definition: basic_type.h:103
osl::NumEffectState::changedEffects
const BoardMask changedEffects(Player pl) const
Definition: numEffectState.h:144
osl::progress::ml::NewProgress::piecestand7_weight
static CArray< int, 56 > piecestand7_weight
Definition: progress.h:92
osl::SimpleState::kingPiece
const Piece kingPiece() const
Definition: simpleState.h:83
osl::SILVER
@ SILVER
Definition: basic_type.h:98
osl::progress::ml::NewProgressDebugInfo::black_values
CArray< int, FEATURE_LIMIT > black_values
Definition: progress.h:61
osl::Square::rotate180
const Square rotate180() const
Definition: basic_type.h:613
osl::progress::ml::NewProgress::progressOne
static void progressOne(const NumEffectState &state, int &attack, int &defense)
Definition: progress.cc:296
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition: basic_type.h:85
osl::SimpleState::turn
Player turn() const
Definition: simpleState.h:220
osl::progress::ml::NewProgressData::progresses
CArray< int, 2 > progresses
Definition: progress.h:69
osl::progress::ml::NewProgressDebugInfo::STAND
@ STAND
Definition: progress.h:54
osl::Player
Player
Definition: basic_type.h:8
osl::progress::ml::NewProgressData::gold
CArray< int, 2 > gold
Definition: progress.h:71
osl::progress::ml::NewProgressDebugInfo::ATTACK5X5
@ ATTACK5X5
Definition: progress.h:53
osl::eval::ml::NonPawnAttackedPtypePair
Definition: minorPiece.h:1348
osl::CArray< int, 81 *15 *10 >
osl::Move::to
const Square to() const
Definition: basic_type.h:1132
osl::progress::ml::NewProgress::ProgressScale
@ ProgressScale
Definition: progress.h:78
osl::progress::ml::NewProgressDebugInfo::KING_RELATIVE_DEFENSE
@ KING_RELATIVE_DEFENSE
Definition: progress.h:57
osl::container::BoardMask
11 x 12
Definition: boardMask.h:21
osl::progress::ml::NewProgress::updateNonPawnAttackedPtypePair
void updateNonPawnAttackedPtypePair(const NumEffectState &state)
Definition: progress.cc:469
osl::PieceMask
駒番号のビットセット.
Definition: pieceMask.h:21
osl::Piece::isOnBoard
bool isOnBoard() const
Definition: basic_type.h:985
osl::NumEffectState::countEffect
int countEffect(Player player, Square target) const
利きの数を数える.
Definition: numEffectState.h:266
osl::eval::ml::Weights::dimension
size_t dimension() const
Definition: weights.h:29
osl::PieceMask::clearBit
void clearBit()
unpromote(PTYPE) の駒のbit を消す
Definition: pieceMask.h:74
osl::FixedCapacityVector::push_back
void push_back(const T &e)
Definition: container.h:204
osl::SimpleState::countPiecesOnStand
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
Definition: simpleState.h:182
osl::container::Board_Mask_Table5x3_Center
const BoardMaskTable5x3Center Board_Mask_Table5x3_Center
Definition: tables.cc:121
osl::Move::player
Player player() const
Definition: basic_type.h:1195
osl::progress::ml::NewProgress::attack5x5_x_weight
static CArray< int, 5625 > attack5x5_x_weight
Definition: progress.h:83
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition: basic_type.h:157
osl
Definition: additionalEffect.h:6