My Project
majorPiece.h
Go to the documentation of this file.
1/* majorPiece.h
2 */
3
4#ifndef EVAL_ML_MAJORPIECE_H
5#define EVAL_ML_MAJORPIECE_H
6
7#include "osl/eval/weights.h"
8#include "osl/eval/midgame.h"
10#include <cstdlib>
11
12namespace osl
13{
14 namespace eval
15 {
16 namespace ml
17 {
18 template <bool Opening, Ptype MajorBasic>
19 class MajorY
20 {
21 private:
23 static int index(Piece piece)
24 {
25 return ((piece.owner() == BLACK) ? (piece.square().y() - 1) :
26 (9 - piece.square().y())) + (piece.isPromoted() ? 9 : 0);
27 }
28 public:
29 enum { DIM = 18 };
30 static void setUp(const Weights &weights);
31 static int eval(const NumEffectState &state)
32 {
33 int value = 0;
35 i < PtypeTraits<MajorBasic>::indexLimit;
36 ++i)
37 {
38 const Piece piece = state.pieceOf(i);
39 if (piece.isOnBoard())
40 {
41 if (piece.owner() == BLACK)
42 value += table[index(piece)];
43 else
44 value -= table[index(piece)];
45 }
46 }
47 return value;
48 }
49 };
50
51 class RookYOpening : public MajorY<true, ROOK>
52 {
53 };
54 class RookYEnding : public MajorY<false, ROOK>
55 {
56 };
57 class BishopYOpening : public MajorY<true, BISHOP>
58 {
59 };
60 class BishopYEnding : public MajorY<false, BISHOP>
61 {
62 };
63
64 template <bool Opening>
66 {
67 public:
68 enum { DIM = 1 };
69 static void setUp(const Weights &weights);
70 static int eval(const NumEffectState &state);
71 private:
72 static int weight;
73 };
74 class RookPawnOpening : public RookPawn<true>
75 {
76 };
77 class RookPawnEnding : public RookPawn<false>
78 {
79 };
80
82 {
83 friend class RookPawnYX;
84 public:
85 enum { ONE_DIM = 180, DIM = ONE_DIM * EvalStages };
86 static void setUp(const Weights &weights);
87 static MultiInt eval(const NumEffectState &state,
88 const CArray2d<int, 2, 9> &pawns);
89 private:
90 static int index(const Piece rook, const int pawn_y)
91 {
92 const int rook_y =
93 (rook.owner() == BLACK ? rook.square().y() : 10 - rook.square().y());
94 return (rook_y - 1) * 10 + pawn_y + (rook.isPromoted() ? 90 : 0);
95 }
96 static int indexY(const Square king,
97 const Piece rook, int pawn_y)
98 {
99 const int x_diff = std::abs(rook.square().x() - king.x());
100 const int rook_y =
101 (rook.owner() == BLACK ? rook.square().y() : 10 - rook.square().y());
102 return x_diff * 10 * 9 + (rook_y - 1) * 10 + pawn_y + (rook.isPromoted() ? 810 : 0);
103 }
107 };
108
110 {
111 public:
112 enum { ONE_DIM = 1620, DIM = ONE_DIM * 2*EvalStages };
113 static void setUp(const Weights &weights);
114 };
115
117 {
118 public:
119 enum { DIM = 1 };
120 static void setUp(const Weights &weights,int stage);
121 static MultiInt eval(int black_major_count)
122 {
123 if (black_major_count == 4)
124 return weight;
125 else if (black_major_count == 0)
126 return -weight;
127
128 return MultiInt();
129 }
130 private:
132 };
133
134 template <bool Opening>
136 {
137 public:
138 enum { DIM = 32 };
139 static void setUp(const Weights &weights);
140 static int eval(const NumEffectState &state);
141 static int index(const NumEffectState &state, Piece piece);
142 template <Ptype PTYPE>
143 static int evalOne(const NumEffectState &state);
144 private:
146 };
147
152 {
153 };
154
156 {
157 friend class RookEffectPiece;
158 public:
159 enum { ONE_DIM = 612, DIM = ONE_DIM * 2 };
160 static MultiInt eval(const NumEffectState &state);
161 protected:
162 template<Player P>
163 static MultiInt evalOne(const NumEffectState& state,
164 Square rook,
165 Square myKing,
166 Square opKing,
167 Square up,
168 Square dp,
169 Square rp,
170 Square lp,
171 bool isP);
177 static int index(int abs_x_diff, int y_diff, bool horizontal, bool is_promoted)
178 {
179 return y_diff + 8 + abs_x_diff * 17 + (horizontal ? 153 : 0) +
180 (is_promoted ? 306 : 0);
181 }
190 static int index0(int abs_x_diff,int y_diff,
191 PtypeO ptypeO,
192 bool horizontal, bool promoted){
193 return y_diff+8+abs_x_diff*17+(ptypeO - PTYPEO_MIN) * 17 * 9 +
194 (horizontal ? 4896 : 0) + (promoted ? 9792 : 0);
195 }
205 static int index1(Square king,Square from,PtypeO ptypeO,bool isP)
206 {
207 int y_diff=from.y()-king.y();
208 int x_diff=from.x()-king.x();
209 return index1(x_diff,y_diff,ptypeO,isP);
210 }
219 static int index1(int x_diff,int y_diff,PtypeO ptypeO,bool isP){
220 assert(-9 <= y_diff && y_diff <= 9);
221 assert(-9 <= x_diff && x_diff <= 9);
222 assert(getPtype((PtypeO)ptypeO)!=PTYPE_EMPTY);
223 int index=(ptypeO-PTYPEO_MIN)+32*((y_diff+9)+19*(x_diff+9+19*(isP ? 1 : 0)));
224 assert(0<=index && index<32*19*19*2);
225 return index;
226 }
234 static int index2(Square king,Square from,bool isP)
235 {
236 int y_diff=from.y()-king.y();
237 int x_diff=from.x()-king.x();
238 return index2(x_diff,y_diff,isP);
239 }
246 static int index2(int x_diff,int y_diff,bool isP){
247 assert(-9 <= y_diff && y_diff <= 9);
248 assert(-9 <= x_diff && x_diff <= 9);
249 int index=(y_diff+9)+19*(x_diff+9+19*(isP ? 1 : 0));
250 assert(0<=index && index<19*19*2);
251 return index;
252 }
266 };
268 {
269 public:
270 static void setUp(const Weights &weights,int stage);
271 };
272
274 {
275 public:
276 enum { DIM = 32 * EvalStages };
277 static void setUp(const Weights &weights);
278 };
280 {
281 public:
282 enum { ONE_DIM = 19584, DIM = ONE_DIM * 2*EvalStages };
283 static void setUp(const Weights & weights);
284 };
285
287 {
289 public:
290 enum { ONE_DIM = 256, DIM = ONE_DIM * EvalStages };
291 static void setUp(const Weights &weights);
292 static MultiInt eval(const NumEffectState &state);
293 private:
296 };
297
299 {
300 public:
301 enum { ONE_DIM = 144, DIM = ONE_DIM * EvalStages };
302 static void setUp(const Weights &weights);
303 private:
304 };
305
307 {
308 friend class BishopEffectPiece;
309 public:
310 enum { ONE_DIM = 612, DIM = ONE_DIM * 2 };
311 static MultiInt eval(const NumEffectState &state);
312 protected:
313 template<Player P>
314 static MultiInt evalOne(const NumEffectState& state,
315 Square bishop,
316 Square myKing,
317 Square opKing,
318 Square ulp,
319 Square urp,
320 Square dlp,
321 Square drp,
322 bool isP);
323 static int index(int x_diff, int y_diff, bool ur, bool promoted)
324 {
325 if (x_diff<0)
326 ur = !ur;
327 return y_diff + 8 + std::abs(x_diff) * 17 + (ur ? 153 : 0) + (promoted ? 306 : 0);
328 }
329 static int index0(int x_diff, int y_diff,PtypeO ptypeO,bool ur, bool promoted)
330 {
331 if (x_diff>0)
332 ur = !ur;
333 return -y_diff + 8 + std::abs(x_diff) * 17 + (ptypeO - PTYPEO_MIN) * 17 * 9 +
334 (ur ? 4896 : 0) + (promoted ? 9792 : 0);
335 }
345 static int index1(Square king,Square from,PtypeO ptypeO,bool isP)
346 {
347 int y_diff=from.y()-king.y();
348 int x_diff=from.x()-king.x();
349 return index1(x_diff,y_diff,ptypeO,isP);
350 }
359 static int index1(int x_diff,int y_diff,PtypeO ptypeO,bool isP){
360 assert(-9 <= y_diff && y_diff <= 9);
361 assert(-9 <= x_diff && x_diff <= 9);
362 assert(getPtype((PtypeO)ptypeO)!=PTYPE_EMPTY);
363 int index=(ptypeO-PTYPEO_MIN)+32*((y_diff+9)+19*(x_diff+9+19*(isP ? 1 : 0)));
364 assert(0<=index && index<32*19*19*2);
365 return index;
366 }
374 static int index2(Square king,Square from,bool isP)
375 {
376 int y_diff=from.y()-king.y();
377 int x_diff=from.x()-king.x();
378 return index2(x_diff,y_diff,isP);
379 }
386 static int index2(int x_diff,int y_diff,bool isP){
387 assert(-9 <= y_diff && y_diff <= 9);
388 assert(-9 <= x_diff && x_diff <= 9);
389 int index=(y_diff+9)+19*(x_diff+9+19*(isP ? 1 : 0));
390 assert(0<=index && index<19*19*2);
391 return index;
392 }
406 };
408 {
409 public:
410 static void setUp(const Weights &weights,int stage);
411 };
413 {
414 public:
415 enum { DIM = 32*EvalStages };
416 static void setUp(const Weights &weights);
417 };
418
420 {
421 public:
422 enum { ONE_DIM = 19584, DIM = ONE_DIM * 2*EvalStages };
423 static void setUp(const Weights & weights);
424 };
425
427 {
429 friend class BishopHeadX;
430 public:
431 enum { ONE_DIM = 32, DIM = ONE_DIM * EvalStages };
432 static void setUp(const Weights &weights);
433 static MultiInt eval(const NumEffectState &state);
434 private:
435 static int indexK(Player player, PtypeO ptypeO, int x_diff, int y_diff)
436 {
437 if (player == WHITE)
438 {
439 ptypeO=(PtypeO)(static_cast<int>(ptypeO)^(~15));
440 }
441 if (player == WHITE)
442 {
443 y_diff = -y_diff;
444 }
445 return (ptypeOIndex(ptypeO) * 9 + x_diff) * 17 + y_diff + 8;
446 }
447 template <Player P>
448 static int indexX(PtypeO ptypeO, int x)
449 {
450 if (x > 5)
451 {
452 x = 10 - x;
453 }
454 if (P == WHITE)
455 {
456 ptypeO = altIfPiece(ptypeO);
457 }
458 return x - 1 + 5 * ptypeOIndex(ptypeO);
459 }
463 };
464
466 {
467 public:
468 enum { ONE_DIM = 4896, DIM = ONE_DIM * EvalStages };
469 static void setUp(const Weights &weights);
470 };
472 {
473 public:
474 enum { ONE_DIM = 160, DIM = ONE_DIM * EvalStages };
475 static void setUp(const Weights &weights);
476 };
478 {
479 public:
480 enum { ONE_DIM = 374544, DIM = ONE_DIM * EvalStages };
481 static void setUp(const Weights &weights);
482 template<Player King>
483 static MultiInt evalOne(const NumEffectState &state);
484 static MultiInt eval(const NumEffectState &state);
485 private:
487 template <Player King>
488 static int index(const Square king, const Piece rook, const Piece bishop)
489 {
490 const int rook_x = std::abs(king.x() - rook.square().x());
491 const int bishop_x = std::abs(king.x() - bishop.square().x());
492 const int rook_y = (King == BLACK ? rook.square().y() - king.y() : king.y() - rook.square().y());
493 const int bishop_y = (King == BLACK ? bishop.square().y() - king.y() : king.y() - bishop.square().y());
494 return bishop_y + 8 + 17 * (bishop_x + 9 * (rook_y + 8 + 17 * (rook_x + 9 * ((bishop.owner() == King ? 1 : 0) + 2 * ((rook.owner() == King ? 1 : 0) + 2 * (2 * (bishop.isPromoted() ? 1 : 0) + (rook.isPromoted() ? 1 : 0)))))));
495 }
496 };
497
499 {
503 public:
504 static MultiInt eval(const NumEffectState &state);
505 private:
506 static void countBetween(const NumEffectState &state,
507 Square king, Piece bishop,
508 int &self_count, int &opp_count,
509 int &total_count);
513 };
515 {
516 public:
517 enum { ONE_DIM = 9, DIM = ONE_DIM * EvalStages };
518 static void setUp(const Weights &weights);
519 };
521 {
522 public:
523 enum { ONE_DIM = 9, DIM = ONE_DIM * EvalStages };
524 static void setUp(const Weights &weights);
525 };
527 {
528 public:
529 enum { ONE_DIM = 9, DIM = ONE_DIM * EvalStages };
530 static void setUp(const Weights &weights);
531 };
533 {
534 public:
535 enum { ONE_DIM = 64, DIM = ONE_DIM * EvalStages };
536 static void setUp(const Weights &weights);
537 static MultiInt eval(const NumEffectState &state);
538 private:
539 static int index(Ptype ptype, bool self_with_support,
540 bool opp_with_support)
541 {
542 return ptype + PTYPE_SIZE * ((self_with_support ? 1 : 0) +
543 2 * (opp_with_support ? 1 : 0));
544 }
546 };
547
549 {
550 public:
551 enum { ONE_DIM = 800, DIM = ONE_DIM * EvalStages };
552 static void setUp(const Weights &weights);
553 static MultiInt eval(const NumEffectState &state);
554 private:
555 template <bool SamePlayer, Player P>
556 static int index(Piece rook1, Piece rook2)
557 {
558 const int y1 = (rook1.isOnBoard() ? rook1.square().y() : 0);
559 const int y2 = (rook2.isOnBoard() ? rook2.square().y() : 0);
560 if (SamePlayer)
561 {
562 if (P == BLACK)
563 {
564 return y1 + 10 *
565 (y2 + 10 * ((rook1.isPromoted() ? 1 : 0) + 2 *
566 ((rook2.isPromoted() ? 1 : 0) + 2 *
567 (SamePlayer ? 1 : 0))));
568 }
569 else
570 {
571 if (y1 == 0 || y2 == 0 || y1 == y2)
572 {
573 return (10 - y1) % 10 + 10 *
574 ((10 - y2) % 10 + 10 * ((rook1.isPromoted() ? 1 : 0) + 2 *
575 ((rook2.isPromoted() ? 1 : 0) + 2 *
576 (SamePlayer ? 1 : 0))));
577 }
578 else
579 {
580 return (10 - y2) % 10 + 10 *
581 ((10 - y1) % 10 + 10 * ((rook2.isPromoted() ? 1 : 0) + 2 *
582 ((rook1.isPromoted() ? 1 : 0) + 2 *
583 (SamePlayer ? 1 : 0))));
584 }
585 }
586 }
587 else
588 {
589 return y1 + 10 *
590 (y2 + 10 * ((rook1.isPromoted() ? 1 : 0) + 2 *
591 ((rook2.isPromoted() ? 1 : 0) + 2 *
592 (SamePlayer ? 1 : 0))));
593 }
594 }
595 static int index(bool same_player, bool promoted1,
596 bool promoted2, int y1, int y2)
597 {
598 return y1 + 10 *
599 (y2 + 10 * ((promoted1 ? 1 : 0) + 2 *
600 ((promoted2 ? 1 : 0) + 2 *
601 (same_player ? 1 : 0))));
602 }
604 };
605
607 {
608 public:
609 enum { ONE_DIM = 128, DIM = ONE_DIM * EvalStages };
610 static void setUp(const Weights &weights);
611 static MultiInt eval(const NumEffectState &state);
612 private:
613 static int index(Ptype ptype, bool self_with_support,
614 bool opp_with_support, bool vertical)
615 {
616 return ptype + PTYPE_SIZE * ((self_with_support ? 1 : 0) +
617 2 * (opp_with_support ? 1 : 0)) +
618 (vertical ? PTYPE_SIZE * 2 * 2 : 0);
619 }
621 };
622
624 {
625 public:
626 enum { ONE_DIM = 32, DIM = ONE_DIM * EvalStages };
627 static void setUp(const Weights &weights);
628 static MultiInt eval(const NumEffectState &state);
629 private:
631 };
632
634 {
635 public:
636 enum {
637 ONE_DIM = PTYPE_SIZE * 2/*bishop or rook*/ * 2 /*promotable*/,
639 };
640 static void setUp(const Weights &weights);
641 static MultiInt eval(const NumEffectState &state);
642 private:
644 template <Player Owner>
645 static MultiInt addOne(const NumEffectState &state);
646 static size_t index(Ptype ptype, bool is_rook, bool can_promote)
647 {
648 return ptype * 4 + is_rook * 2 + can_promote;
649 }
650 };
651
653 {
654 public:
655 enum {
656 ONE_DIM = 5 * 9 * 9 * 9 * 9 * 9,
658 };
659 static void setUp(const Weights &weights);
660 static MultiInt eval(const NumEffectState &state);
661 private:
663 static size_t index(int rook_x, int rook_y, int silver_x, int silver_y,
664 int knight_x, int knight_y)
665 {
666 return knight_y + 9 * (knight_x + 9 * (silver_y + 9 * (silver_x + 9 * (rook_y + 9 * rook_x))));
667 }
668 };
669
671 {
672 public:
673 enum {
674 ONE_DIM = 5 * 9 * 9 * 9 * 9 * 9,
676 };
677 static void setUp(const Weights &weights);
678 static MultiInt eval(const NumEffectState &state);
679 private:
681 static size_t index(int bishop_x, int bishop_y, int silver_x, int silver_y,
682 int knight_x, int knight_y)
683 {
684 return knight_y + 9 * (knight_x + 9 * (silver_y + 9 * (silver_x + 9 * (bishop_y + 9 * bishop_x))));
685 }
686 };
687
689 {
690 public:
691 enum {
694 };
695 static void setUp(const Weights &weights);
696 static MultiInt eval(const NumEffectState &state);
697 private:
699 size_t maxActive() const { return 4; }
700 static int index(Ptype support, Ptype attack, bool has_gold,
701 bool rook_support, bool bishop_support)
702 {
703 return (unpromoteSafe(support)*16 + unpromoteSafe(attack))*8+has_gold*4
704 +rook_support*2+bishop_support;
705 }
706 template <Player Owner>
707 static void addOne(const NumEffectState &state, Piece rook, MultiInt&);
708 };
709 }
710 }
711}
712
713#endif // EVAL_ML_MAJORPIECE_H
714// ;;; Local Variables:
715// ;;; mode:c++
716// ;;; c-basic-offset:2
717// ;;; End:
利きを持つ局面
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
const Piece pieceOf(int num) const
Definition simpleState.h:76
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
static MultiInt eval(int black_major_count)
Definition majorPiece.h:121
static MultiInt weight
Definition majorPiece.h:131
static void setUp(const Weights &weights, int stage)
static int index(Ptype support, Ptype attack, bool has_gold, bool rook_support, bool bishop_support)
Definition majorPiece.h:700
static void addOne(const NumEffectState &state, Piece rook, MultiInt &)
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:698
static void setUp(const Weights &weights)
static int index(Ptype ptype, bool self_with_support, bool opp_with_support)
Definition majorPiece.h:539
static CArray< MultiInt, 64 > table
Definition majorPiece.h:545
static void setUp(const Weights &weights)
static CArray< MultiInt, 612 > defense_table
Definition majorPiece.h:394
static int index2(int x_diff, int y_diff, bool isP)
黒の角(馬)がある場所は空マスでないのでその分を補正するテーブル {attack,defense}_nospace へのアクセス (x_diff, y_diff) - 玉を基準にしてみた角(馬)の相対位...
Definition majorPiece.h:386
static CArray< MultiInt, 23104 > defense_ur
Definition majorPiece.h:400
static CArray< MultiInt, 23104 > attack_ur
Definition majorPiece.h:396
static CArray< MultiInt, 23104 > defense_dr
Definition majorPiece.h:402
static CArray< MultiInt, 612 > attack_table
Definition majorPiece.h:393
static int index0(int x_diff, int y_diff, PtypeO ptypeO, bool ur, bool promoted)
Definition majorPiece.h:329
static CArray< MultiInt, 23104 > attack_dr
Definition majorPiece.h:398
static int index(int x_diff, int y_diff, bool ur, bool promoted)
Definition majorPiece.h:323
static int index1(int x_diff, int y_diff, PtypeO ptypeO, bool isP)
黒の角(馬)からの利きのある駒のindex {attack,defense}_{ul,ur,dl,dr} へのアクセスに使う (x_diff, y_diff) - 玉を基準に見た駒の相対位置 ptype...
Definition majorPiece.h:359
static CArray< MultiInt, 722 > attack_nospace
Definition majorPiece.h:404
static int index1(Square king, Square from, PtypeO ptypeO, bool isP)
黒の角(馬)からの利きのある駒のindex {attack,defense}_{ul,ur,dl,dr} へのアクセスに使う from - 駒の位置 king - 玉の位置 ptypeO - 駒の種類,...
Definition majorPiece.h:345
static CArray< MultiInt, 722 > defense_nospace
Definition majorPiece.h:405
static CArray< MultiInt, 32 > piece_table
Definition majorPiece.h:395
static int index2(Square king, Square from, bool isP)
黒の角(馬)がある場所は空マスでないのでその分を補正するテーブル {attack,defense}_nospace へのアクセス king - 玉の位置 from - 角(馬)の位置 isP - 馬の場...
Definition majorPiece.h:374
static CArray< MultiInt, 23104 > defense_dl
Definition majorPiece.h:403
static CArray< MultiInt, 23104 > attack_ul
Definition majorPiece.h:397
static CArray< MultiInt, 23104 > defense_ul
Definition majorPiece.h:401
static CArray< MultiInt, 23104 > attack_dl
Definition majorPiece.h:399
static MultiInt evalOne(const NumEffectState &state, Square bishop, Square myKing, Square opKing, Square ulp, Square urp, Square dlp, Square drp, bool isP)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, 32 > table
Definition majorPiece.h:460
static int indexK(Player player, PtypeO ptypeO, int x_diff, int y_diff)
Definition majorPiece.h:435
static int indexX(PtypeO ptypeO, int x)
Definition majorPiece.h:448
static void setUp(const Weights &weights)
static CArray< MultiInt, 4896 > king_table
Definition majorPiece.h:461
static CArray< MultiInt, 160 > x_table
Definition majorPiece.h:462
static size_t index(int bishop_x, int bishop_y, int silver_x, int silver_y, int knight_x, int knight_y)
Definition majorPiece.h:681
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:680
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, 32 > table
Definition majorPiece.h:630
static CArray< MultiInt, 374544 > table
Definition majorPiece.h:486
static int index(const Square king, const Piece rook, const Piece bishop)
Definition majorPiece.h:488
static void setUp(const Weights &weights)
static MultiInt evalOne(const NumEffectState &state)
static size_t index(Ptype ptype, bool is_rook, bool can_promote)
Definition majorPiece.h:646
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:643
static void setUp(const Weights &weights)
static MultiInt addOne(const NumEffectState &state)
static int evalOne(const NumEffectState &state)
static int index(const NumEffectState &state, Piece piece)
static CArray< int, 32 > table
Definition majorPiece.h:145
static void setUp(const Weights &weights)
static CArray< int, 18 > table
Definition majorPiece.h:22
static void setUp(const Weights &weights)
Definition majorPiece.cc:12
static int index(Piece piece)
Definition majorPiece.h:23
static int eval(const NumEffectState &state)
Definition majorPiece.h:31
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static CArray< MultiInt, 9 > opp_table
Definition majorPiece.h:511
static CArray< MultiInt, 9 > all_table
Definition majorPiece.h:512
static CArray< MultiInt, 9 > self_table
Definition majorPiece.h:510
static MultiInt eval(const NumEffectState &state)
static void countBetween(const NumEffectState &state, Square king, Piece bishop, int &self_count, int &opp_count, int &total_count)
static CArray< MultiInt, 23104 > attack_d
Definition majorPiece.h:257
static MultiInt evalOne(const NumEffectState &state, Square rook, Square myKing, Square opKing, Square up, Square dp, Square rp, Square lp, bool isP)
static int index1(int x_diff, int y_diff, PtypeO ptypeO, bool isP)
黒の飛車(竜)からの利きのある駒のindex {attack,defense}_{u,r,l,d} へのアクセスに使う (x_diff, y_diff) - 玉を基準に見た駒の相対位置 ptypeO -...
Definition majorPiece.h:219
static CArray< MultiInt, 23104 > defense_d
Definition majorPiece.h:261
static CArray< MultiInt, 23104 > defense_u
Definition majorPiece.h:260
static CArray< MultiInt, 612 > attack_table
Definition majorPiece.h:253
static int index0(int abs_x_diff, int y_diff, PtypeO ptypeO, bool horizontal, bool promoted)
黒の飛車(竜)から利きのある駒 (abs_x_diff, y_diff) - 駒を基準にした玉の相対位置 abs_x_diffは絶対値 ptypeO - 駒のptypeO,...
Definition majorPiece.h:190
static CArray< MultiInt, 23104 > attack_u
Definition majorPiece.h:256
static CArray< MultiInt, 23104 > attack_l
Definition majorPiece.h:258
static CArray< MultiInt, 23104 > attack_r
Definition majorPiece.h:259
static CArray< MultiInt, 722 > attack_nospace
Definition majorPiece.h:264
static CArray< MultiInt, 722 > defense_nospace
Definition majorPiece.h:265
static CArray< MultiInt, 23104 > defense_r
Definition majorPiece.h:263
static CArray< MultiInt, 612 > defense_table
Definition majorPiece.h:254
static int index2(int x_diff, int y_diff, bool isP)
黒の飛車(竜)がある場所は空マスでないのでその分を補正するテーブル {attack,defense}_nospace へのアクセス (x_diff, y_diff) - 玉を基準にしてみた飛車(竜)の相...
Definition majorPiece.h:246
static int index2(Square king, Square from, bool isP)
黒の飛車(竜)がある場所は空マスでないのでその分を補正するテーブル {attack,defense}_nospace へのアクセス king - 玉の位置 from - 飛車(竜)の位置 isP - 竜...
Definition majorPiece.h:234
static int index1(Square king, Square from, PtypeO ptypeO, bool isP)
黒の飛車(竜)からの利きのある駒のindex {attack,defense}_{u,r,l,d} へのアクセスに使う from - 駒の位置 king - 玉の位置 ptypeO - 駒の種類,白から...
Definition majorPiece.h:205
static int index(int abs_x_diff, int y_diff, bool horizontal, bool is_promoted)
(abs_x_diff, y_diff) - 玉を原点とした時の空マスの相対位置 horizontal - 飛車の横利きがある場合 is_promoted - 竜の場合
Definition majorPiece.h:177
static CArray< MultiInt, 32 > piece_table
Definition majorPiece.h:255
static CArray< MultiInt, 23104 > defense_l
Definition majorPiece.h:262
static void setUp(const Weights &weights)
static void setUp(const Weights &weights)
static void setUp(const Weights &weights, int stage)
static void setUp(const Weights &weights)
Definition majorPiece.cc:60
static CArray< MultiInt, 180 > table
Definition majorPiece.h:104
static void setUp(const Weights &weights)
Definition majorPiece.cc:74
static int indexY(const Square king, const Piece rook, int pawn_y)
Definition majorPiece.h:96
static CArray< MultiInt, 1620 > y_attack_table
Definition majorPiece.h:105
static CArray< MultiInt, 1620 > y_defense_table
Definition majorPiece.h:106
static int index(const Piece rook, const int pawn_y)
Definition majorPiece.h:90
static void setUp(const Weights &weights)
Definition majorPiece.cc:26
static void setUp(const Weights &weights)
static CArray< MultiInt, 256 > promote_defense_table
Definition majorPiece.h:294
static CArray< MultiInt, 144 > promote_defense_rook_table
Definition majorPiece.h:295
static void setUp(const Weights &weights)
static CArray< MultiInt, 128 > table
Definition majorPiece.h:620
static int index(Ptype ptype, bool self_with_support, bool opp_with_support, bool vertical)
Definition majorPiece.h:613
static void setUp(const Weights &weights)
static int index(bool same_player, bool promoted1, bool promoted2, int y1, int y2)
Definition majorPiece.h:595
static void setUp(const Weights &weights)
static int index(Piece rook1, Piece rook2)
Definition majorPiece.h:556
static CArray< MultiInt, 800 > table
Definition majorPiece.h:603
static void setUp(const Weights &weights)
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:662
static size_t index(int rook_x, int rook_y, int silver_x, int silver_y, int knight_x, int knight_y)
Definition majorPiece.h:663
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
@ PTYPE_EMPTY
Definition basic_type.h:85
const int PTYPE_SIZE
Definition basic_type.h:107
Ptype getPtype(PtypeO ptypeO)
Definition basic_type.h:217
constexpr Ptype unpromoteSafe(Ptype ptype)
Definition basic_type.h:164
unsigned int ptypeOIndex(PtypeO ptypeo)
Definition basic_type.h:205
QuadInt MultiInt
Definition midgame.h:13
Player
Definition basic_type.h:8
@ WHITE
Definition basic_type.h:10
@ BLACK
Definition basic_type.h:9
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition basic_type.h:199
@ PTYPEO_MIN
Definition basic_type.h:200
const int EvalStages
Definition midgame.h:12
PtypeO altIfPiece(PtypeO ptypeO)
Pieceの時にはowner を反転する
Definition basic_type.h:281