My Project
openMidEndingEval.cc
Go to the documentation of this file.
7#include "osl/eval/mobility.h"
9#include "osl/eval/pin.h"
10#include "osl/eval/king8.h"
11#include "osl/eval/progress.h"
12#include "osl/random.h"
13#include "osl/bits/binaryIO.h"
14#include "osl/bits/pieceStand.h"
15#include "osl/oslConfig.h"
16
17#include <fstream>
18
21{
22 const CArray<int, PTYPE_SIZE> values = {{
23 0, 0,
24 583, 493, 491, 467, 1279, 1351,
26 128, 318, 361, 540, 959, 1059
27 }};
28 reset(values);
29}
30#ifndef MINIMAL
31const char * osl::eval::ml::
33{
35 "PIECE",
36 "BISHOP_EXCHANGE_SILVER_KING",
37 "ENTER_KING_DEFENSE",
38 "KING25_EFFECT_ATTACK",
39 "PIECE_PAIR",
40 "PIECE_PAIR_KING",
41 }};
42 return table[f];
43}
44const char *osl::eval::ml::
46{
47 static const CArray<const char *,STAGE_FEATURE_LIMIT> table = {{
48 "KING_PIECE_RELATIVE",
49 "PIECE_STAND",
50 "KING25_EFFECT_EACH",
51 "PTYPEX",
52 "PTYPEY",
53 "ROOK_MOBILITY",
54 "BISHOP_MOBILITY",
55 "LANCE_MOBILITY",
56 "ROOK_EFFECT",
57 "BISHOP_EFFECT",
58 "PIECE_STAND_COMBINATION",
59 "PIECE_STAND_TURN",
60 "ROOK_PAWN",
61 "PAWN_DROP",
62 "PIECE_STAND_Y",
63 "KNIGHT_CHECK",
64 "PAWN_ADVANCE",
65 "PAWN_PTYPEO",
66 "PROMOTED_MINOR_PIECE",
67 "KING_PIECE_RELATIVE_NOSUPPORT",
68 "NON_PAWN_ATTACKED",
69 "NON_PAWN_ATTACKED_PTYPE",
70 "PTYPE_YY",
71 "KING3PIECES",
72 "BISHOP_HEAD",
73 "KNIGHT_HEAD",
74 "ROOK_PROMOTE_DEFENSE",
75 "PTYPE_COUNT",
76 "LANCE_EFFECT_PIECE",
77 "PTYPE_Y_PAWN_Y",
78 "BISHOP_AND_KING",
79 "PIECE_FORK_TURN",
80 "ROOK_SILVER_KNIGHT",
81 "BISHOP_SILVER_KNIGHT",
82 "KING25_EFFECT_SUPPORTED",
83 "KING_ROOK_BISHOP",
84 "KING_X_BLOCKED3",
85 "GOLD_RETREAT",
86 "SILVER_RETREAT",
87 "ALL_GOLD",
88 "ALL_MAJOR",
89 "KING25_EFFECT_DEFENSE",
90 "ANAGUMA_EMPTY",
91 "NO_PAWN_ON_STAND",
92 "NON_PAWN_PIECE_STAND",
93 "PIN_PTYPE_ALL",
94 "KING_MOBILITY",
95 "GOLD_AND_SILVER_NEAR_KING",
96 "PTYPE_COMBINATION",
97 "KING25_BOTH_SIDE",
98 "KING25_MOBILITY",
99 "BISHOP_STAND_FILE5",
100 "MAJOR_CHECK_WITH_CAPTURE",
101 "SILVER_ADVANCE26",
102 "KING25_EFFECT3",
103 "BISHOP_BISHOP_PIECE",
104 "ROOK_ROOK",
105 "ROOK_ROOK_PIECE",
106 "KING25_EFFECT_COUNT_COMBINATION",
107 "NON_PAWN_ATTACKED_PTYPE_PAIR",
108 "ATTACK_MAJORS_IN_BASE",
109 }};
110 return table[f];
111}
112#endif
113
116static std::mutex initialize_mutex;
119namespace
120{
121#ifndef MINIMAL
122 template <class Eval>
123 static void setRandomOne()
124 {
125 osl::eval::ml::Weights weights(Eval::DIM);
126 for (size_t i = 0; i < weights.dimension(); ++i)
127 {
128 weights.setValue(i, (osl::misc::random() % 1024)-512);
129 }
130 Eval::setUp(weights);
131 }
132 template <class Eval>
133 static void setRandomOne(int stage)
134 {
135 osl::eval::ml::Weights weights(Eval::DIM);
136 for (size_t i = 0; i < weights.dimension(); ++i)
137 {
138 weights.setValue(i, (osl::misc::random() % 1024)-512);
139 }
140 Eval::setUp(weights, stage);
141 }
142#endif
143 template <class Eval, class Reader>
144 static int setUpOneWithDim(Reader& p, int dim)
145 {
146 osl::eval::ml::Weights weights(dim);
147 // std::cerr << typeid(Eval).name() << " " << dim << "\n";
148 for (size_t i = 0; i < weights.dimension(); ++i)
149 {
150 if (! p.hasNext())
151 break;
152 int val = p.read();
153 weights.setValue(i, val);
154 }
155 Eval::setUp(weights);
156 return weights.dimension();
157 }
158 template <class Eval, class Reader>
159 static int setUpOne(Reader& p)
160 {
161 return setUpOneWithDim<Eval>(p, Eval::DIM);
162 }
163 template <class Eval, class Reader>
164 static int setUpOne(Reader& p, int stage)
165 {
166 osl::eval::ml::Weights weights(Eval::DIM);
167 // std::cerr << typeid(Eval).name() << " " << Eval::DIM << "\n";
168 for (size_t i = 0; i < weights.dimension(); ++i)
169 {
170 if (!p.hasNext())
171 break;
172 int val = p.read();
173 weights.setValue(i, val);
174 }
175 Eval::setUp(weights,stage);
176 return weights.dimension();
177 }
178}
179
180namespace osl
181{
183 {
184 size_t cur, length;
185 const int *array;
186 IntArrayReader(const int *a, size_t l) : cur(0), length(l), array(a)
187 {
188 }
189 bool hasNext() const { return cur < length; }
190 bool failed() const { return false; }
191 int read() { return array[cur++]; }
192 };
193}
194
196OpenMidEndingEval::resetWeights(const int *w, size_t length)
197{
198 IntArrayReader reader(w, length);
199 doResetWeights(reader);
200}
201
203{
204 std::lock_guard<std::mutex> lk(initialize_mutex);
205 if (initialized_flag == Loaded)
206 return true;
208 std::ifstream is(filename, std::ios_base::binary);
209 reader_t reader(is);
210 if (! reader.hasNext()) {
211 initialized_flag = Zero;
212 std::cerr << "file " << filename << std::endl;
213 return false;
214 }
215 doResetWeights(reader);
216 return initialized_flag == Loaded;
217}
218
219template <class Reader>
222{
223 size_t read_count = 0;
224
225 // flat
226 CArray<int, PTYPE_SIZE> piece_values = {{0}};
227 Weights weights(PTYPE_SIZE);
228 for (int i = 0; i < PTYPE_SIZE; ++i)
229 {
230 if (! reader.hasNext())
231 break;
232 int val = reader.read();
233 if (i == KING) {
234 assert(val == 0);
236 }
237 weights.setValue(i, val);
238 piece_values[i] = val;
239 ++read_count;
240 }
241 PieceEval::setUp(weights);
242 Piece_Value.reset(piece_values);
243
245 piece_pair_weights.resetDimension(PiecePair::DIM);
246 for (size_t i = 0; i < piece_pair_weights.dimension(); ++i)
247 {
248 if (! reader.hasNext())
249 break;
250 int val = reader.read();
251 piece_pair_weights.setValue(i, val);
252 ++read_count;
253 }
254 PiecePair::sanitize(piece_pair_weights);
255 PiecePair::compile(piece_pair_weights);
256
257 read_count += setUpOne<King25EffectAttack>(reader);
258 read_count += setUpOne<King25EffectYAttack>(reader);
259 read_count += setUpOne<PiecePairKing>(reader);
260 read_count += setUpOne<BishopExchangeSilverKing>(reader);
261 read_count += setUpOne<EnterKingDefense>(reader);
262
263 // opening
264 read_count += setUpOne<PieceStand>(reader,0);
265 read_count += setUpOne<King25EffectEachBothOpening>(reader);
266 read_count += setUpOne<PawnDrop>(reader,0);
267 read_count += setUpOne<NoPawnOnStand>(reader,0);
268 read_count += setUpOne<GoldRetreat>(reader,0);
269 read_count += setUpOne<SilverRetreat>(reader,0);
270 read_count += setUpOne<KnightAdvance>(reader,0);
271 read_count += setUpOne<AllMajor>(reader,0);
272 read_count += setUpOne<KingXBlocked>(reader,0);
273 read_count += setUpOne<KingXBlockedY>(reader,0);
274 read_count += setUpOne<AllGold>(reader,0);
275 read_count += setUpOne<PtypeX>(reader,0);
276 read_count += setUpOne<PtypeY>(reader,0);
277 read_count += setUpOne<AnagumaEmpty>(reader,0);
278 read_count += setUpOne<NonPawnPieceStand>(reader,0);
279 read_count += setUpOne<King25EffectDefense>(reader,0);
280 read_count += setUpOne<King25EffectYDefense>(reader,0);
281 read_count += setUpOne<RookMobility>(reader,0);
282 read_count += setUpOne<BishopMobility>(reader,0);
283 read_count += setUpOne<LanceMobility>(reader,0);
284 read_count += setUpOne<RookEffect>(reader,0);
285 read_count += setUpOne<BishopEffect>(reader,0);
286 read_count += setUpOne<PawnAdvance>(reader,0);
287 read_count += setUpOne<PawnDropY>(reader,0);
288 read_count += setUpOne<KnightCheck>(reader,0);
289
290 // midgame
291 read_count += setUpOne<PieceStand>(reader,1);
292 read_count += setUpOne<King25EffectEachBothMidgame>(reader);
293 read_count += setUpOne<PawnDrop>(reader,1);
294 read_count += setUpOne<NoPawnOnStand>(reader,1);
295 read_count += setUpOne<GoldRetreat>(reader,1);
296 read_count += setUpOne<SilverRetreat>(reader,1);
297 read_count += setUpOne<KnightAdvance>(reader,1);
298 read_count += setUpOne<AllMajor>(reader,1);
299 read_count += setUpOne<KingXBlocked>(reader,1);
300 read_count += setUpOne<KingXBlockedY>(reader,1);
301 read_count += setUpOne<AllGold>(reader,1);
302 read_count += setUpOne<PtypeX>(reader,1);
303 read_count += setUpOne<PtypeY>(reader,1);
304 read_count += setUpOne<AnagumaEmpty>(reader,1);
305 read_count += setUpOne<NonPawnPieceStand>(reader,1);
306 read_count += setUpOne<King25EffectDefense>(reader,1);
307 read_count += setUpOne<King25EffectYDefense>(reader,1);
308 read_count += setUpOne<RookMobility>(reader,1);
309 read_count += setUpOne<BishopMobility>(reader,1);
310 read_count += setUpOne<LanceMobility>(reader,1);
311 read_count += setUpOne<RookEffect>(reader,1);
312 read_count += setUpOne<BishopEffect>(reader,1);
313 read_count += setUpOne<PawnAdvance>(reader,1);
314 read_count += setUpOne<PawnDropY>(reader,1);
315 read_count += setUpOne<KnightCheck>(reader,1);
316
317#ifdef EVAL_QUAD
318 // midgame2
319 read_count += setUpOne<PieceStand>(reader,2);
320 read_count += setUpOne<King25EffectEachBothMidgame2>(reader);
321 read_count += setUpOne<PawnDrop>(reader,2);
322 read_count += setUpOne<NoPawnOnStand>(reader,2);
323 read_count += setUpOne<GoldRetreat>(reader,2);
324 read_count += setUpOne<SilverRetreat>(reader,2);
325 read_count += setUpOne<KnightAdvance>(reader,2);
326 read_count += setUpOne<AllMajor>(reader,2);
327 read_count += setUpOne<KingXBlocked>(reader,2);
328 read_count += setUpOne<KingXBlockedY>(reader,2);
329 read_count += setUpOne<AllGold>(reader,2);
330 read_count += setUpOne<PtypeX>(reader,2);
331 read_count += setUpOne<PtypeY>(reader,2);
332 read_count += setUpOne<AnagumaEmpty>(reader,2);
333 read_count += setUpOne<NonPawnPieceStand>(reader,2);
334 read_count += setUpOne<King25EffectDefense>(reader,2);
335 read_count += setUpOne<King25EffectYDefense>(reader,2);
336 read_count += setUpOne<RookMobility>(reader,2);
337 read_count += setUpOne<BishopMobility>(reader,2);
338 read_count += setUpOne<LanceMobility>(reader,2);
339 read_count += setUpOne<RookEffect>(reader,2);
340 read_count += setUpOne<BishopEffect>(reader,2);
341 read_count += setUpOne<PawnAdvance>(reader,2);
342 read_count += setUpOne<PawnDropY>(reader,2);
343 read_count += setUpOne<KnightCheck>(reader,2);
344#endif
345
346 // endgame
347 read_count += setUpOne<PieceStand>(reader,EndgameIndex);
348 read_count += setUpOne<King25EffectEachBothEnding>(reader);
349 read_count += setUpOne<PawnDrop>(reader,EndgameIndex);
350 read_count += setUpOne<NoPawnOnStand>(reader,EndgameIndex);
351 read_count += setUpOne<GoldRetreat>(reader,EndgameIndex);
352 read_count += setUpOne<SilverRetreat>(reader,EndgameIndex);
353 read_count += setUpOne<KnightAdvance>(reader,EndgameIndex);
354 read_count += setUpOne<AllMajor>(reader,EndgameIndex);
355 read_count += setUpOne<KingXBlocked>(reader,EndgameIndex);
356 read_count += setUpOne<KingXBlockedY>(reader,EndgameIndex);
357 read_count += setUpOne<AllGold>(reader,EndgameIndex);
358 read_count += setUpOne<PtypeX>(reader,EndgameIndex);
359 read_count += setUpOne<PtypeY>(reader,EndgameIndex);
360 read_count += setUpOne<AnagumaEmpty>(reader,EndgameIndex);
361 read_count += setUpOne<NonPawnPieceStand>(reader,EndgameIndex);
362 read_count += setUpOne<King25EffectDefense>(reader,EndgameIndex);
363 read_count += setUpOne<King25EffectYDefense>(reader,EndgameIndex);
364 read_count += setUpOne<RookMobility>(reader,EndgameIndex);
365 read_count += setUpOne<BishopMobility>(reader,EndgameIndex);
366 read_count += setUpOne<LanceMobility>(reader,EndgameIndex);
367 read_count += setUpOne<RookEffect>(reader,EndgameIndex);
368 read_count += setUpOne<BishopEffect>(reader,EndgameIndex);
369 read_count += setUpOne<PawnAdvance>(reader,EndgameIndex);
370 read_count += setUpOne<PawnDropY>(reader,EndgameIndex);
371 read_count += setUpOne<KnightCheck>(reader,EndgameIndex);
372
373 // triple
374 read_count += setUpOne<KingPieceRelative>(reader,0);
375 read_count += setUpOne<KingPieceRelative>(reader,1);
376#ifdef EVAL_QUAD
377 read_count += setUpOne<KingPieceRelative>(reader,2);
378#endif
379 read_count += setUpOne<KingPieceRelative>(reader,EndgameIndex);
380 read_count += setUpOne<NonPawnPieceStandTurn>(reader);
381 read_count += setUpOne<King25EffectEachXY>(reader);
382 read_count += setUpOne<RookPawnY>(reader);
383 read_count += setUpOne<RookEffectPiece>(reader);
384 read_count += setUpOne<BishopEffectPiece>(reader);
385 read_count += setUpOne<PieceStandY>(reader);
386 read_count += setUpOne<RookEffectPieceKingRelative>(reader);
387 read_count += setUpOne<BishopEffectPieceKingRelative>(reader);
388 read_count += setUpOne<RookPawnYX>(reader);
389 read_count += setUpOne<PawnPtypeOPtypeO>(reader);
390 read_count += setUpOne<PromotedMinorPieces>(reader);
391 read_count += setUpOne<KingPieceRelativeNoSupport>(reader);
392 read_count += setUpOne<NonPawnAttacked>(reader);
393 read_count += setUpOne<PtypeYY>(reader);
394 read_count += setUpOne<PawnPtypeOPtypeOY>(reader);
395 read_count += setUpOne<PawnDropX>(reader);
396 read_count += setUpOne<King3Pieces>(reader);
397 read_count += setUpOne<King3PiecesXY>(reader);
398 read_count += setUpOne<King25EffectEachKXY>(reader);
399 read_count += setUpOne<BishopHead>(reader);
400 read_count += setUpOne<BishopHeadKingRelative>(reader);
401 read_count += setUpOne<KnightCheckY>(reader);
402 read_count += setUpOne<KnightHead>(reader);
403 read_count += setUpOne<RookPromoteDefense>(reader);
404 read_count += setUpOne<PawnDropPawnStand>(reader);
405 read_count += setUpOne<PawnDropPawnStandX>(reader);
406 read_count += setUpOne<PawnDropPawnStandY>(reader);
407 read_count += setUpOne<KnightHeadOppPiecePawnOnStand>(reader);
408 read_count += setUpOne<KingXBothBlocked>(reader);
409 read_count += setUpOne<KingXBothBlockedY>(reader);
410 read_count += setUpOne<KingRookBishop>(reader);
411 read_count += setUpOne<PromotedMinorPiecesY>(reader);
412 read_count += setUpOne<King25EffectSupported>(reader);
413 read_count += setUpOne<King25EffectSupportedY>(reader);
414 read_count += setUpOne<NonPawnAttackedKingRelative>(reader);
415 read_count += setUpOne<NonPawnAttackedPtype>(reader);
416 read_count += setUpOne<PtypeCount>(reader);
417 read_count += setUpOne<KingXBlocked3>(reader);
418 read_count += setUpOne<KingXBlocked3Y>(reader);
419 read_count += setUpOne<PtypeCountXY>(reader);
420 read_count += setUpOne<PtypeCountXYAttack>(reader);
421 read_count += setUpOne<LanceEffectPieceKingRelative>(reader);
422 read_count += setUpOne<KingMobility>(reader);
423 read_count += setUpOne<KingMobilitySum>(reader);
424 read_count += setUpOne<PtypeYPawnY>(reader);
425 read_count += setUpOne<GoldAndSilverNearKing>(reader);
426 read_count += setUpOne<PtypeCombination>(reader);
427 read_count += setUpOne<PieceStandCombinationBoth>(reader);
428 read_count += setUpOne<King25BothSide>(reader);
429 read_count += setUpOne<King25BothSideX>(reader);
430 read_count += setUpOne<King25BothSideY>(reader);
431 read_count += setUpOne<GoldAndSilverNearKingCombination>(reader);
432 read_count += setUpOne<KingMobilityWithRook>(reader);
433 read_count += setUpOne<KingMobilityWithBishop>(reader);
434 read_count += setUpOne<NumPiecesBetweenBishopAndKingSelf>(reader);
435 read_count += setUpOne<NumPiecesBetweenBishopAndKingOpp>(reader);
436 read_count += setUpOne<NumPiecesBetweenBishopAndKingAll>(reader);
437 read_count += setUpOne<King25Effect3>(reader);
438 read_count += setUpOne<SilverHeadPawnKingRelative>(reader);
439 read_count += setUpOne<GoldKnightKingRelative>(reader);
440 read_count += setUpOne<RookMobilitySum>(reader);
441 read_count += setUpOne<RookMobilityX>(reader);
442 read_count += setUpOne<RookMobilityY>(reader);
443 read_count += setUpOne<RookMobilitySumKingX>(reader);
444 read_count += setUpOne<RookMobilityXKingX>(reader);
445 read_count += setUpOne<PinPtype>(reader);
446 read_count += setUpOne<PinPtypeDistance>(reader);
447 read_count += setUpOne<BishopMobilityEach>(reader);
448 read_count += setUpOne<BishopBishopPiece>(reader);
449 read_count += setUpOne<NonPawnPieceStandCombination>(reader);
450 read_count += setUpOne<CanCheckNonPawnPieceStandCombination>(reader);
451 read_count += setUpOne<King25Effect3Y>(reader);
452 read_count += setUpOne<RookRook>(reader);
453 read_count += setUpOne<RookRookPiece>(reader);
454 read_count += setUpOne<PinPtypePawnAttack>(reader);
455 read_count += setUpOne<King25Mobility>(reader);
456 read_count += setUpOne<King25MobilityX>(reader);
457 read_count += setUpOne<King25MobilityY>(reader);
458 read_count += setUpOne<King25EffectCountCombination>(reader);
459 read_count += setUpOne<GoldSideMove>(reader);
460 read_count += setUpOne<King25EffectCountCombinationY>(reader);
461 read_count += setUpOne<RookPromoteDefenseRookH>(reader);
462 read_count += setUpOne<BishopHeadX>(reader);
463 read_count += setUpOne<PawnDropNonDrop>(reader);
464 read_count += setUpOne<PawnStateKingRelative>(reader);
465 read_count += setUpOne<SilverFork>(reader);
466 read_count += setUpOne<BishopRookFork>(reader);
467 read_count += setUpOne<BishopStandFile5>(reader);
468 read_count += setUpOne<KnightFork>(reader);
469 read_count += setUpOne<NonPawnAttackedPtypePair>(reader);
470 read_count += setUpOne<MajorCheckWithCapture>(reader);
471 read_count += setUpOne<SilverAdvance26>(reader);
472 read_count += setUpOne<RookSilverKnight>(reader);
473 read_count += setUpOne<BishopSilverKnight>(reader);
474 read_count += setUpOne<AttackMajorsInBase>(reader);
475 read_count += setUpOne<CheckShadowPtype>(reader);
476 read_count += setUpOne<Promotion37>(reader);
477
478 initialized_flag = reader.failed() ? Zero : Loaded;
479 if (initialized_flag != Loaded)
480 {
481 std::cerr << "Failed to load OpenMidEndingEval data "
482 << ' ' << read_count << std::endl;
483 }
484}
485
487{
488 std::string filename = OslConfig::home();
489 filename += "/data/eval.bin";
490 return filename;
491}
492
494{
495 return setUp(defaultFilename().c_str());
496}
497
499OpenMidEndingEval::OpenMidEndingEval(const NumEffectState &state, bool use_limit)
500 : progress(state), use_progress_independent_value_limit(use_limit)
501{
502 assert(initialized_flag != Zero);
503
504 pawns.fill(0);
506 turn = state.turn();
507 for (int i = PtypeTraits<PAWN>::indexMin;
508 i < PtypeTraits<PAWN>::indexLimit; ++i)
509 {
510 const Piece pawn = state.pieceOf(i);
511 if (pawn.owner() == BLACK)
513 if (pawn.isOnBoard() && !pawn.isPromoted())
514 pawns[pawn.owner()][pawn.square().x() - 1] =
515 pawn.square().y();
516 }
519 for (int i = PtypeTraits<ROOK>::indexMin;
520 i < PtypeTraits<ROOK>::indexLimit; ++i)
521 {
522 if (state.pieceOf(i).owner() == BLACK)
524 }
526 i < PtypeTraits<BISHOP>::indexLimit; ++i)
527 {
528 if (state.pieceOf(i).owner() == BLACK)
530 }
531 for (int i = PtypeTraits<GOLD>::indexMin;
532 i < PtypeTraits<GOLD>::indexLimit; ++i)
533 {
534 if (state.pieceOf(i).owner() == BLACK)
536 }
538
539 ptype_count.fill(0);
540 ptypeo_mask=0u;
541 ptype_board_count.fill(0);
542 for (int i = 0; i < Piece::SIZE; ++i)
543 {
544 const Piece piece = state.pieceOf(i);
545 if (piece.ptype() == KING)
546 continue;
547 ++ptype_count[piece.owner()][piece.ptype()];
548 ptypeo_mask |= 1<<(piece.ptypeO()-PTYPEO_MIN);
549 if (piece.isOnBoard())
550 ++ptype_board_count[piece.owner()][piece.ptype()];
551 }
553 for (Ptype ptype: osl::PieceStand::order)
554 {
555 if (ptype == PAWN)
556 continue;
558 state.countPiecesOnStand(osl::BLACK, ptype);
560 state.countPiecesOnStand(osl::WHITE, ptype);
561 }
570
573
575
576 King25EffectBoth::countEffectAndPiecesBoth<BLACK>(state, effect25[WHITE],
583 King25EffectBoth::countEffectAndPiecesBoth<WHITE>(state, effect25[BLACK],
592 EnterKingDefense::eval(state) +
603 {
604 MultiInt result_supported =
609 MultiInt result_supported_y =
614 state.kingSquare<BLACK>().y(),
615 state.kingSquare<WHITE>().y());
616
617 recalculated_stage_value = result_supported + result_supported_y;
618 king_rook_bishop[BLACK]=KingRookBishop::evalOne<BLACK>(state);
619 king_rook_bishop[WHITE]=KingRookBishop::evalOne<WHITE>(state);
622 }
623
625 const MultiInt silver_retreat = SilverFeatures::eval(state);
626 const MultiInt gold_retreat = GoldFeatures::eval(state);
628 recalculated_stage_value += silver_retreat + gold_retreat;
641
650 king25_both_side[BLACK]=King25BothSide::evalOne<BLACK>(state,black_vertical);
651 king25_both_side[WHITE]=King25BothSide::evalOne<WHITE>(state,white_vertical);
659
661
663
664 ptypex = PtypeX::eval(state);
665
666 ptypey = PtypeY::eval(state);
667
669 CanCheckNonPawnPieceStandCombination::canCheck<BLACK>(state);
671 CanCheckNonPawnPieceStandCombination::canCheck<WHITE>(state);
673 can_check);
677
681
683
686 state.effectedMask(BLACK);
689 state.effectedMask(WHITE);
690 mask_t black_ppawn =
692 state.promotedPieces().getMask<PAWN>();
693 mask_t white_ppawn =
695 state.promotedPieces().getMask<PAWN>();
704
705 ptype_yy = PtypeYY::eval(state);
728}
729
731OpenMidEndingEval::expect(const NumEffectState &state, Move move) const
732{
733 if (move.isPass())
734 return value();
735 int value;
736 if(move.player()==BLACK)
737 value = PieceEval::evalWithUpdate<BLACK>(state, move, progress_independent_value);
738 else
739 value = PieceEval::evalWithUpdate<WHITE>(state, move, progress_independent_value);
740
741#ifdef USE_TEST_PROGRESS
742 return roundUp(value * NewProgress::maxProgress() +
743 openingValue() * (NewProgress::maxProgress() - progress.progress()) +
744 endgameValue() * progress.progress());
745#else
746 return roundUp(value * 16 +
747 openingValue() * (16 - progress.progress16().value()) +
748 endgameValue() * progress.progress16().value());
749#endif
750}
751
753OpenMidEndingEval::update(const NumEffectState &new_state, Move last_move)
754{
755 turn = alt(turn);
756 assert(new_state.turn() == turn);
757 if (last_move.isPass())
758 {
759 invalidateCache();
760 return;
761 }
762 if(last_move.player()==BLACK)
763 updateSub<BLACK>(new_state,last_move);
764 else
765 updateSub<WHITE>(new_state,last_move);
766}
767template<osl::Player P>
769OpenMidEndingEval::updateSub(const NumEffectState &new_state, Move last_move)
770{
771 assert(last_move.player()==P);
772 const Square opp_king =
773 new_state.kingSquare<alt(P)>();
774 const Square self_king =
775 new_state.kingSquare<P>();
776 Ptype captured = last_move.capturePtype();
777 if (captured != PTYPE_EMPTY)
778 {
779 Ptype base = unpromote(captured);
780 if (base == PAWN)
781 {
782 if (P == BLACK)
783 ++black_pawn_count;
784 else
785 --black_pawn_count;
786 }
787 else
788 {
789 ++non_pawn_stand_count[P];
790 }
791 if (captured == PAWN)
792 {
793 pawns[alt(P)][last_move.to().x() - 1] = 0;
794 }
795 if (isMajorBasic(base))
796 {
797 if (P == BLACK)
798 ++black_major_count;
799 else
800 --black_major_count;
801 }
802 if (base == GOLD)
803 {
804 if (P == BLACK)
805 ++black_gold_count;
806 else
807 --black_gold_count;
808 }
809 if (base == GOLD || base == SILVER)
810 {
811 const int y_diff = std::abs(last_move.to().y() - opp_king.y());
812 const int x_diff = std::abs(last_move.to().x() - opp_king.x());
813 if (y_diff <= 2 && x_diff <= 3)
814 {
815 --gs_near_king_count[alt(P)][std::max(x_diff, y_diff) - 1];
816 }
817 }
818 }
819 const Ptype base_ptype = unpromote(last_move.ptype());
820 {
821 if (base_ptype == GOLD || base_ptype == SILVER)
822 {
823 if (!last_move.isDrop())
824 {
825 const int y_diff = std::abs(last_move.from().y() - self_king.y());
826 const int x_diff = std::abs(last_move.from().x() - self_king.x());
827 if (y_diff <= 2 && x_diff <= 3)
828 {
829 --gs_near_king_count[P][std::max(x_diff, y_diff) - 1];
830 }
831 }
832 {
833 const int y_diff = std::abs(last_move.to().y() - self_king.y());
834 const int x_diff = std::abs(last_move.to().x() - self_king.x());
835 if (y_diff <= 2 && x_diff <= 3)
836 {
837 ++gs_near_king_count[P][std::max(x_diff, y_diff) - 1];
838 }
839 }
840 }
841 if (base_ptype == KING)
842 {
843 updateGoldSilverNearKing(new_state);
844 }
845 }
846 if (last_move.isDrop() && last_move.ptype() != PAWN)
847 {
848 --non_pawn_stand_count[P];
849 }
850 if (last_move.ptype() == PPAWN && last_move.isPromotion())
851 {
852 pawns[P][last_move.from().x() - 1] = 0;
853 }
854 if (last_move.ptype() == PAWN)
855 {
856 pawns[P][last_move.to().x() - 1] = last_move.to().y();
857 }
858 const Square kb = new_state.kingSquare<BLACK>(), kw = new_state.kingSquare<WHITE>();
859 {
860 BoardMask mask = new_state.changedEffects();
861 mask.set(last_move.from());
862 mask.set(last_move.to());
863 const bool update_black = mask.anyInRange(Board_Mask_Table5x5.mask(kw)); // black attack to white
864 const bool update_white = mask.anyInRange(Board_Mask_Table5x5.mask(kb));
865 if (update_black ||
866 (effect25_supported[WHITE] & new_state.effectedMask(BLACK)) !=
867 effect25_supported[WHITE] ||
868 (~effect25_supported[WHITE] & effect25[WHITE] & ~new_state.effectedMask(BLACK)) !=
869 (~effect25_supported[WHITE] & effect25[WHITE])){
870 King25EffectBoth::countEffectAndPiecesBoth<BLACK>(
871 new_state, effect25[WHITE], effect25_supported[WHITE],
872 black_attack_effect, black_attack_piece,
873 white_defense_effect, white_defense_piece,
874 black_attack_supported_piece, white_vertical, white_king_vertical);
875 king25_both_side[WHITE]=King25BothSide::evalOne<WHITE>(new_state,white_vertical);
876 }
877 if (update_white ||
878 (effect25_supported[BLACK] & new_state.effectedMask(WHITE)) !=
879 effect25_supported[BLACK] ||
880 (~effect25_supported[BLACK] & effect25[BLACK] & ~new_state.effectedMask(WHITE)) !=
881 (~effect25_supported[BLACK] & effect25[BLACK])){
882 King25EffectBoth::countEffectAndPiecesBoth<WHITE>(
883 new_state, effect25[BLACK], effect25_supported[BLACK],
884 white_attack_effect, white_attack_piece,
885 black_defense_effect, black_defense_piece,
886 white_attack_supported_piece, black_vertical, black_king_vertical);
887 king25_both_side[BLACK]=King25BothSide::evalOne<BLACK>(new_state,black_vertical);
888 }
889 }
890#ifdef USE_TEST_PROGRESS
891 progress.updateSub<P>(new_state, last_move);
892#else
893 progress.update(new_state, last_move);
894#endif
895
896 progress_independent_value =
897 PieceEval::evalWithUpdate<P>(new_state, last_move, progress_independent_value);
898 piece_stand_value =
899 PieceStand::evalWithUpdate<P>(new_state, last_move,
900 piece_stand_value);
901 if (new_state.longEffectChanged<ROOK>() || last_move.ptype() == KING)
902 {
903 RookMobilityAll::eval(new_state, rook_mobility);
904 rook_effect = RookEffectBase::eval(new_state);
905 }
906 if (new_state.longEffectChanged<BISHOP>())
907 {
908 BishopMobilityAll::eval(new_state, bishop_mobility);
909 bishop_effect = BishopEffectBase::eval(new_state);
910 }
911 else if (last_move.ptype() == KING)
912 {
913 bishop_effect = BishopEffectBase::eval(new_state);
914 }
915 if (new_state.longEffectChanged<LANCE>() || last_move.ptype() == KING)
916 {
917 LanceMobilityAll::eval(new_state, lance_mobility);
918 lance_effect_piece = LanceEffectPieceKingRelative::eval(new_state);
919 }
920
921 if (new_state.anyEffectChanged<KNIGHT>()) {
922 knight_advance = KnightAdvance::eval(new_state);
923 }
924 KingXBlockedBoth::evalWithUpdateBang(new_state, last_move, kingx_blocked);
925 const MultiInt silver_features = SilverFeatures::eval(new_state);
926 const MultiInt gold_retreat = GoldFeatures::eval(new_state);
927 recalculated_stage_value = silver_features+gold_retreat;
928 recalculated_stage_value += AllGold::eval(black_gold_count);
929 recalculated_stage_value += AllMajor::eval(black_major_count);
930
931 King25EffectEachBoth::evalWithUpdate(new_state, last_move,
932 king25_effect_each);
933
934 recalculated_value =
936 EnterKingDefense::eval(new_state) +
937 King25EffectAttack::eval(new_state,
938 black_attack_effect,
939 black_attack_piece,
940 white_attack_effect, white_attack_piece);
941 recalculated_value +=
943 black_attack_effect,
944 black_attack_piece,
945 white_attack_effect, white_attack_piece);
946
947 recalculated_stage_value +=
948 King25EffectDefense::eval(new_state,black_defense_effect,black_defense_piece,
949 white_defense_effect, white_defense_piece);
950 recalculated_stage_value +=
952 black_defense_effect,
953 black_defense_piece,
954 white_defense_effect, white_defense_piece);
955 recalculated_stage_value += knight_advance;
956 recalculated_stage_value += AnagumaEmpty::eval(new_state);
957 recalculated_stage_value += kingx_blocked[BLACK] + kingx_blocked[WHITE];
958 recalculated_stage_value += NoPawnOnStand::eval(new_state, black_pawn_count);
959 recalculated_stage_value += NonPawnPieceStand::eval(non_pawn_stand_count[BLACK], non_pawn_stand_count[WHITE]);
960 recalculated_stage_value += PinPtypeAll::eval(new_state);
961 recalculated_stage_value += KingMobility::eval(new_state) + KingMobilitySum::eval(new_state);
962 recalculated_stage_value += GoldAndSilverNearKing::eval(new_state,
963 gs_near_king_count);
964 recalculated_stage_value += PieceStandCombinationBoth::eval(new_state);
965
966 {
967 MultiInt result_supported =
968 King25EffectSupported::eval(black_attack_piece,
969 white_attack_piece,
970 black_attack_supported_piece,
971 white_attack_supported_piece);
972 MultiInt result_supported_y =
973 King25EffectSupportedY::eval(black_attack_piece,
974 white_attack_piece,
975 black_attack_supported_piece,
976 white_attack_supported_piece,
977 new_state.kingSquare<BLACK>().y(),
978 new_state.kingSquare<WHITE>().y());
979 recalculated_stage_value += result_supported + result_supported_y;
980 if(isMajorNonPieceOK(last_move.ptype()) ||
981 isMajorNonPieceOK(last_move.capturePtype())){ // rook or bishop
982 king_rook_bishop[BLACK]=KingRookBishop::evalOne<BLACK>(new_state);
983 king_rook_bishop[WHITE]=KingRookBishop::evalOne<WHITE>(new_state);
984 }
985 else if(last_move.ptype() == KING){
986 king_rook_bishop[P]=KingRookBishop::evalOne<P>(new_state);
987 }
988 recalculated_stage_value +=king_rook_bishop[BLACK]-king_rook_bishop[WHITE];
989 recalculated_stage_value += KingXBlocked3::eval(new_state);
990 recalculated_stage_value += king25_both_side[BLACK]-king25_both_side[WHITE];
991 recalculated_stage_value += King25Mobility::eval(new_state,
992 black_king_vertical,
993 white_king_vertical);
994 }
995 king_table_value = KingPieceRelative::evalWithUpdate<P>
996 (new_state, last_move, king_table_value);
997 piece_pair_value = PiecePair::evalWithUpdateCompiled(new_state,
998 last_move,
999 piece_pair_value);
1000 PiecePairKing::evalWithUpdateBang<P>(new_state, last_move,
1001 piece_pair_king_value);
1002 pawn_drop = PawnDropBoth::evalWithUpdate<P>(new_state,
1003 last_move, pawn_drop);
1004
1005 ptypex = PtypeX::evalWithUpdate<P>(new_state, last_move, ptypex);
1006 ptypey = PtypeY::evalWithUpdate<P>(new_state, last_move, ptypey);
1007 CArray<bool, 2> can_check_new;
1008 can_check_new[BLACK] =
1009 CanCheckNonPawnPieceStandCombination::canCheck<BLACK>(new_state);
1010 can_check_new[WHITE] =
1011 CanCheckNonPawnPieceStandCombination::canCheck<WHITE>(new_state);
1012 piece_stand_combination =
1014 last_move,
1015 piece_stand_combination,
1016 can_check,
1017 can_check_new);
1018 can_check = can_check_new;
1019 NonPawnPieceStandTurn::evalWithUpdateBang<P>(new_state,
1020 last_move,
1021 piece_stand_turn);
1022 rook_pawn = RookPawnY::eval(new_state, pawns);
1023 piece_stand_y = PieceStandY::evalWithUpdate<P>(new_state, last_move,
1024 piece_stand_y);
1025 PawnAdvanceAll::evalWithUpdateBang<P>(new_state,
1026 last_move,
1027 pawn_advance);
1028
1029 knight_check = KnightCheck::eval(new_state);
1030 pawn_ptypeo = PawnPtypeOPtypeO::template evalWithUpdate<P>(new_state, last_move,
1031 pawns,
1032 pawn_ptypeo);
1033
1034 promoted_minor_piece =
1036 last_move,
1037 promoted_minor_piece);
1038
1039 nosupport = KingPieceRelativeNoSupport::evalWithUpdate(new_state, last_move,
1040 effected_mask,
1041 nosupport);
1042 NonPawnAttacked::evalWithUpdateBang<P>(new_state,
1043 last_move,
1044 effected_mask_for_attacked,
1045 non_pawn_attacked);
1046 NonPawnAttackedPtype::evalWithUpdateBang<P>(
1047 new_state, last_move, effected_mask_for_attacked,
1048 attacked_mask, non_pawn_attacked_ptype);
1049 effected_mask[BLACK] =
1050 effected_mask_for_attacked[BLACK] =
1051 new_state.effectedMask(BLACK);
1052 effected_mask[WHITE] =
1053 effected_mask_for_attacked[WHITE] =
1054 new_state.effectedMask(WHITE);
1055 mask_t black_ppawn =
1056 effected_mask_for_attacked[BLACK].selectBit<PAWN>() &
1057 new_state.promotedPieces().template getMask<PAWN>();
1058 mask_t white_ppawn =
1059 effected_mask_for_attacked[WHITE].selectBit<PAWN>() &
1060 new_state.promotedPieces().template getMask<PAWN>();
1061 effected_mask_for_attacked[BLACK].clearBit<PAWN>();
1062 effected_mask_for_attacked[WHITE].clearBit<PAWN>();
1063 effected_mask_for_attacked[BLACK].orMask(PtypeFuns<PAWN>::indexNum, black_ppawn);
1064 effected_mask_for_attacked[WHITE].orMask(PtypeFuns<PAWN>::indexNum, white_ppawn);
1065
1066 ptype_yy = PtypeYY::evalWithUpdate(new_state, last_move, ptype_yy);
1067 king3pieces = King3Pieces::evalWithUpdate(new_state, last_move, king3pieces);
1068 bishop_head = BishopHead::eval(new_state);
1069 knight_head = KnightHead::eval(new_state);
1070 rook_promote_defense = RookPromoteDefense::eval(new_state);
1071 PtypeCount::evalWithUpdateBang<P>(new_state,
1072 last_move, ptype_count, ptype_board_count,
1073 ptype_count_value,ptypeo_mask);
1074 PtypeYPawnY::evalWithUpdateBang<P>(new_state, last_move,pawns, ptype_y_pawn_y);
1075 recalculated_stage_value += PtypeCombination::eval(ptypeo_mask);
1076 bishop_and_king = NumPiecesBetweenBishopAndKing::eval(new_state);
1077 recalculated_stage_value += King25Effect3::eval(new_state, effect25);
1078 recalculated_stage_value += BishopBishopPiece::eval(new_state);
1079 recalculated_stage_value += RookRook::eval(new_state);
1080 recalculated_stage_value += RookRookPiece::eval(new_state);
1081 recalculated_stage_value += King25EffectCountCombination::eval(new_state, effect25);
1082 recalculated_stage_value += BishopStandFile5::eval(new_state);
1083 recalculated_stage_value += MajorCheckWithCapture::eval(new_state);
1084 recalculated_stage_value += SilverAdvance26::eval(new_state);
1085 if (base_ptype == ROOK || last_move.ptype() == SILVER ||
1086 last_move.ptype() == KNIGHT ||
1087 captured == ROOK || captured == PROOK || captured == SILVER ||
1088 captured == KNIGHT ||
1089 (last_move.isPromotion() &&
1090 (base_ptype == SILVER || base_ptype == KNIGHT)))
1091 {
1092 rook_silver_knight = RookSilverKnight::eval(new_state);
1093 }
1094 if (base_ptype == BISHOP || last_move.ptype() == SILVER ||
1095 last_move.ptype() == KNIGHT ||
1096 captured == BISHOP || captured == PBISHOP || captured == SILVER ||
1097 captured == KNIGHT ||
1098 (last_move.isPromotion() &&
1099 (base_ptype == SILVER || base_ptype == KNIGHT)))
1100 {
1101 bishop_silver_knight = BishopSilverKnight::eval(new_state);
1102 }
1103 recalculated_stage_value += AttackMajorsInBase::eval(new_state);
1104 recalculated_stage_value += CheckShadowPtype::eval(new_state);
1105#ifdef USE_TEST_PROGRESS
1106 recalculated_stage_value += progress.rawData().promotion37_eval;
1107 recalculated_stage_value += progress.rawData().non_pawn_ptype_attacked_pair_eval[BLACK]
1108 + progress.rawData().non_pawn_ptype_attacked_pair_eval[WHITE];
1109#else
1110 recalculated_stage_value += Promotion37::eval(new_state);
1111 recalculated_stage_value += NonPawnAttackedPtypePair::eval(new_state);
1112#endif
1113 piece_fork_turn = SilverFork::eval(new_state, silver_drop);
1114 piece_fork_turn += BishopRookFork::eval(new_state, bishop_drop, rook_drop);
1115 piece_fork_turn += KnightFork::evalWithUpdate<P>(new_state, last_move, knight_fork_squares, knight_drop);
1116 invalidateCache();
1117}
1118
1119#ifndef MINIMAL
1122{
1123 OpenMidEndingEvalDebugInfo debug_info;
1124 debug_info.value = value();
1125 debug_info.progress = progress16().value();
1126 debug_info.progress_independent_values[OpenMidEndingEvalDebugInfo::PIECE] = progress_independent_value;
1130 = EnterKingDefense::eval(state);
1131 int black_attack_effect, black_attack_piece, black_defense_effect, black_defense_piece,
1132 white_attack_effect, white_attack_piece, white_defense_effect, white_defense_piece;
1133 CArray<int, 5> black_vertical, white_vertical,
1134 black_king_vertical, white_king_vertical;
1135 King25EffectBoth::countEffectAndPiecesBoth<BLACK>(state, effect25[WHITE],
1136 effect25_supported[WHITE],
1137 black_attack_effect, black_attack_piece,
1138 white_defense_effect, white_defense_piece,
1139 black_attack_supported_piece,
1140 white_vertical,
1141 white_king_vertical);
1142 King25EffectBoth::countEffectAndPiecesBoth<WHITE>(state, effect25[BLACK],
1143 effect25_supported[BLACK],
1144 white_attack_effect, white_attack_piece,
1145 black_defense_effect, black_defense_piece,
1146 white_attack_supported_piece,
1147 black_vertical,
1148 black_king_vertical);
1151 black_attack_effect,
1152 black_attack_piece,
1153 white_attack_effect, white_attack_piece,
1154 black_defense_effect, black_defense_piece,
1155 white_defense_effect, white_defense_piece) +
1156 King25EffectY::eval(state,
1157 black_attack_effect,
1158 black_attack_piece,
1159 white_attack_effect, white_attack_piece,
1160 black_defense_effect, black_defense_piece,
1161 white_defense_effect, white_defense_piece);
1163 debug_info.progress_independent_values[OpenMidEndingEvalDebugInfo::PIECE_PAIR_KING] = piece_pair_king_value[BLACK] + piece_pair_king_value[WHITE];
1164
1166 king_table_value;
1168 piece_stand_value;
1170 king25_effect_each[BLACK] + king25_effect_each[WHITE];
1173 debug_info.stage_values[OpenMidEndingEvalDebugInfo::ROOK_MOBILITY] = rook_mobility;
1174 debug_info.stage_values[OpenMidEndingEvalDebugInfo::BISHOP_MOBILITY] = bishop_mobility;
1175 debug_info.stage_values[OpenMidEndingEvalDebugInfo::LANCE_MOBILITY] = lance_mobility;
1176 debug_info.stage_values[OpenMidEndingEvalDebugInfo::ROOK_EFFECT] = rook_effect;
1177 debug_info.stage_values[OpenMidEndingEvalDebugInfo::BISHOP_EFFECT] = bishop_effect;
1178 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PIECE_STAND_COMBINATION] = piece_stand_combination;
1179 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PIECE_STAND_TURN] = piece_stand_turn[turn];
1182 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PIECE_STAND_Y] = piece_stand_y;
1183 debug_info.stage_values[OpenMidEndingEvalDebugInfo::KNIGHT_CHECK] = knight_check;
1184 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PAWN_ADVANCE] = pawn_advance;
1185 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PAWN_PTYPEO] = pawn_ptypeo;
1186 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PROMOTED_MINOR_PIECE] = promoted_minor_piece;
1188 debug_info.stage_values[OpenMidEndingEvalDebugInfo::NON_PAWN_ATTACKED] = non_pawn_attacked[turn];
1189 debug_info.stage_values[OpenMidEndingEvalDebugInfo::NON_PAWN_ATTACKED_PTYPE] = non_pawn_attacked_ptype[turn];
1191 debug_info.stage_values[OpenMidEndingEvalDebugInfo::KING3PIECES] = king3pieces;
1192 debug_info.stage_values[OpenMidEndingEvalDebugInfo::BISHOP_HEAD] = bishop_head;
1193 debug_info.stage_values[OpenMidEndingEvalDebugInfo::KNIGHT_HEAD] = knight_head;
1194 debug_info.stage_values[OpenMidEndingEvalDebugInfo::ROOK_PROMOTE_DEFENSE] = rook_promote_defense;
1195 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PTYPE_COUNT] = ptype_count_value;
1196 debug_info.stage_values[OpenMidEndingEvalDebugInfo::LANCE_EFFECT_PIECE] = lance_effect_piece;
1197 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PTYPE_Y_PAWN_Y] = ptype_y_pawn_y;
1198 debug_info.stage_values[OpenMidEndingEvalDebugInfo::BISHOP_AND_KING] = bishop_and_king;
1199 debug_info.stage_values[OpenMidEndingEvalDebugInfo::PIECE_FORK_TURN] = piece_fork_turn[turn];
1200 debug_info.stage_values[OpenMidEndingEvalDebugInfo::ROOK_SILVER_KNIGHT] = rook_silver_knight;
1201 debug_info.stage_values[OpenMidEndingEvalDebugInfo::BISHOP_SILVER_KNIGHT] = bishop_silver_knight;
1203 King25EffectSupported::eval(black_attack_piece,
1204 white_attack_piece,
1205 black_attack_supported_piece,
1206 white_attack_supported_piece) +
1207 King25EffectSupportedY::eval(black_attack_piece,
1208 white_attack_piece,
1209 black_attack_supported_piece,
1210 white_attack_supported_piece,
1211 state.kingSquare<BLACK>().y(),
1212 state.kingSquare<WHITE>().y());
1214 king_rook_bishop[BLACK] - king_rook_bishop[WHITE];
1216 KingXBlocked3::eval(state);
1218 GoldFeatures::eval(state);
1220 SilverFeatures::eval(state);
1222 AllGold::eval(black_gold_count);
1224 AllMajor::eval(black_major_count);
1226 King25EffectDefense::eval(state, black_defense_effect, black_defense_piece,
1227 white_defense_effect, white_defense_piece) +
1229 black_defense_effect,
1230 black_defense_piece,
1231 white_defense_effect, white_defense_piece);
1233 AnagumaEmpty::eval(state);
1235 NoPawnOnStand::eval(state, black_pawn_count);
1237 NonPawnPieceStand::eval(non_pawn_stand_count[BLACK], non_pawn_stand_count[WHITE]);
1239 PinPtypeAll::eval(state);
1244 gs_near_king_count);
1246 PtypeCombination::eval(ptypeo_mask);
1248 king25_both_side[BLACK] - king25_both_side[WHITE];
1251 black_king_vertical,
1252 white_king_vertical);
1258 SilverAdvance26::eval(state);
1260 King25Effect3::eval(state, effect25);
1264 RookRook::eval(state);
1266 RookRookPiece::eval(state);
1268 King25EffectCountCombination::eval(state, effect25);
1273
1274 return debug_info;
1275}
1276
1277#define DEBUGPRINT(x) std::cerr << " " << #x << " " << x << "\n"
1279debug() const
1280{
1281 DEBUGPRINT(king_table_value[0]);
1282 DEBUGPRINT(piece_stand_value[0]);
1283 DEBUGPRINT(king25_effect_each[BLACK][0] + king25_effect_each[WHITE][0]);
1284 DEBUGPRINT(ptypex[0]);
1285 DEBUGPRINT(ptypey[0]);
1286 DEBUGPRINT(rook_mobility[0]);
1287 DEBUGPRINT(bishop_mobility[0]);
1288 DEBUGPRINT(lance_mobility[0]);
1289 DEBUGPRINT(rook_effect[0]);
1290 DEBUGPRINT(bishop_effect[0]);
1291 DEBUGPRINT(piece_stand_combination[0]);
1292 DEBUGPRINT(piece_stand_turn[turn][0]);
1293 DEBUGPRINT(rook_pawn[0]);
1294 DEBUGPRINT(pawn_drop[0]);
1295 DEBUGPRINT(piece_stand_y[0]);
1296 DEBUGPRINT(knight_check[0]);
1297 DEBUGPRINT(pawn_advance[0]);
1298 DEBUGPRINT(pawn_ptypeo[0]);
1299 DEBUGPRINT(promoted_minor_piece[0]);
1300 DEBUGPRINT(nosupport[0]);
1301 DEBUGPRINT(non_pawn_attacked[turn][0]);
1302 DEBUGPRINT(non_pawn_attacked_ptype[turn][0]);
1303 DEBUGPRINT(ptype_yy[0]);
1304 DEBUGPRINT(king3pieces[0]);
1305 DEBUGPRINT(bishop_head[0]);
1306 DEBUGPRINT(knight_head[0]);
1307 DEBUGPRINT(rook_promote_defense[0]);
1308 DEBUGPRINT(ptype_count_value[0]);
1309 DEBUGPRINT(lance_effect_piece[0]);
1310 DEBUGPRINT(ptype_y_pawn_y[0]);
1311 DEBUGPRINT(bishop_and_king[0]);
1312 DEBUGPRINT(recalculated_stage_value[0]);
1313}
1314
1316setRandom()
1317{
1318 std::lock_guard<std::mutex> lk(initialize_mutex);
1319 initialized_flag = Random;
1320
1321 setRandomOne<King25EffectAttack>();
1322 setRandomOne<King25EffectYAttack>();
1323
1324 // opening
1325 setRandomOne<PieceStand>(0);
1326 setRandomOne<Pin>(0);
1327 setRandomOne<King25EffectEachBothOpening>();
1328 setRandomOne<PawnDrop>(0);
1329 setRandomOne<NoPawnOnStand>(0);
1330 setRandomOne<GoldRetreat>(0);
1331 setRandomOne<SilverRetreat>(0);
1332 setRandomOne<KnightAdvance>(0);
1333 setRandomOne<AllMajor>(0);
1334 setRandomOne<KingXBlocked>(0);
1335 setRandomOne<KingXBlockedY>(0);
1336 setRandomOne<AllGold>(0);
1337 setRandomOne<PtypeX>(0);
1338 setRandomOne<PtypeY>(0);
1339 setRandomOne<AnagumaEmpty>(0);
1340 setRandomOne<NonPawnPieceStand>(0);
1341 setRandomOne<King25EffectDefense>(0);
1342 setRandomOne<King25EffectYDefense>(0);
1343 setRandomOne<RookMobility>(0);
1344 setRandomOne<BishopMobility>(0);
1345 setRandomOne<LanceMobility>(0);
1346 setRandomOne<RookEffect>(0);
1347 setRandomOne<BishopEffect>(0);
1348 setRandomOne<PawnAdvance>(0);
1349 setRandomOne<PawnDropY>(0);
1350 setRandomOne<KnightCheck>(0);
1351
1352 // midgame
1353 setRandomOne<PieceStand>(1);
1354 setRandomOne<Pin>(1);
1355 setRandomOne<King25EffectEachBothMidgame>();
1356 setRandomOne<PawnDrop>(1);
1357 setRandomOne<NoPawnOnStand>(1);
1358 setRandomOne<GoldRetreat>(1);
1359 setRandomOne<SilverRetreat>(1);
1360 setRandomOne<KnightAdvance>(1);
1361 setRandomOne<AllMajor>(1);
1362 setRandomOne<KingXBlocked>(1);
1363 setRandomOne<KingXBlockedY>(1);
1364 setRandomOne<AllGold>(1);
1365 setRandomOne<PtypeX>(1);
1366 setRandomOne<PtypeY>(1);
1367 setRandomOne<AnagumaEmpty>(1);
1368 setRandomOne<NonPawnPieceStand>(1);
1369 setRandomOne<King25EffectDefense>(1);
1370 setRandomOne<King25EffectYDefense>(1);
1371 setRandomOne<RookMobility>(1);
1372 setRandomOne<BishopMobility>(1);
1373 setRandomOne<LanceMobility>(1);
1374 setRandomOne<RookEffect>(1);
1375 setRandomOne<BishopEffect>(1);
1376 setRandomOne<PawnAdvance>(1);
1377 setRandomOne<PawnDropY>(1);
1378 setRandomOne<KnightCheck>(1);
1379
1380#ifdef EVAL_QUAD
1381 // midgame2
1382 setRandomOne<PieceStand>(2);
1383 setRandomOne<Pin>(2);
1384 setRandomOne<King25EffectEachBothEnding>();
1385 setRandomOne<PawnDrop>(2);
1386 setRandomOne<NoPawnOnStand>(2);
1387 setRandomOne<GoldRetreat>(2);
1388 setRandomOne<SilverRetreat>(2);
1389 setRandomOne<KnightAdvance>(2);
1390 setRandomOne<AllMajor>(2);
1391 setRandomOne<KingXBlocked>(2);
1392 setRandomOne<KingXBlockedY>(2);
1393 setRandomOne<AllGold>(2);
1394 setRandomOne<PtypeX>(2);
1395 setRandomOne<PtypeY>(2);
1396 setRandomOne<AnagumaEmpty>(2);
1397 setRandomOne<NonPawnPieceStand>(2);
1398 setRandomOne<King25EffectDefense>(2);
1399 setRandomOne<King25EffectYDefense>(2);
1400 setRandomOne<RookMobility>(2);
1401 setRandomOne<BishopMobility>(2);
1402 setRandomOne<LanceMobility>(2);
1403 setRandomOne<RookEffect>(2);
1404 setRandomOne<BishopEffect>(2);
1405 setRandomOne<PawnAdvance>(2);
1406 setRandomOne<PawnDropY>(2);
1407 setRandomOne<KnightCheck>(2);
1408#endif
1409 // endgame
1410 setRandomOne<PieceStand>(EndgameIndex);
1411 setRandomOne<Pin>(EndgameIndex);
1412 setRandomOne<King25EffectEachBothMidgame>();
1413 setRandomOne<PawnDrop>(EndgameIndex);
1414 setRandomOne<NoPawnOnStand>(EndgameIndex);
1415 setRandomOne<GoldRetreat>(EndgameIndex);
1416 setRandomOne<SilverRetreat>(EndgameIndex);
1417 setRandomOne<KnightAdvance>(EndgameIndex);
1418 setRandomOne<AllMajor>(EndgameIndex);
1419 setRandomOne<KingXBlocked>(EndgameIndex);
1420 setRandomOne<KingXBlockedY>(EndgameIndex);
1421 setRandomOne<AllGold>(EndgameIndex);
1422 setRandomOne<PtypeX>(EndgameIndex);
1423 setRandomOne<PtypeY>(EndgameIndex);
1424 setRandomOne<AnagumaEmpty>(EndgameIndex);
1425 setRandomOne<NonPawnPieceStand>(EndgameIndex);
1426 setRandomOne<King25EffectDefense>(EndgameIndex);
1427 setRandomOne<King25EffectYDefense>(EndgameIndex);
1428 setRandomOne<RookMobility>(EndgameIndex);
1429 setRandomOne<BishopMobility>(EndgameIndex);
1430 setRandomOne<LanceMobility>(EndgameIndex);
1431 setRandomOne<RookEffect>(EndgameIndex);
1432 setRandomOne<BishopEffect>(EndgameIndex);
1433 setRandomOne<PawnAdvance>(EndgameIndex);
1434 setRandomOne<PawnDropY>(EndgameIndex);
1435 setRandomOne<KnightCheck>(EndgameIndex);
1436
1437 // both
1438 setRandomOne<KingPieceRelative>(0);
1439 setRandomOne<KingPieceRelative>(1);
1440#ifdef EVAL_QUAD
1441 setRandomOne<KingPieceRelative>(2);
1442#endif
1443 setRandomOne<KingPieceRelative>(EndgameIndex);
1444 setRandomOne<NonPawnPieceStandCombination>();
1445 setRandomOne<NonPawnPieceStandTurn>();
1446 setRandomOne<King25EffectEachXY>();
1447 setRandomOne<RookPawnY>();
1448 setRandomOne<RookEffectPiece>();
1449 setRandomOne<BishopEffectPiece>();
1450 setRandomOne<PieceStandY>();
1451 setRandomOne<RookEffectPieceKingRelative>();
1452 setRandomOne<BishopEffectPieceKingRelative>();
1453 setRandomOne<RookPawnYX>();
1454 setRandomOne<PawnPtypeOPtypeO>();
1455 setRandomOne<CanCheckNonPawnPieceStandCombination>();
1456 setRandomOne<PromotedMinorPieces>();
1457 setRandomOne<KingPieceRelativeNoSupport>();
1458 setRandomOne<NonPawnAttacked>();
1459 setRandomOne<PtypeYY>();
1460 setRandomOne<PawnPtypeOPtypeOY>();
1461 setRandomOne<PawnDropX>();
1462 setRandomOne<King3Pieces>();
1463 setRandomOne<King3PiecesXY>();
1464 setRandomOne<King25EffectEachKXY>();
1465 setRandomOne<BishopHead>();
1466 setRandomOne<BishopHeadKingRelative>();
1467 setRandomOne<KnightCheckY>();
1468 setRandomOne<KnightHead>();
1469 setRandomOne<RookPromoteDefense>();
1470 setRandomOne<PawnDropPawnStand>();
1471 setRandomOne<PawnDropPawnStandX>();
1472 setRandomOne<PawnDropPawnStandY>();
1473 setRandomOne<King25Effect2>();
1474 setRandomOne<King25EffectY2>();
1475 setRandomOne<KnightHeadOppPiecePawnOnStand>();
1476 setRandomOne<KingXBothBlocked>();
1477 setRandomOne<KingXBothBlockedY>();
1478 setRandomOne<KingRookBishop>();
1479 setRandomOne<PromotedMinorPiecesY>();
1480 setRandomOne<King25EffectSupported>();
1481 setRandomOne<King25EffectSupportedY>();
1482 setRandomOne<NonPawnAttackedKingRelative>();
1483 setRandomOne<NonPawnAttackedPtype>();
1484 setRandomOne<PtypeCount>();
1485 setRandomOne<KingXBlocked3>();
1486 setRandomOne<KingXBlocked3Y>();
1487 setRandomOne<PtypeCountXY>();
1488 setRandomOne<PtypeCountXYAttack>();
1489 setRandomOne<LanceEffectPieceKingRelative>();
1490 setRandomOne<KingMobility>();
1491 setRandomOne<KingMobilitySum>();
1492 setRandomOne<MajorCheckWithCapture>();
1493 setRandomOne<RookSilverKnight>();
1494 setRandomOne<BishopSilverKnight>();
1495}
1496#endif
1497
1498
1499// ;;; Local Variables:
1500// ;;; mode:c++
1501// ;;; c-basic-offset:2
1502// ;;; End:
void fill(const T_simple &value=T_simple())
Definition container.h:67
圧縮していない moveの表現 .
bool isPromotion() const
Ptype ptype() const
Player player() const
bool isDrop() const
bool isPass() const
Ptype capturePtype() const
const Square to() const
const Square from() const
利きを持つ局面
const BoardMask changedEffects(Player pl) const
bool longEffectChanged() const
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
const PieceMask promotedPieces() const
bool anyEffectChanged() const
const mask_t getMask(int num) const
Definition pieceMask.h:59
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
PtypeO ptypeO() const
Definition basic_type.h:824
Ptype ptype() const
Definition basic_type.h:821
bool isPromoted() const
promoteした駒かどうかをチェックする
Definition basic_type.h:898
const Square square() const
Definition basic_type.h:832
Player owner() const
Definition basic_type.h:963
bool isOnBoard() const
Definition basic_type.h:985
static const int SIZE
Definition basic_type.h:794
Player turn() const
const Piece pieceOf(int num) const
Definition simpleState.h:76
Square kingSquare() const
Definition simpleState.h:94
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
const BoardMask & mask(Square p) const
p中心の5x5 の範囲のbitを立てたもの, centeringなし
Definition boardMask.h:113
void set(unsigned int i)
Definition boardMask.h:40
bool anyInRange(const BoardMask &mask) const
Definition boardMask.h:57
void reset(const CArray< int, PTYPE_SIZE > &values)
Definition ptypeEval.cc:26
static MultiInt eval(int black_major_count)
Definition minorPiece.h:719
static MultiInt eval(int black_major_count)
Definition majorPiece.h:121
static MultiInt eval(const NumEffectState &state)
Definition king8.cc:1073
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static int eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiIntPair eval(const NumEffectState &state, CArray< std::pair< Square, int >, 2 > &bishop_drop, CArray< std::pair< Square, int >, 2 > &rook_drop)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
Definition eval_pin.cc:248
static int eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state, const CArray2d< int, 2, 3 > &gs_count)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state, const CArray< PieceMask, 2 > &king25_mask)
static int eval(const NumEffectState &, int black_effect, int black_piece, int white_effect, int white_piece)
Definition kingTable.h:193
static int eval(const NumEffectState &, int black_attack_effect, int black_attack_piece, int white_attack_effect, int white_attack_piece, int black_defense_effect, int black_defense_piece, int white_defense_effect, int white_defense_piece)
Definition kingTable.h:163
static MultiInt eval(const NumEffectState &state, const CArray< PieceMask, 2 > &king25)
static MultiInt eval(const NumEffectState &, int black_effect, int black_piece, int white_effect, int white_piece)
Definition kingTable.h:219
static void evalWithUpdate(const NumEffectState &state, Move last_move, MultiIntPair &values)
static void eval(const NumEffectState &state, MultiIntPair &out)
static MultiInt eval(int black_attack_piece, int white_attack_piece, int black_attack_supported_piece, int white_attack_supported_piece, int black_king_y, int white_king_y)
Definition kingTable.h:409
static MultiInt eval(int black_attack_piece, int white_attack_piece, int black_attack_supported_piece, int white_attack_supported_piece)
Definition kingTable.h:385
static int eval(const NumEffectState &state, int black_effect, int black_piece, int white_effect, int white_piece)
Definition kingTable.h:246
static MultiInt eval(const NumEffectState &state, int black_effect, int black_piece, int white_effect, int white_piece)
Definition kingTable.h:275
static int eval(const NumEffectState &state, int black_attack_effect, int black_attack_piece, int white_attack_effect, int white_attack_piece, int black_defense_effect, int black_defense_piece, int white_defense_effect, int white_defense_piece)
Definition kingTable.h:299
static MultiInt eval(const NumEffectState &state, const CArray< int, 5 > &black, const CArray< int, 5 > &white)
static MultiInt evalWithUpdate(const NumEffectState &state, Move last_move, MultiInt &last_value)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const CArray< PieceMask, 2 > &effected_mask, const MultiInt &last_values)
Definition kingTable.cc:179
static MultiInt eval(const NumEffectState &state)
Definition kingTable.cc:146
static MultiInt eval(const NumEffectState &state)
Definition king8.cc:965
static void evalWithUpdateBang(const NumEffectState &new_state, Move last_move, MultiIntPair &last_values_and_out)
Definition king8.cc:916
static const MultiIntPair eval(const NumEffectState &state)
static MultiIntPair eval(const NumEffectState &state)
static MultiIntPair eval(const NumEffectState &state)
Definition king8.cc:634
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiIntPair eval(const NumEffectState &state, CArray< BoardMask, 2 > &knight_fork_squares, CArray< std::pair< Square, int >, 2 > &knight_drop)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state, int black_pawn_count)
Definition minorPiece.h:488
static MultiInt eval(const NumEffectState &state)
static void eval(const NumEffectState &state, CArray< PieceMask, 40 > &attacked_mask, MultiIntPair &out)
static void eval(const NumEffectState &state, MultiIntPair &out)
static MultiInt eval(const NumEffectState &state, const CArray< bool, 2 > &can_check)
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_value, const CArray< bool, 2 > &could_check, const CArray< bool, 2 > &can_check)
static void eval(const NumEffectState &state, MultiIntPair &out)
static MultiInt eval(int black_count, int white_count)
static MultiInt eval(const NumEffectState &state)
int expect(const NumEffectState &state, Move move) const
CArray< std::pair< Square, int >, 2 > bishop_drop
void updateSub(const NumEffectState &new_state, Move last_move)
static void doResetWeights(Reader &reader)
CArray2d< int, 2, PTYPE_SIZE > ptype_board_count
void update(const NumEffectState &new_state, Move last_move)
CArray2d< int, 2, PTYPE_SIZE > ptype_count
OpenMidEndingEval(const NumEffectState &state=NumEffectState(), bool limit_progress_independent_value=! OslConfig::hasByoyomi())
void updateGoldSilverNearKing(const NumEffectState &state)
CArray< std::pair< Square, int >, 2 > knight_drop
static void resetWeights(const int *w, size_t length)
static volatile LoadStatus initialized_flag
CArray< PieceMask, 2 > effected_mask
CArray2d< int, 2, 3 > gs_near_king_count
CArray< PieceMask, 2 > effected_mask_for_attacked
CArray< PieceMask, 40 > attacked_mask
OpenMidEndingEvalDebugInfo debugInfo(const NumEffectState &state)
CArray< std::pair< Square, int >, 2 > silver_drop
CArray< std::pair< Square, int >, 2 > rook_drop
CArray< PieceMask, 2 > effect25_supported
CArray< BoardMask, 2 > knight_fork_squares
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static void setUp(const Weights &weights)
Definition ptypeEval.cc:63
static int eval(const NumEffectState &state)
Definition ptypeEval.cc:77
static CArray< int, 2 > eval(const NumEffectState &)
static int evalWithUpdateCompiled(const NumEffectState &state, Move moved, int last_value)
Definition piecePair.cc:595
static void compile(const Weights &values)
values を展開してクラス全体で使う
Definition piecePair.cc:365
static void sanitize(Weights &values)
Definition piecePair.cc:396
static int eval(const NumEffectState &, const Weights &)
Definition piecePair.cc:450
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
Definition eval_pin.cc:186
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_values)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(unsigned int ptypeo_mask)
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 MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state, const CArray2d< int, 2, 9 > &pawns)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static void eval(const NumEffectState &, MultiInt &out)
Definition mobility.cc:145
static MultiInt eval(const NumEffectState &state, const CArray2d< int, 2, 9 > &pawns)
Definition majorPiece.cc:84
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiInt eval(const NumEffectState &state)
static MultiIntPair eval(const NumEffectState &state, CArray< std::pair< Square, int >, 2 > &silver_drop)
unsigned int random()
Definition random.cc:4
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
@ ROOK
Definition basic_type.h:100
@ PPAWN
Definition basic_type.h:87
@ BISHOP
Definition basic_type.h:99
@ PROOK
Definition basic_type.h:92
@ PAWN
Definition basic_type.h:95
@ KING
Definition basic_type.h:93
@ KNIGHT
Definition basic_type.h:97
@ PTYPE_EMPTY
Definition basic_type.h:85
@ SILVER
Definition basic_type.h:98
@ GOLD
Definition basic_type.h:94
@ PBISHOP
Definition basic_type.h:91
@ LANCE
Definition basic_type.h:96
const int PTYPE_SIZE
Definition basic_type.h:107
bool isMajorBasic(Ptype ptype)
Definition basic_type.h:181
const int EndgameIndex
Definition midgame.h:16
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
Definition basic_type.h:157
@ WHITE
Definition basic_type.h:10
@ BLACK
Definition basic_type.h:9
@ PTYPEO_MIN
Definition basic_type.h:200
bool isMajorNonPieceOK(Ptype ptype)
Definition basic_type.h:190
constexpr Player alt(Player player)
Definition basic_type.h:13
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
Definition basic_type.h:264
static std::mutex initialize_mutex
#define DEBUGPRINT(x)
IntArrayReader(const int *a, size_t l)
static const std::string & home(const std::string &initialize_if_first_invocation="")
compile時に指定されたディレクトリを返す.
Definition oslConfig.cc:239
static void eval(const NumEffectState &, MultiInt &out)
Definition mobility.cc:225
static MultiInt eval(const NumEffectState &state)
Definition kingTable.cc:27
static void eval(const NumEffectState &, MultiInt &out)
Definition mobility.cc:280
CArray< int, PROGRESS_INDEPENDENT_FEATURE_LIMIT > progress_independent_values
CArray< MultiInt, STAGE_FEATURE_LIMIT > stage_values
static const char * name(ProgressIndependentFeature)
static MultiInt eval(const NumEffectState &state)
Definition kingTable.cc:331
static MultiInt evalWithUpdate(const NumEffectState &state, Move moved, const MultiInt &last_values)
Definition kingTable.cc:351
size_t dimension() const
Definition weights.h:29
void setValue(size_t index, int value)
Definition weights.h:31