17#if (defined(__i386__) || defined(__x86_64__)) && !defined(OSL_NO_SSE)
49template<osl::Player P>
53#ifdef ALLOW_KING_ABSENCE
54 if (kingSquare<P>().isPieceStand())
57 king8infos[P]=King8Info::make<altP>(*
this,kingSquare<P>()).uint64Value();
71 for(
int num=0;num<40;num++){
90 makeKing8Info<BLACK>();
92 makeKing8Info<WHITE>();
107 ppieces = pieces & promoted.getMask<
PAWN>();
116 ppieces = pieces & promoted.getMask<
LANCE>();
128 ppieces = effect.
getMask(index) & promoted.getMask(index);
129 pieces = effect.
getMask(index) & ~ppieces;
130 if (pieces.none() || ppieces.none())
131 return pieceOf(pieces.any() ? pieces.bsf() : ppieces.bsf());
132 const int num = pieces.bsf(), nump = ppieces.bsf();
135 return pieceOf(std::min(num, nump));
141 assert(! inCheck(P));
142 PieceMask pieces = piecesOnBoard(P) & effectedMask(
alt(P));
144 int pp=-1, npp=-1, ret=-1;
146 for (
int i=lance_index; i>=0; --i) {
147 mask_t all = nolance.
getMask(i);
148 mask_t promoted = all & promotedPieces().getMask(i);
149 mask_t notpromoted = all & ~promoted;
150 if (promoted.any()) {
151 pp = promoted.bsr() + i*32;
154 if (notpromoted.any())
155 npp = notpromoted.bsr() + i*32;
156 ret = std::max(pp, npp);
162 mask_t plance = lance & promotedPieces().getMask(lance_index);
164 return pieceOf(plance.bsr()+lance_index*32);
165 return pieceOf(lance.bsr()+lance_index*32);
179 const Square from = last_move.
from(), to = last_move.
to();
184 return hasEffectAt(turn(), from);
188 kingSquare(
alt(turn())))
190 kingSquare(
alt(turn())));
191 const Piece piece = pieceOnBoard(to);
192 if (! pin(
alt(turn())).test(piece.
number()))
203 assert(turn() == move.
player());
209 assert(isAlmostValidMove(move));
214 doDropMove(to,move.
ptype());
247 pin_or_open_backup, king_mobility_backup,
248 promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
253 pin_or_open_backup, king_mobility_backup,
254 promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
257 clearPawn(turn(),from);
264 int num0, num1, num1Index;
274 prologueCapture(
Player2Type<BLACK>(), from, to, target, promoteMask, oldPiece, oldPtypeO,
275 capturePtypeO,
newPtypeO, num0, num1, num1Index,num1Mask,
276 pin_or_open_backup, king_mobility_backup,
277 promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
280 prologueCapture(
Player2Type<WHITE>(), from, to, target, promoteMask, oldPiece, oldPtypeO,
281 capturePtypeO,
newPtypeO, num0, num1, num1Index,num1Mask,
282 pin_or_open_backup, king_mobility_backup,
283 promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
286 if (capturePtype==
PAWN)
287 clearPawn(
alt(turn()),to);
289 clearPawn(turn(),from);
306 prologueDrop(
Player2Type<BLACK>(), to, ptype, oldPiece, num, ptypeO, numIndex, numMask,
307 pin_or_open_backup, king_mobility_backup,
308 effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
311 prologueDrop(
Player2Type<WHITE>(), to, ptype, oldPiece, num, ptypeO, numIndex, numMask,
312 pin_or_open_backup, king_mobility_backup,
313 effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
319template<osl::Player P>
322 Piece& oldPiece,
int& num,
332 mobility_backup = effects.mobilityTable;
333 pin_or_open_backup = pin_or_open;
334 king_mobility_backup = king_mobility;
335 effected_mask_backup = effects.effected_mask;
336 effected_changed_mask_backup = effects.effected_changed_mask;
337 king8infos_backup=king8infos;
339 oldPiece=pieceAt(from);
344 oldPtypeO=oldPiece.
ptypeO();
345 new_ptypeo=newPiece.
ptypeO();
347 setPieceOf(num,newPiece);
348 effects.clearChangedEffects();
349 effects.clearEffectedChanged();
350 effects.template doEffect<NumBitmapEffect::Sub,true>(*
this,oldPtypeO,from,num);
353 effects.effectedNumTable[num].clear();
354 setBoard(to,newPiece);
355 effects.template doBlockAt<NumBitmapEffect::Sub,true>(*
this,to,num);
357 effects.template doBlockAt<NumBitmapEffect::Add,true>(*
this,from,num);
358 effects.template doEffect<NumBitmapEffect::Add,true>(*
this,new_ptypeo,to,num);
364 pin_or_open[P].reset(num);
365 recalcPinOpen(from,lastD,P);
366 recalcPinOpen(to,lastD,P);
370 pin_or_open[
alt(P)].reset(num);
371 recalcPinOpen(from,lastD,
alt(P));
372 recalcPinOpen(to,lastD,
alt(P));
374 promoted_backup = promoted;
377 if(hasEffectAt(
BLACK,to))
378 effects.effected_mask[
BLACK].set(num);
380 effects.effected_mask[
BLACK].reset(num);
381 if(hasEffectAt(
WHITE,to))
382 effects.effected_mask[
WHITE].set(num);
384 effects.effected_mask[
WHITE].reset(num);
385 effects.effected_changed_mask[
BLACK].set(num);
386 effects.effected_changed_mask[
WHITE].set(num);
391 if(changed.
anyInRange(Board_Mask_Table3x3.
mask(kingSquare<BLACK>()))
392 || pin_or_open[
BLACK]!=pin_or_open_backup[
BLACK])
393 makeKing8Info<BLACK>();
394 if(changed.
anyInRange(Board_Mask_Table3x3.
mask(kingSquare<WHITE>()))
395 || pin_or_open[
WHITE]!=pin_or_open_backup[
WHITE])
396 makeKing8Info<WHITE>();
411 setPieceOf(num,oldPiece);
413 setBoard(from,oldPiece);
414 effects.effectedNumTable[num].clear();
419 effects.invalidateChangedEffects();
420 pin_or_open = pin_or_open_backup;
421 king_mobility = king_mobility_backup;
422 promoted = promoted_backup;
423 effects.effected_mask = effected_mask_backup;
424 effects.effected_changed_mask = effected_changed_mask_backup;
425 effects.mobilityTable = mobility_backup;
426 king8infos = king8infos_backup;
429template<osl::Player P>
433 int& numIndex, mask_t& numMask,
441 king8infos_backup = king8infos;
442 mobility_backup = effects.mobilityTable;
443 pin_or_open_backup = pin_or_open;
444 king_mobility_backup = king_mobility;
445 effected_mask_backup = effects.effected_mask;
446 effected_changed_mask_backup = effects.effected_changed_mask;
447#if OSL_WORDSIZE == 64
449#elif OSL_WORDSIZE == 32
452 const mask_t ownMochigoma=
454 assert(ownMochigoma.any());
455 numMask=ownMochigoma.lowestBit();
456 int numLow = ownMochigoma.bsf();
457 num = numLow|(numIndex<<5);
458 oldPiece=pieceOf(num);
459 Piece newPiece=oldPiece;
462 setPieceOf(num,newPiece);
463 effects.clearChangedEffects();
464 effects.clearEffectedChanged();
465 effects.template doBlockAt<NumBitmapEffect::Sub,true>(*
this,to,num);
466 effects.template doEffect<NumBitmapEffect::Add,true>(*
this,ptypeO,to,num);
467 setBoard(to,newPiece);
468 standMask(P).xorMask(numIndex,numMask);
470 pieces_onboard[P].xorMask(numIndex,numMask);
473 recalcPinOpen(to,lastD,P);
477 recalcPinOpen(to,lastD,
alt(P));
479 if(hasEffectAt(
BLACK,to))
480 effects.effected_mask[
BLACK].set(num);
482 effects.effected_mask[
BLACK].reset(num);
483 if (hasEffectAt(
WHITE,to))
484 effects.effected_mask[
WHITE].set(num);
486 effects.effected_mask[
WHITE].reset(num);
487 effects.effected_changed_mask[
BLACK].set(num);
488 effects.effected_changed_mask[
WHITE].set(num);
492 if(changed.
anyInRange(Board_Mask_Table3x3.
mask(kingSquare<BLACK>()))
493 || pin_or_open[
BLACK]!=pin_or_open_backup[
BLACK])
494 makeKing8Info<BLACK>();
495 if(changed.
anyInRange(Board_Mask_Table3x3.
mask(kingSquare<WHITE>()))
496 || pin_or_open[
WHITE]!=pin_or_open_backup[
WHITE])
497 makeKing8Info<WHITE>();
501template<osl::Player P>
504 int num,
PtypeO ptypeO,
int numIndex, mask_t numMask,
512 standMask(P).xorMask(numIndex,numMask);
514 pieces_onboard[P].xorMask(numIndex,numMask);
516 effects.template doEffect<NumBitmapEffect::Sub,false>(*
this,ptypeO,to,num);
517 effects.template doBlockAt<NumBitmapEffect::Add,false>(*
this,to,num);
518 setPieceOf(num,oldPiece);
519 effects.effectedNumTable[num].clear();
520 effects.invalidateChangedEffects();
521 pin_or_open = pin_or_open_backup;
522 king_mobility = king_mobility_backup;
523 effects.effected_mask = effected_mask_backup;
524 effects.effected_changed_mask = effected_changed_mask_backup;
525 effects.mobilityTable = mobility_backup;
526 king8infos = king8infos_backup;
529template<osl::Player P>
534 PtypeO& new_ptypeo,
int& num0,
int& num1,
535 int& num1Index, mask_t& num1Mask,
544 mobility_backup = effects.mobilityTable;
545 pin_or_open_backup = pin_or_open;
546 king_mobility_backup = king_mobility;
547 effected_mask_backup = effects.effected_mask;
548 effected_changed_mask_backup = effects.effected_changed_mask;
549 king8infos_backup = king8infos;
554 pieces_onboard[
alt(P)].xorMask(num1Index,num1Mask);
555 standMask(P).xorMask(num1Index,num1Mask);
556 oldPiece=pieceAt(from);
560 setPieceOf(num0,newPiece);
563 oldPtypeO=oldPiece.
ptypeO();
564 new_ptypeo=newPiece.
ptypeO();
565 capturePtypeO=target.
ptypeO();
567 effects.clearChangedEffects();
568 effects.clearEffectedChanged();
569 effects.setChangedPieces(effectSetAt(to));
570 effects.template doEffect<NumBitmapEffect::Sub,true>(*
this,capturePtypeO,to,num1);
571 effects.template doEffect<NumBitmapEffect::Sub,true>(*
this,oldPtypeO,from,num0);
573 effects.template doBlockAt<NumBitmapEffect::Add,true>(*
this,from,num0);
574 effects.effectedNumTable[num0]=effects.effectedNumTable[num1];
575 effects.effectedNumTable[num1].clear();
576 setBoard(to,newPiece);
577 effects.template doEffect<NumBitmapEffect::Add,true>(*
this,new_ptypeo,to,num0);
583 pin_or_open[P].reset(num0);
584 pin_or_open[P].reset(num1);
585 recalcPinOpen(from,lastD,P);
586 recalcPinOpen(to,lastD,P);
590 pin_or_open[
alt(P)].reset(num0);
591 pin_or_open[
alt(P)].reset(num1);
592 recalcPinOpen(from,lastD,
alt(P));
593 recalcPinOpen(to,lastD,
alt(P));
595 promoted_backup = promoted;
596 promoted.
reset(num1);
597 effects.effected_mask[
BLACK].reset(num1);
598 effects.effected_mask[
WHITE].reset(num1);
601 if(hasEffectAt(
BLACK,to))
602 effects.effected_mask[
BLACK].set(num0);
604 effects.effected_mask[
BLACK].reset(num0);
605 if(hasEffectAt(
WHITE,to))
606 effects.effected_mask[
WHITE].set(num0);
608 effects.effected_mask[
WHITE].reset(num0);
609 effects.effected_changed_mask[
BLACK].set(num0);
610 effects.effected_changed_mask[
WHITE].set(num0);
615 if(changed.
anyInRange(Board_Mask_Table3x3.
mask(kingSquare<BLACK>()))
616 || pin_or_open[
BLACK]!=pin_or_open_backup[
BLACK])
617 makeKing8Info<BLACK>();
618 if(changed.
anyInRange(Board_Mask_Table3x3.
mask(kingSquare<WHITE>()))
619 || pin_or_open[
WHITE]!=pin_or_open_backup[
WHITE])
620 makeKing8Info<WHITE>();
624template<osl::Player P>
629 int num1Index, mask_t num1Mask,
638 standMask(P).xorMask(num1Index,num1Mask);
640 pieces_onboard[
alt(P)].xorMask(num1Index,num1Mask);
641 effects.effectedNumTable[num1]=effects.effectedNumTable[num0];
642 effects.effectedNumTable[num0].clear();
643 setPieceOf(num0,oldPiece);
644 setPieceOf(num1,target);
645 effects.template doEffect<NumBitmapEffect::Sub,false>(*
this,
newPtypeO,to,num0);
646 setBoard(from,oldPiece);
648 effects.template doBlockAt<NumBitmapEffect::Sub,false>(*
this,from,num0);
649 effects.template doEffect<NumBitmapEffect::Add,false>(*
this,capturePtypeO,to,num1);
650 effects.template doEffect<NumBitmapEffect::Add,false>(*
this,oldPtypeO,from,num0);
651 effects.invalidateChangedEffects();
652 pin_or_open = pin_or_open_backup;
653 king_mobility = king_mobility_backup;
654 promoted = promoted_backup;
655 effects.effected_mask = effected_mask_backup;
656 effects.effected_changed_mask = effected_changed_mask_backup;
657 effects.mobilityTable = mobility_backup;
658 king8infos = king8infos_backup;
668 std::cerr <<
"error before effect\n";
672 if (!(effects1==effects))
676 std::cerr <<
"Effect error 1" << std::endl;
678 for(
int y=1;y<=9;y++)
682 if (!(effects1.
effectSetAt(pos)==effects.effectSetAt(pos)))
684 std::cerr << pos <<
",real=" << effects.effectSetAt(pos) <<
",ideal=" << effects1.
effectSetAt(pos) << std::endl;
687 for(
int num=0;num<=39;num++){
688 for(
int i=0;i<8;i++){
691 std::cerr <<
"piece=" << pieceOf(num) <<
",num=" << num <<
",d=" << d <<
",v1=" << effects.effectedNumTable[num][d] <<
",v2=" << effects1.
effectedNumTable[num][d] << std::endl;
695 std::cerr << effects.effectedNumTable << std::endl;
699 for (
int z=0; z<2; ++z) {
701#ifdef ALLOW_KING_ABSENCE
702 if (kingSquare(p).isPieceStand())
706 const PieceMask pin2 = effect_util::Pin::make(*
this, p);
707 if (pin(p) != pin2) {
709 std::cerr <<
"pin for " << p <<
" differs " << pin(p) <<
" " << pin2 <<
"\n";
716 std::cerr <<
"king8info for " << p <<
" differs \n" <<
King8Info(Iking8Info(p)) <<
"\n" << king8info2 <<
"\n";
721 const Piece p = pieceOf(i);
725 std::cerr <<
"promoted differs " << p <<
" " << promoted <<
" " << promoted.test(i) <<
"\n";
738 = {{ changedEffects(
BLACK), changedEffects(
WHITE) }};
742 each_effect[i].clear();
743 prev_effect[i].clear();
745 for (
int x=1; x<=9; ++x) {
746 for (
int y=1; y<=9; ++y) {
749 if (effectSetAt(sq).test(i))
750 each_effect[i].set(sq);
752 prev_effect[i].set(sq);
754 if (! changed_all.
test(sq))
759 std::cerr <<
"changedEffects unset\n" << *
this << moved << sq <<
"\n";
764 for (
int i=0; i<2; ++i)
767 if (! changed_squares[pl].test(sq))
769 if ((effectSetAt(sq) & piecesOnBoard(pl))
773 std::cerr <<
"changedEffects unset for " << pl <<
"\n" << *
this << moved << sq <<
"\n";
784 if (each_effect[i] == prev_effect[i])
786 if (! changed_effect_pieces.
test(i)) {
789 std::cerr <<
"changedPieces() unset\n" << *
this << moved << i
790 <<
" " << each_effect[i] <<
" != " << prev_effect[i] <<
"\n";
798 for (
int j=0; j<2; ++j)
804 if (! effectedChanged(pl).test(i)) {
807 std::cerr <<
"effectedChanged(" << pl <<
") unset\n" << *
this << moved << i
818template <
bool show_error>
820#if (defined __GNUC__) && (! defined GPSONE) && (! defined GPSUSIONE)
826 assert(this->turn() == move.
player());
827 assert(isValidMoveByRule(move,
true));
831 return isAlmostValidDrop<show_error>(move);
833 const Piece from_piece = this->pieceAt(from);
835 if (! testValidityOtherThanEffect<show_error>(move))
837 if(!hasEffectByPiece(from_piece,to)){
839 std::cerr <<
" No such move2 : " << move << std::endl;
852 return isAlmostValidMove<true>(move);
854 return isAlmostValidMove<false>(move);
860 os<< static_cast<SimpleState const&>(*
this);
861 for(
int y=1;y<=9;y++){
863 for(
int x=9;x>0;x--){
865 os <<
csa::show(pieceAt(pos)) << effectSetAt(pos);
871 if (standMask(
BLACK).test(num)){
875 else if (standMask(
WHITE).test(num)){
889 makePinOpenDir<UL>(target,pins,mask,defense);
890 makePinOpenDir<U>(target,pins,mask,defense);
891 makePinOpenDir<UR>(target,pins,mask,defense);
892 makePinOpenDir<L>(target,pins,mask,defense);
893 makePinOpenDir<R>(target,pins,mask,defense);
894 makePinOpenDir<DL>(target,pins,mask,defense);
895 makePinOpenDir<D>(target,pins,mask,defense);
896 makePinOpenDir<DR>(target,pins,mask,defense);
903 pin_or_open[defense]=makePinOpen(kingSquare(defense),defense);
911 return allEffectAt<PAWN>(attack, target);
913 return allEffectAt<LANCE>(attack, target);
915 return allEffectAt<KNIGHT>(attack, target);
917 return allEffectAt<SILVER>(attack, target);
919 return allEffectAt<GOLD>(attack, target);
921 return allEffectAt<BISHOP>(attack, target);
923 return allEffectAt<ROOK>(attack, target);
925 return allEffectAt<KING>(attack, target);
938#if (defined(__i386__) || defined(__x86_64__)) && !defined(OSL_NO_SSE)
940 v2di b16=*((v2di*)&src.
board[16]);
941 v2di b20=*((v2di*)&src.
board[20]);
942 v2di b24=*((v2di*)&src.
board[24]);
943 v2di b32=*((v2di*)&src.
board[32]);
944 v2di b36=*((v2di*)&src.
board[36]);
945 v2di b40=*((v2di*)&src.
board[40]);
946 v2di b48=*((v2di*)&src.
board[48]);
947 v2di b52=*((v2di*)&src.
board[52]);
948 v2di b56=*((v2di*)&src.
board[56]);
950 *((v2di*)&(*this).board[16])=b16;
951 *((v2di*)&(*this).board[20])=b20;
952 *((v2di*)&(*this).board[24])=b24;
953 *((v2di*)&(*this).board[32])=b32;
954 *((v2di*)&(*this).board[36])=b36;
955 *((v2di*)&(*this).board[40])=b40;
956 *((v2di*)&(*this).board[48])=b48;
957 *((v2di*)&(*this).board[52])=b52;
958 *((v2di*)&(*this).board[56])=b56;
961 v2di b64=*((v2di*)&src.
board[64]);
962 v2di b68=*((v2di*)&src.
board[68]);
963 v2di b72=*((v2di*)&src.
board[72]);
965 v2di b80=*((v2di*)&src.
board[80]);
966 v2di b84=*((v2di*)&src.
board[84]);
967 v2di b88=*((v2di*)&src.
board[88]);
969 v2di b96=*((v2di*)&src.
board[96]);
970 v2di b100=*((v2di*)&src.
board[100]);
971 v2di b104=*((v2di*)&src.
board[104]);
974 *((v2di*)&(*this).board[64])=b64;
975 *((v2di*)&(*this).board[68])=b68;
976 *((v2di*)&(*this).board[72])=b72;
978 *((v2di*)&(*this).board[80])=b80;
979 *((v2di*)&(*this).board[84])=b84;
980 *((v2di*)&(*this).board[88])=b88;
982 *((v2di*)&(*this).board[96])=b96;
983 *((v2di*)&(*this).board[100])=b100;
984 *((v2di*)&(*this).board[104])=b104;
986 v2di b112=*((v2di*)&src.
board[112]);
987 v2di b116=*((v2di*)&src.
board[116]);
988 v2di b120=*((v2di*)&src.
board[120]);
990 v2di b128=*((v2di*)&src.
board[128]);
991 v2di b132=*((v2di*)&src.
board[132]);
992 v2di b136=*((v2di*)&src.
board[136]);
994 v2di b144=*((v2di*)&src.
board[144]);
995 v2di b148=*((v2di*)&src.
board[148]);
996 v2di b152=*((v2di*)&src.
board[152]);
998 *((v2di*)&(*this).board[112])=b112;
999 *((v2di*)&(*this).board[116])=b116;
1000 *((v2di*)&(*this).board[120])=b120;
1002 *((v2di*)&(*this).board[128])=b128;
1003 *((v2di*)&(*this).board[132])=b132;
1004 *((v2di*)&(*this).board[136])=b136;
1006 *((v2di*)&(*this).board[144])=b144;
1007 *((v2di*)&(*this).board[148])=b148;
1008 *((v2di*)&(*this).board[152])=b152;
1010 v2di p0=*((v2di*)&src.
pieces[0]);
1011 v2di p4=*((v2di*)&src.
pieces[4]);
1012 v2di p8=*((v2di*)&src.
pieces[8]);
1013 v2di p12=*((v2di*)&src.
pieces[12]);
1014 v2di p16=*((v2di*)&src.
pieces[16]);
1015 v2di p20=*((v2di*)&src.
pieces[20]);
1016 v2di p24=*((v2di*)&src.
pieces[24]);
1017 v2di p28=*((v2di*)&src.
pieces[28]);
1018 v2di p32=*((v2di*)&src.
pieces[32]);
1019 v2di p36=*((v2di*)&src.
pieces[36]);
1020 *((v2di*)&(*this).pieces[0])=p0;
1021 *((v2di*)&(*this).pieces[4])=p4;
1022 *((v2di*)&(*this).pieces[8])=p8;
1023 *((v2di*)&(*this).pieces[12])=p12;
1024 *((v2di*)&(*this).pieces[16])=p16;
1025 *((v2di*)&(*this).pieces[20])=p20;
1026 *((v2di*)&(*this).pieces[24])=p24;
1027 *((v2di*)&(*this).pieces[28])=p28;
1028 *((v2di*)&(*this).pieces[32])=p32;
1029 *((v2di*)&(*this).pieces[36])=p36;
1032 for(
int x=1;x<=9;x++)
1033 for(
int y=1;y<=9;y++)
1035 (*this).pieces=src.
pieces;
1040 effects.copyFrom(src.
effects);
1055 using namespace move_classifier;
1056 return ConditionAdaptor<SafeMove>::isMember(*
this, move);
1060 using namespace move_classifier;
1061 return PlayerMoveAdaptor<Check>::isMember(*
this, move);
1065 using namespace move_classifier;
1066 return PlayerMoveAdaptor<PawnDropCheckmate>::isMember(*
this, move);
1070 using namespace move_classifier;
1071 return PlayerMoveAdaptor<DirectCheck>::isMember(*
this, move);
1076 using namespace move_classifier;
1077 return ConditionAdaptor<OpenCheck>::isMember(*
this, move);
1098 std::copy_if(all_moves.
begin(), all_moves.
end(), std::back_inserter(moves),
1100 return this->isSafeMove(m) && ! this->isPawnDropCheckmate(m);
1107 generateLegal(moves);
1110 for (
int i=0, iend=moves.
size(); i<iend; ++i) {
1111 const Move move = moves[i];
1122 forEachEffect(P, target, store);
1129 template bool NumEffectState::
1131 template bool NumEffectState::
1133 template void NumEffectState::makeKing8Info<BLACK>();
1134 template void NumEffectState::makeKing8Info<WHITE>();
1195 NumEffectState::safeCaptureNotByKing<BLACK>(
Square,
Piece)
const;
1197 NumEffectState::safeCaptureNotByKing<WHITE>(
Square,
Piece)
const;
Direction getShort8Unsafe(Square from, Square to) const
8方向にいない場合も適当なものを返す.
bool isBetweenSafe(Square t, Square p0, Square p1) const
void push_back(const T &e)
const Move unpromote() const
promote moveからunpromote moveを作る
PtypeO capturePtypeO() const
bool isNormal() const
INVALID でも PASS でもない.
int promoteMask() const
pieceに使うためのmaskなので
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
bool hasIgnoredUnpromote() const
MoveをunpromoteするとcutUnpromoteなMoveになる
const Square from() const
void generateLegal(MoveVector &) const
全ての合法手を生成する.
const NumBitmapEffect effectSetAt(Square sq) const
void doCaptureMove(Square from, Square to, Piece target, int promoteMask)
const checkmate::King8Info king8Info(Player king) const
void epilogueCapture(Player2Type< P >, Square from, Square to, Piece target, Piece oldPiece, PtypeO oldPtypeO, PtypeO capturePtypeO, PtypeO newPtypeO, int num0, int num1, int num1Index, mask_t num1Mask, const CArray< PieceMask, 2 > &pin_or_open_backup, const KingMobility &king_mobility_backup, const PieceMask &promoted_backup, const CArray< PieceMask, 2 > &effected_mask_backup, const CArray< PieceMask, 2 > &effected_changed_mask_backup, const CArray< uint64_t, 2 > &king8infos_backup, const MobilityTable &mobility_backup)
bool isOpenCheck(Move move) const
CArray< PieceMask, 2 > pieces_onboard
const Piece selectCheapPiece(PieceMask effect) const
利きの中から安そうな駒を選ぶ
bool isPawnDropCheckmate(Move move) const
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
void doSimpleMove(Square from, Square to, int promoteMask)
void prologueCapture(Player2Type< P >, Square from, Square to, Piece target, int promoteMask, Piece &oldPiece, PtypeO &oldPtypeO, PtypeO &capturePtypeO, PtypeO &new_ptypeo, int &num0, int &num1, int &num1Index, mask_t &num1Mask, CArray< PieceMask, 2 > &pin_or_open_backup, KingMobility &king_mobility_backup, PieceMask &promoted_backup, CArray< PieceMask, 2 > &effected_mask_backup, CArray< PieceMask, 2 > &effected_changed_mask_backup, CArray< uint64_t, 2 > &king8infos_backup, MobilityTable &mobility_backup)
bool wasCheckEvasion(Move last_move) const
bool isAlmostValidMove(Move move) const
合法手かどうかを簡単に検査する.局面に依存するチェックのみ. ルール上指せない手である可能性がある場合は,isValidMove を用いる.
const PieceMask effectedChanged(Player pl) const
前の指手でeffectedMask(pl)が変化したか.
void copyFrom(const NumEffectState &src)
主要部分を高速にコピーする.
void generateAllUnsafe(MoveVector &) const
自殺を含めてすべての手を生成
PieceMask makePinOpen(Square target, Player defense)
bool isDirectCheck(Move move) const
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
void prologueSimple(Player2Type< P >, Square from, Square to, int promoteMask, Piece &oldPiece, int &num, PtypeO &oldPtypeO, PtypeO &new_ptypeo, CArray< PieceMask, 2 > &pin_or_open_backup, KingMobility &king_mobility_backup, PieceMask &promoted_backup, CArray< PieceMask, 2 > &effected_mask_backup, CArray< PieceMask, 2 > &effected_changed_mask_backup, CArray< uint64_t, 2 > &king8infos_backup, MobilityTable &mobility_backup)
NumEffectState(const SimpleState &st=SimpleState(HIRATE))
const Piece findThreatenedPiece(Player P) const
取られそうなPの駒で価値が最大のもの
effect::NumSimpleEffectTable effects
void findEffect(Player P, Square target, PieceVector &out) const
target に利きのあるPieceをoutに格納する
void doDropMove(Square to, Ptype ptype)
void epilogueSimple(Square from, Square to, Piece oldPiece, int num, PtypeO oldPtypeO, PtypeO newPtypeO, const CArray< PieceMask, 2 > &pin_or_open_backup, const KingMobility &king_mobility_backup, const PieceMask &promoted_backup, const CArray< PieceMask, 2 > &effected_mask_backup, const CArray< PieceMask, 2 > &effected_changed_mask_backup, const CArray< uint64_t, 2 > &king8infos_backup, const MobilityTable &mobility_backup)
KingMobility king_mobility
void showEffect(std::ostream &os) const
CArray< uint64_t, 2 > king8infos
CArray< PieceMask, 2 > pin_or_open
bool isSafeMove(Move move) const
const PieceMask & piecesOnBoard(Player p) const
void epilogueDrop(Player2Type< P >, Square to, Ptype ptype, Piece oldPiece, int num, PtypeO ptypeO, int numIndex, mask_t numMask, const CArray< PieceMask, 2 > &pin_or_open_backup, const KingMobility &king_mobility_backup, const CArray< PieceMask, 2 > &effected_mask_backup, const CArray< PieceMask, 2 > &effected_changed_mask_backup, const CArray< uint64_t, 2 > &king8infos_backup, const MobilityTable &mobility_backup)
bool isConsistent(bool showError=true) const
void prologueDrop(Player2Type< P >, Square to, Ptype ptype, Piece &oldPiece, int &num, PtypeO &ptypeO, int &numIndex, mask_t &numMask, CArray< PieceMask, 2 > &pin_or_open_backup, KingMobility &king_mobility_backup, CArray< PieceMask, 2 > &effected_mask_backup, CArray< PieceMask, 2 > &effected_changed_mask_backup, CArray< uint64_t, 2 > &king8infos_backup, MobilityTable &mobility_backup)
bool isCheck(Move move) const
const mask_t allEffectAt(Player P, Square target) const
void generateWithFullUnpromotions(MoveVector &) const
打歩詰め絡み以外では有利にはならない手も含め, 全ての合法手を生成す る(Move::ignoredUnpromoteも生成する).
const mask_t getMask(int num) const
void clearBit()
unpromote(PTYPE) の駒のbit を消す
static const mask_t numToMask(int num)
const mask_t selectBit() const
unpromote(PTYPE) の駒のbit だけ取り出す
Ptype getPtypeOf(int num) const
bool isPromoted() const
promoteした駒かどうかをチェックする
const Square square() const
const Piece promoteWithMask(int promote_mask) const
static const Piece EMPTY()
const Piece captured() const
取られたpieceを作成.
int getIndex(Ptype) const
mask_t getMaskLow(Ptype ptype) const
CArray< BitXmask, 2 > pawnMask
CArray< Piece, Square::SIZE > board
CArray< CArray< char, PTYPE_SIZE-PTYPE_BASIC_MIN >, 2 > stand_count
bool isOnBoard(int num) const
CArray< PieceMask, 2 > stand_mask
CArray< Piece, Piece::SIZE > pieces
全てのpieceが登録されている
const Piece pieceOf(int num) const
bool isConsistent(bool show_error=true) const
unsigned int index() const
bool isPieceStand() const
static const Square STAND()
uint64_t uint64Value() const
static const King8Info make(NumEffectState const &state, Square king, PieceMask pinned)
const BoardMask & mask(Square p) const
p中心の3x3 の範囲のbitを立てたもの, centeringなし
bool test(unsigned int i) const
bool anyInRange(const BoardMask &mask) const
static int numToIndex(int)
EffectedNumTable effectedNumTable
effected num
const NumBitmapEffect effectSetAt(Square pos) const
ある位置の利きデータを取り出す.
CArray< PieceMask, 2 > effected_mask
CArray< PieceMask, 2 > effected_changed_mask
static void generate(const NumEffectState &state, Action &action)
const std::string show(Move)
const PtypeTable Ptype_Table
Ptype getPtype(PtypeO ptypeO)
const PieceTable Piece_Table
constexpr Player indexToPlayer(int n)
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に,promote前の型を返す. promoteしていない型の時はそのまま返す
const BoardTable Board_Table
constexpr Direction primDirUnsafe(Direction d)
8方向について,primitiveな4方向を求める dとしてknight, INVALIDなども来る
const PtypeO PTYPEO_EDGE __attribute__((unused))
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
constexpr Direction primDir(Direction d)
8方向について,primitiveな4方向を求める
constexpr Player alt(Player player)
PtypeO newPtypeO(Player player, Ptype ptype)
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に,ownerを反転する.
bool operator==(Square l, Square r)
static void generate(Player p, const NumEffectState &state, MoveVector &)
static void generate(const NumEffectState &state, MoveVector &out)
不成の受けも作成