1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
|
/* numEffectState.cc
*/
#include "osl/state/numEffectState.h"
#include "osl/state/numEffectState.tcc"
#include "osl/state/simpleState.tcc"
#include "osl/effect/numSimpleEffect.tcc"
#include <iostream>
#if (defined(__i386__) || defined(__x86_64__)) && !defined(OSL_NO_SSE)
#include <emmintrin.h>
typedef __v2di v2di;
#endif
bool osl::state::operator==(const NumEffectState& st1,
const NumEffectState& st2)
{
assert(st1.isConsistent(true));
assert(st2.isConsistent(true));
if (!(st1.effects == st2.effects))
return false;
if (!(st1.pieces_onboard == st2.pieces_onboard))
return false;
if (!(st1.promoted == st2.promoted))
return false;
if (!(st1.pin_or_open == st2.pin_or_open))
return false;
if (!(st1.king_mobility == st2.king_mobility))
return false;
if (!(st1.king8infos == st2.king8infos))
return false;
return (static_cast<const SimpleState&>(st1)
== static_cast<const SimpleState&>(st2));
}
const osl::checkmate::King8Info osl::state::
NumEffectState::king8Info(Player king) const
{
return King8Info(Iking8Info(king));
}
template<osl::Player P>
void osl::state::NumEffectState::makeKing8Info()
{
const Player altP=PlayerTraits<P>::opponent;
#ifdef ALLOW_KING_ABSENCE
if (kingSquare<P>().isPieceStand())
return;
#endif
king8infos[P]=King8Info::make<altP>(*this,kingSquare<P>()).uint64Value();
}
osl::state::
NumEffectState::NumEffectState(const SimpleState& st)
: SimpleState(st),effects(st)
{
pieces_onboard[0].resetAll();
pieces_onboard[1].resetAll();
promoted.resetAll();
effects.effected_mask[0].resetAll();
effects.effected_mask[1].resetAll();
effects.effected_changed_mask[0].resetAll();
effects.effected_changed_mask[1].resetAll();
for(int num=0;num<40;num++){
Piece p=pieceOf(num);
if (p.isOnBoard()){
pieces_onboard[p.owner()].set(num);
if (p.isPromoted())
promoted.set(num);
for(int i=0;i<2;i++){
Player pl=indexToPlayer(i);
if(hasEffectAt(pl,p.square()))
{
effects.effected_mask[i].set(num);
effects.effected_changed_mask[i].set(num);
}
}
}
}
makePinOpen(BLACK);
makePinOpen(WHITE);
if(kingSquare<BLACK>().isOnBoard())
makeKing8Info<BLACK>();
if(kingSquare<WHITE>().isOnBoard())
makeKing8Info<WHITE>();
}
osl::state::
NumEffectState::~NumEffectState()
{
}
const osl::Piece osl::state::
NumEffectState::selectCheapPiece(PieceMask effect) const
{
if (! effect.any())
return Piece::EMPTY();
mask_t pieces = effect.selectBit<PAWN>(), ppieces;
if (pieces.any())
{
ppieces = pieces & promoted.getMask<PAWN>();
pieces &= ~ppieces;
if (pieces.any())
return pieceOf(pieces.bsf()+PtypeFuns<PAWN>::indexNum*32);
return pieceOf(ppieces.bsf()+PtypeFuns<PAWN>::indexNum*32);
}
pieces = effect.selectBit<LANCE>();
if (pieces.any())
{
ppieces = pieces & promoted.getMask<LANCE>();
pieces &= ~ppieces;
if (pieces.any())
return pieceOf(pieces.bsf()+PtypeFuns<LANCE>::indexNum*32);
return pieceOf(ppieces.bsf()+PtypeFuns<LANCE>::indexNum*32);
}
mask_t king = effect.selectBit<KING>();
effect.clearBit<KING>();
if (effect.none())
return pieceOf(king.bsf()+PtypeFuns<KING>::indexNum*32);
// depends on current piece numbers: <FU 0>, KE 18, GI 22, KI 26, <OU 30>, <KY 32>, KA 36, HI 38,
#if OSL_WORDSIZE == 64
const int index = 0;
#else
const int index = effect.getMask(0).any() ? 0 : 1;
#endif
ppieces = effect.getMask(index) & promoted.getMask(index);
pieces = effect.getMask(index) & ~ppieces;
const int num = pieces.any()
? (ppieces.any() ? std::min(pieces.bsf(),ppieces.bsf()) : pieces.bsf())
: ppieces.bsf();
return pieceOf(num + index*32);
}
const osl::Piece osl::state::
NumEffectState::findThreatenedPiece(Player P) const
{
assert(! inCheck(P));
PieceMask pieces = piecesOnBoard(P) & effectedMask(alt(P));
PieceMask nolance = pieces; nolance.clearBit<LANCE>();
int pp=-1, npp=-1, ret=-1;
const int lance_index = PtypeFuns<LANCE>::indexNum; // 64bit: 0, 32bit: 1
for (int i=lance_index; i>=0; --i) {
mask_t all = nolance.getMask(i);
mask_t promoted = all & promotedPieces().getMask(i);
mask_t notpromoted = all & ~promoted;
if (promoted.any()) {
pp = promoted.bsr() + i*32;
notpromoted &= ~Ptype_Table.getMaskLow(Piece_Table.getPtypeOf(pp));
}
if (notpromoted.any())
npp = notpromoted.bsr() + i*32;
ret = std::max(pp, npp);
if (ret >= PtypeTraits<KNIGHT>::indexMin)
return pieceOf(ret);
}
mask_t lance = pieces.selectBit<LANCE>();
if (lance.any()) {
mask_t plance = lance & promotedPieces().getMask(lance_index);
if (plance.any())
return pieceOf(plance.bsr()+lance_index*32);
return pieceOf(lance.bsr()+lance_index*32);
}
if (ret >= 0) {
assert(Piece_Table.getPtypeOf(ret) == PAWN);
return pieceOf(ret);
}
return Piece::EMPTY();
}
bool osl::state::
NumEffectState::wasCheckEvasion(Move last_move) const
{
if (! last_move.isNormal())
return false;
const Square from = last_move.from(), to = last_move.to();
if (last_move.ptype() == KING) {
if (last_move.isCapture()
&& hasEffectIf(last_move.capturePtypeO(), to, from))
return true;
return hasEffectAt(turn(), from);
}
if (last_move.isCapture())
return hasEffectIf(last_move.capturePtypeO(), to,
kingSquare(alt(turn())))
&& !Board_Table.isBetweenSafe(from, to,
kingSquare(alt(turn())));
const Piece piece = pieceOnBoard(to);
if (! pin(alt(turn())).test(piece.number()))
return false;
if (last_move.isDrop() || last_move.oldPtype() == KNIGHT)
return true;
const Direction d=pinnedDir(piece);
return primDir(d)
!=primDirUnsafe(Board_Table.getShort8Unsafe(piece.owner(), from,to));
}
void osl::state::NumEffectState::makeMove(Move move)
{
assert(turn() == move.player());
if (move.isPass()) {
makeMovePass();
return;
}
assert(isAlmostValidMove(move));
const Square from=move.from();
const Square to=move.to();
if (from.isPieceStand())
{
doDropMove(to,move.ptype());
}
else
{
const Piece captured = pieceOnBoard(to);
if (captured != Piece::EMPTY())
{
doCaptureMove(from,to,captured,move.promoteMask());
}
else
{
doSimpleMove(from,to,move.promoteMask());
}
}
changeTurn();
}
void osl::state::NumEffectState::
doSimpleMove(Square from, Square to, int promoteMask)
{
Piece oldPiece;
int num;
PtypeO oldPtypeO, newPtypeO;
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;
mobility::MobilityTable mobilityTable;
if (turn()==BLACK){
prologueSimple(Player2Type<BLACK>(), from, to, promoteMask,
oldPiece, num, oldPtypeO, newPtypeO,
pin_or_open_backup, king_mobility_backup,
promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
}
else{
prologueSimple(Player2Type<WHITE>(), from, to, promoteMask,
oldPiece, num, oldPtypeO, newPtypeO,
pin_or_open_backup, king_mobility_backup,
promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
}
if (promoteMask!=0 && num < PtypeTraits<PAWN>::indexLimit)
clearPawn(turn(),from);
}
void osl::state::NumEffectState::
doCaptureMove(Square from, Square to, Piece target, int promoteMask)
{
Piece oldPiece;
PtypeO oldPtypeO, capturePtypeO, newPtypeO;
int num0, num1, 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;
mobility::MobilityTable mobilityTable;
if(turn()==BLACK){
prologueCapture(Player2Type<BLACK>(), from, to, target, promoteMask, oldPiece, oldPtypeO,
capturePtypeO, newPtypeO, num0, num1, num1Index,num1Mask,
pin_or_open_backup, king_mobility_backup,
promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
}
else{
prologueCapture(Player2Type<WHITE>(), from, to, target, promoteMask, oldPiece, oldPtypeO,
capturePtypeO, newPtypeO, num0, num1, num1Index,num1Mask,
pin_or_open_backup, king_mobility_backup,
promoted_backup, effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
}
const Ptype capturePtype=target.ptype();
if (capturePtype==PAWN)
clearPawn(alt(turn()),to);
if (promoteMask!=0 && num0<PtypeTraits<PAWN>::indexLimit)
clearPawn(turn(),from);
}
void osl::state::NumEffectState::
doDropMove(Square to,Ptype ptype)
{
Piece oldPiece;
PtypeO ptypeO;
int num, 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;
mobility::MobilityTable mobilityTable;
if(turn()==BLACK){
prologueDrop(Player2Type<BLACK>(), to, ptype, oldPiece, num, ptypeO, numIndex, numMask,
pin_or_open_backup, king_mobility_backup,
effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
}
else{
prologueDrop(Player2Type<WHITE>(), to, ptype, oldPiece, num, ptypeO, numIndex, numMask,
pin_or_open_backup, king_mobility_backup,
effected_mask_backup, effected_changed_mask_backup,king8infos_backup,mobilityTable);
}
if (ptype==PAWN)
setPawn(turn(),to);
}
template<osl::Player P>
void osl::state::NumEffectState::
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)
{
mobility_backup = effects.mobilityTable;
pin_or_open_backup = pin_or_open;
king_mobility_backup = king_mobility;
effected_mask_backup = effects.effected_mask;
effected_changed_mask_backup = effects.effected_changed_mask;
king8infos_backup=king8infos;
oldPiece=pieceAt(from);
Piece newPiece=oldPiece.promoteWithMask(promoteMask);
newPiece+=(to-from);
num=oldPiece.number();
oldPtypeO=oldPiece.ptypeO();
new_ptypeo=newPiece.ptypeO();
// 自分自身の効きを外す
setPieceOf(num,newPiece);
effects.clearChangedEffects();
effects.clearEffectedChanged();
effects.template doEffect<NumBitmapEffect::Sub,true>(*this,oldPtypeO,from,num);
// 自分自身がブロックしていたpromote?の延長
// あるいは自分自身のブロック
effects.effectedNumTable[num].clear();
setBoard(to,newPiece);
effects.template doBlockAt<NumBitmapEffect::Sub,true>(*this,to,num);
setBoard(from,Piece::EMPTY());
effects.template doBlockAt<NumBitmapEffect::Add,true>(*this,from,num);
effects.template doEffect<NumBitmapEffect::Add,true>(*this,new_ptypeo,to,num);
if (oldPtypeO == newPtypeO(P,KING))
makePinOpen(P);
else {
Direction lastD=UL;
pin_or_open[P].reset(num);
recalcPinOpen(from,lastD,P);
recalcPinOpen(to,lastD,P);
}
{
Direction lastD=UL;
pin_or_open[alt(P)].reset(num);
recalcPinOpen(from,lastD,alt(P));
recalcPinOpen(to,lastD,alt(P));
}
promoted_backup = promoted;
if (promoteMask)
promoted.set(num);
if(hasEffectAt(BLACK,to))
effects.effected_mask[BLACK].set(num);
else
effects.effected_mask[BLACK].reset(num);
if(hasEffectAt(WHITE,to))
effects.effected_mask[WHITE].set(num);
else
effects.effected_mask[WHITE].reset(num);
effects.effected_changed_mask[BLACK].set(num);
effects.effected_changed_mask[WHITE].set(num);
{
BoardMask changed=changedEffects(BLACK)|changedEffects(WHITE);
changed.set(from);
changed.set(to);
if(changed.anyInRange(Board_Mask_Table3x3.mask(kingSquare<BLACK>()))
|| pin_or_open[BLACK]!=pin_or_open_backup[BLACK])
makeKing8Info<BLACK>();
if(changed.anyInRange(Board_Mask_Table3x3.mask(kingSquare<WHITE>()))
|| pin_or_open[WHITE]!=pin_or_open_backup[WHITE])
makeKing8Info<WHITE>();
}
}
void osl::state::NumEffectState::
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)
{
setPieceOf(num,oldPiece);
effects.doEffect<NumBitmapEffect::Sub,false>(*this,newPtypeO,to,num);
setBoard(from,oldPiece);
effects.effectedNumTable[num].clear();
effects.doBlockAt<NumBitmapEffect::Sub,false>(*this,from,num);
setBoard(to,Piece::EMPTY());
effects.doBlockAt<NumBitmapEffect::Add,false>(*this,to,num);
effects.doEffect<NumBitmapEffect::Add,false>(*this,oldPtypeO,from,num);
effects.invalidateChangedEffects();
pin_or_open = pin_or_open_backup;
king_mobility = king_mobility_backup;
promoted = promoted_backup;
effects.effected_mask = effected_mask_backup;
effects.effected_changed_mask = effected_changed_mask_backup;
effects.mobilityTable = mobility_backup;
king8infos = king8infos_backup;
}
template<osl::Player P>
void osl::state::NumEffectState::
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)
{
king8infos_backup = king8infos;
mobility_backup = effects.mobilityTable;
pin_or_open_backup = pin_or_open;
king_mobility_backup = king_mobility;
effected_mask_backup = effects.effected_mask;
effected_changed_mask_backup = effects.effected_changed_mask;
#if OSL_WORDSIZE == 64
numIndex=0;
#elif OSL_WORDSIZE == 32
numIndex=Ptype_Table.getIndex(ptype);
#endif
const mask_t ownMochigoma=
standMask(P).getMask(numIndex) & Ptype_Table.getMaskLow(ptype);
assert(ownMochigoma.any());
numMask=ownMochigoma.lowestBit();
int numLow = ownMochigoma.bsf();
num = numLow|(numIndex<<5);
oldPiece=pieceOf(num);
Piece newPiece=oldPiece;
newPiece+=to-Square::STAND();
ptypeO=newPiece.ptypeO();
setPieceOf(num,newPiece);
effects.clearChangedEffects();
effects.clearEffectedChanged();
effects.template doBlockAt<NumBitmapEffect::Sub,true>(*this,to,num);
effects.template doEffect<NumBitmapEffect::Add,true>(*this,ptypeO,to,num);
setBoard(to,newPiece);
standMask(P).xorMask(numIndex,numMask);
stand_count[P][ptype-PTYPE_BASIC_MIN]--;
pieces_onboard[P].xorMask(numIndex,numMask);
{
Direction lastD=UL;
recalcPinOpen(to,lastD,P);
}
{
Direction lastD=UL;
recalcPinOpen(to,lastD,alt(P));
}
if(hasEffectAt(BLACK,to))
effects.effected_mask[BLACK].set(num);
else
effects.effected_mask[BLACK].reset(num);
if (hasEffectAt(WHITE,to))
effects.effected_mask[WHITE].set(num);
else
effects.effected_mask[WHITE].reset(num);
effects.effected_changed_mask[BLACK].set(num);
effects.effected_changed_mask[WHITE].set(num);
{
BoardMask changed=changedEffects(BLACK)|changedEffects(WHITE);
changed.set(to);
if(changed.anyInRange(Board_Mask_Table3x3.mask(kingSquare<BLACK>()))
|| pin_or_open[BLACK]!=pin_or_open_backup[BLACK])
makeKing8Info<BLACK>();
if(changed.anyInRange(Board_Mask_Table3x3.mask(kingSquare<WHITE>()))
|| pin_or_open[WHITE]!=pin_or_open_backup[WHITE])
makeKing8Info<WHITE>();
}
}
template<osl::Player P>
void osl::state::NumEffectState::
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)
{
standMask(P).xorMask(numIndex,numMask);
stand_count[P][ptype-PTYPE_BASIC_MIN]++;
pieces_onboard[P].xorMask(numIndex,numMask);
setBoard(to,Piece::EMPTY());
effects.template doEffect<NumBitmapEffect::Sub,false>(*this,ptypeO,to,num);
effects.template doBlockAt<NumBitmapEffect::Add,false>(*this,to,num);
setPieceOf(num,oldPiece);
effects.effectedNumTable[num].clear();
effects.invalidateChangedEffects();
pin_or_open = pin_or_open_backup;
king_mobility = king_mobility_backup;
effects.effected_mask = effected_mask_backup;
effects.effected_changed_mask = effected_changed_mask_backup;
effects.mobilityTable = mobility_backup;
king8infos = king8infos_backup;
}
template<osl::Player P>
void osl::state::NumEffectState::
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)
{
mobility_backup = effects.mobilityTable;
pin_or_open_backup = pin_or_open;
king_mobility_backup = king_mobility;
effected_mask_backup = effects.effected_mask;
effected_changed_mask_backup = effects.effected_changed_mask;
king8infos_backup = king8infos;
num1=target.number();
num1Index=PieceMask::numToIndex(num1);
num1Mask=PieceMask::numToMask(num1);
pieces_onboard[PlayerTraits<P>::opponent].xorMask(num1Index,num1Mask);
standMask(P).xorMask(num1Index,num1Mask);
oldPiece=pieceAt(from);
Piece newPiece=oldPiece.promoteWithMask(promoteMask);
newPiece+=(to-from);
num0=oldPiece.number();
setPieceOf(num0,newPiece);
setPieceOf(num1,target.captured());
oldPtypeO=oldPiece.ptypeO();
new_ptypeo=newPiece.ptypeO();
capturePtypeO=target.ptypeO();
stand_count[P][unpromote(getPtype(capturePtypeO))-PTYPE_BASIC_MIN]++;
effects.clearChangedEffects();
effects.clearEffectedChanged();
effects.setChangedPieces(effectSetAt(to));
effects.template doEffect<NumBitmapEffect::Sub,true>(*this,capturePtypeO,to,num1);
effects.template doEffect<NumBitmapEffect::Sub,true>(*this,oldPtypeO,from,num0);
setBoard(from,Piece::EMPTY());
effects.template doBlockAt<NumBitmapEffect::Add,true>(*this,from,num0);
effects.effectedNumTable[num0]=effects.effectedNumTable[num1];
effects.effectedNumTable[num1].clear();
setBoard(to,newPiece);
effects.template doEffect<NumBitmapEffect::Add,true>(*this,new_ptypeo,to,num0);
if (oldPtypeO == newPtypeO(P,KING))
makePinOpen(P);
else {
Direction lastD=UL;
pin_or_open[P].reset(num0);
pin_or_open[P].reset(num1); // captured is not pin
recalcPinOpen(from,lastD,P);
recalcPinOpen(to,lastD,P);
}
{
Direction lastD=UL;
pin_or_open[alt(P)].reset(num0);
pin_or_open[alt(P)].reset(num1); // captured is not pin
recalcPinOpen(from,lastD,alt(P));
recalcPinOpen(to,lastD,alt(P));
}
promoted_backup = promoted;
promoted.reset(num1);
effects.effected_mask[BLACK].reset(num1);
effects.effected_mask[WHITE].reset(num1);
if (promoteMask)
promoted.set(num0);
if(hasEffectAt(BLACK,to))
effects.effected_mask[BLACK].set(num0);
else
effects.effected_mask[BLACK].reset(num0);
if(hasEffectAt(WHITE,to))
effects.effected_mask[WHITE].set(num0);
else
effects.effected_mask[WHITE].reset(num0);
effects.effected_changed_mask[BLACK].set(num0);
effects.effected_changed_mask[WHITE].set(num0);
{
BoardMask changed=changedEffects(BLACK)|changedEffects(WHITE);
changed.set(from);
changed.set(to);
if(changed.anyInRange(Board_Mask_Table3x3.mask(kingSquare<BLACK>()))
|| pin_or_open[BLACK]!=pin_or_open_backup[BLACK])
makeKing8Info<BLACK>();
if(changed.anyInRange(Board_Mask_Table3x3.mask(kingSquare<WHITE>()))
|| pin_or_open[WHITE]!=pin_or_open_backup[WHITE])
makeKing8Info<WHITE>();
}
}
template<osl::Player P>
void osl::state::NumEffectState::
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)
{
standMask(P).xorMask(num1Index,num1Mask);
stand_count[P][unpromote(getPtype(capturePtypeO))-PTYPE_BASIC_MIN]--;
pieces_onboard[PlayerTraits<P>::opponent].xorMask(num1Index,num1Mask);
effects.effectedNumTable[num1]=effects.effectedNumTable[num0];
effects.effectedNumTable[num0].clear();
setPieceOf(num0,oldPiece);
setPieceOf(num1,target);
effects.template doEffect<NumBitmapEffect::Sub,false>(*this,newPtypeO,to,num0);
setBoard(from,oldPiece);
setBoard(to,target);
effects.template doBlockAt<NumBitmapEffect::Sub,false>(*this,from,num0);
effects.template doEffect<NumBitmapEffect::Add,false>(*this,capturePtypeO,to,num1);
effects.template doEffect<NumBitmapEffect::Add,false>(*this,oldPtypeO,from,num0);
effects.invalidateChangedEffects();
pin_or_open = pin_or_open_backup;
king_mobility = king_mobility_backup;
promoted = promoted_backup;
effects.effected_mask = effected_mask_backup;
effects.effected_changed_mask = effected_changed_mask_backup;
effects.mobilityTable = mobility_backup;
king8infos = king8infos_backup;
}
#ifndef MINIMAL
bool osl::state::NumEffectState::isConsistent(bool showError) const
{
if (!SimpleState::isConsistent(showError))
{
if (showError)
std::cerr << "error before effect\n";
return false;
}
effect::NumSimpleEffectTable effects1(*this);
if (!(effects1==effects))
{
if (showError)
{
std::cerr << "Effect error 1" << std::endl;
std::cerr << *this;
for(int y=1;y<=9;y++)
for(int x=9;x>0;x--)
{
Square pos(x,y);
if (!(effects1.effectSetAt(pos)==effects.effectSetAt(pos)))
{
std::cerr << pos << ",real=" << effects.effectSetAt(pos) << ",ideal=" << effects1.effectSetAt(pos) << std::endl;
}
}
for(int num=0;num<=39;num++){
for(int i=0;i<8;i++){
Direction d=static_cast<Direction>(i);
if(effects.effectedNumTable[num][d]!=effects1.effectedNumTable[num][d]){
std::cerr << "piece=" << pieceOf(num) << ",num=" << num << ",d=" << d << ",v1=" << effects.effectedNumTable[num][d] << ",v2=" << effects1.effectedNumTable[num][d] << std::endl;
}
}
}
std::cerr << effects.effectedNumTable << std::endl;
}
return false;
}
for (int z=0; z<2; ++z) {
const Player p = indexToPlayer(z);
#ifdef ALLOW_KING_ABSENCE
if (kingSquare(p).isPieceStand())
continue;
#endif
const PieceMask pin2 = effect_util::Pin::make(*this, p);
if (pin(p) != pin2) {
if (showError)
std::cerr << "pin for " << p << " differs " << pin(p) << " " << pin2 << "\n";
return false;
}
King8Info king8info2 = King8Info::make(alt(p), *this);
if (King8Info(Iking8Info(p)).uint64Value() != king8info2.uint64Value()) {
if (showError)
std::cerr << "king8info for " << p << " differs \n" << King8Info(Iking8Info(p)) << "\n" << king8info2 << "\n";
return false;
}
}
for (int i=0; i<Piece::SIZE; ++i) {
const Piece p = pieceOf(i);
if (p.isOnBoard()) {
if (promoted.test(i) != p.isPromoted()) {
if (showError)
std::cerr << "promoted differs " << p << " " << promoted << " " << promoted.test(i) << "\n";
return false;
}
}
}
return true;
}
#endif
bool osl::state::NumEffectState::isConsistent(const NumEffectState& prev, Move moved, bool show_error) const
{
// test changedEffects
const CArray<BoardMask,2> changed_squares
= {{ changedEffects(BLACK), changedEffects(WHITE) }};
const BoardMask changed_all = changed_squares[BLACK] | changed_squares[WHITE];
CArray<BoardMask, Piece::SIZE> each_effect, prev_effect;
for (int i=0; i<Piece::SIZE; ++i) {
each_effect[i].clear();
prev_effect[i].clear();
}
for (int x=1; x<=9; ++x) {
for (int y=1; y<=9; ++y) {
const Square sq(x, y);
for (int i=0; i<Piece::SIZE; ++i) {
if (effectSetAt(sq).test(i))
each_effect[i].set(sq);
if (prev.effectSetAt(sq).test(i))
prev_effect[i].set(sq);
}
if (! changed_all.test(sq))
{
if (effectSetAt(sq) != prev.effectSetAt(sq)) {
#ifndef MINIMAL
if (show_error)
std::cerr << "changedEffects unset\n" << *this << moved << sq << "\n";
#endif
return false;
}
}
for (int i=0; i<2; ++i)
{
const Player pl = indexToPlayer(i);
if (! changed_squares[pl].test(sq))
{
if ((effectSetAt(sq) & piecesOnBoard(pl))
!= (prev.effectSetAt(sq) & prev.piecesOnBoard(pl))) {
#ifndef MINIMAL
if (show_error)
std::cerr << "changedEffects unset for " << pl << "\n" << *this << moved << sq << "\n";
#endif
return false;
}
}
}
}
}
// test changedPieces()
const NumBitmapEffect changed_effect_pieces = changedPieces();
for (int i=0; i<Piece::SIZE; ++i) {
if (each_effect[i] == prev_effect[i])
continue;
if (! changed_effect_pieces.test(i)) {
#ifndef MINIMAL
if (show_error)
std::cerr << "changedPieces() unset\n" << *this << moved << i
<< " " << each_effect[i] << " != " << prev_effect[i] << "\n";
#endif
return false;
}
}
// test effectedChanged(Player pl)
for (int i=0; i<Piece::SIZE; ++i)
{
for (int j=0; j<2; ++j)
{
const Player pl = indexToPlayer(j);
if (prev.pieceOf(i).square() == moved.to())
continue; // captured
if (prev.effectedMask(pl).test(i) != effectedMask(pl).test(i)) {
if (! effectedChanged(pl).test(i)) {
#ifndef MINIMAL
if (show_error)
std::cerr << "effectedChanged(" << pl << ") unset\n" << *this << moved << i
<< " " << prev.effectedChanged(pl) << " != " << prev.effectedChanged(WHITE) << "\n";
#endif
return false;
}
}
}
}
return true;
}
template <bool show_error>
bool
#if (defined __GNUC__) && (! defined GPSONE) && (! defined GPSUSIONE)
__attribute__ ((used,noinline))
#endif
osl::state::NumEffectState::isAlmostValidMove(Move move) const{
assert(move.isValid());
assert(move.isNormal());
assert(this->turn() == move.player());
assert(isValidMoveByRule(move, true));
const Square from=move.from();
if (from.isPieceStand()) // 打つ手
return isAlmostValidDrop<show_error>(move);
const Square to=move.to();
const Piece from_piece = this->pieceAt(from);
if (! testValidityOtherThanEffect<show_error>(move))
return false;
if(!hasEffectByPiece(from_piece,to)){
if (show_error) {
std::cerr << " No such move2 : " << move << std::endl;
}
return false;
}
return true;
}
bool osl::state::NumEffectState::
isAlmostValidMove(Move move,bool show_error) const{
#ifdef MINIMAL
show_error=false;
#endif
if(show_error)
return isAlmostValidMove<true>(move);
else
return isAlmostValidMove<false>(move);
}
#ifndef MINIMAL
void osl::state::NumEffectState::showEffect(std::ostream& os) const
{
os<< static_cast<SimpleState const&>(*this);
for(int y=1;y<=9;y++){
os << 'P' << y;
for(int x=9;x>0;x--){
Square pos(x,y);
os << record::csa::show(pieceAt(pos)) << effectSetAt(pos);
}
os << std::endl;
}
// 持ち駒の表示
for(int num=0;num<Piece::SIZE;num++){
if (standMask(BLACK).test(num)){
os << "P+00" << record::csa::show(Piece_Table.getPtypeOf(num))
<< std::endl;
}
else if (standMask(WHITE).test(num)){
os << "P-00" << record::csa::show(Piece_Table.getPtypeOf(num))
<< std::endl;
}
}
}
#endif
osl::container::PieceMask osl::state::NumEffectState::
makePinOpen(osl::Square target,osl::Player defense)
{
PieceMask pins;
if(target.isPieceStand()) return pins;
PieceMask mask=piecesOnBoard(alt(defense));
makePinOpenDir<UL>(target,pins,mask,defense);
makePinOpenDir<U>(target,pins,mask,defense);
makePinOpenDir<UR>(target,pins,mask,defense);
makePinOpenDir<L>(target,pins,mask,defense);
makePinOpenDir<R>(target,pins,mask,defense);
makePinOpenDir<DL>(target,pins,mask,defense);
makePinOpenDir<D>(target,pins,mask,defense);
makePinOpenDir<DR>(target,pins,mask,defense);
return pins;
}
void osl::state::NumEffectState::
makePinOpen(osl::Player defense)
{
pin_or_open[defense]=makePinOpen(kingSquare(defense),defense);
}
const osl::mask_t osl::state::NumEffectState::
allEffectAt(Player attack, Ptype ptype, Square target) const
{
switch (ptype) {
case PAWN: case PPAWN:
return allEffectAt<PAWN>(attack, target);
case LANCE: case PLANCE:
return allEffectAt<LANCE>(attack, target);
case KNIGHT: case PKNIGHT:
return allEffectAt<KNIGHT>(attack, target);
case SILVER: case PSILVER:
return allEffectAt<SILVER>(attack, target);
case GOLD:
return allEffectAt<GOLD>(attack, target);
case BISHOP: case PBISHOP:
return allEffectAt<BISHOP>(attack, target);
case ROOK: case PROOK:
return allEffectAt<ROOK>(attack, target);
case KING:
return allEffectAt<KING>(attack, target);
default:
assert(0);
}
return mask_t();
}
void osl::state::NumEffectState::copyFrom(const NumEffectState& src)
{
#ifndef MINIMAL
(*this).used_mask=src.used_mask;
#endif
(*this).stand_mask=src.stand_mask;
#if (defined(__i386__) || defined(__x86_64__)) && !defined(OSL_NO_SSE)
{
v2di b16=*((v2di*)&src.board[16]);
v2di b20=*((v2di*)&src.board[20]);
v2di b24=*((v2di*)&src.board[24]);
v2di b32=*((v2di*)&src.board[32]);
v2di b36=*((v2di*)&src.board[36]);
v2di b40=*((v2di*)&src.board[40]);
v2di b48=*((v2di*)&src.board[48]);
v2di b52=*((v2di*)&src.board[52]);
v2di b56=*((v2di*)&src.board[56]);
*((v2di*)&(*this).board[16])=b16;
*((v2di*)&(*this).board[20])=b20;
*((v2di*)&(*this).board[24])=b24;
*((v2di*)&(*this).board[32])=b32;
*((v2di*)&(*this).board[36])=b36;
*((v2di*)&(*this).board[40])=b40;
*((v2di*)&(*this).board[48])=b48;
*((v2di*)&(*this).board[52])=b52;
*((v2di*)&(*this).board[56])=b56;
v2di b64=*((v2di*)&src.board[64]);
v2di b68=*((v2di*)&src.board[68]);
v2di b72=*((v2di*)&src.board[72]);
v2di b80=*((v2di*)&src.board[80]);
v2di b84=*((v2di*)&src.board[84]);
v2di b88=*((v2di*)&src.board[88]);
v2di b96=*((v2di*)&src.board[96]);
v2di b100=*((v2di*)&src.board[100]);
v2di b104=*((v2di*)&src.board[104]);
*((v2di*)&(*this).board[64])=b64;
*((v2di*)&(*this).board[68])=b68;
*((v2di*)&(*this).board[72])=b72;
*((v2di*)&(*this).board[80])=b80;
*((v2di*)&(*this).board[84])=b84;
*((v2di*)&(*this).board[88])=b88;
*((v2di*)&(*this).board[96])=b96;
*((v2di*)&(*this).board[100])=b100;
*((v2di*)&(*this).board[104])=b104;
v2di b112=*((v2di*)&src.board[112]);
v2di b116=*((v2di*)&src.board[116]);
v2di b120=*((v2di*)&src.board[120]);
v2di b128=*((v2di*)&src.board[128]);
v2di b132=*((v2di*)&src.board[132]);
v2di b136=*((v2di*)&src.board[136]);
v2di b144=*((v2di*)&src.board[144]);
v2di b148=*((v2di*)&src.board[148]);
v2di b152=*((v2di*)&src.board[152]);
*((v2di*)&(*this).board[112])=b112;
*((v2di*)&(*this).board[116])=b116;
*((v2di*)&(*this).board[120])=b120;
*((v2di*)&(*this).board[128])=b128;
*((v2di*)&(*this).board[132])=b132;
*((v2di*)&(*this).board[136])=b136;
*((v2di*)&(*this).board[144])=b144;
*((v2di*)&(*this).board[148])=b148;
*((v2di*)&(*this).board[152])=b152;
v2di p0=*((v2di*)&src.pieces[0]);
v2di p4=*((v2di*)&src.pieces[4]);
v2di p8=*((v2di*)&src.pieces[8]);
v2di p12=*((v2di*)&src.pieces[12]);
v2di p16=*((v2di*)&src.pieces[16]);
v2di p20=*((v2di*)&src.pieces[20]);
v2di p24=*((v2di*)&src.pieces[24]);
v2di p28=*((v2di*)&src.pieces[28]);
v2di p32=*((v2di*)&src.pieces[32]);
v2di p36=*((v2di*)&src.pieces[36]);
*((v2di*)&(*this).pieces[0])=p0;
*((v2di*)&(*this).pieces[4])=p4;
*((v2di*)&(*this).pieces[8])=p8;
*((v2di*)&(*this).pieces[12])=p12;
*((v2di*)&(*this).pieces[16])=p16;
*((v2di*)&(*this).pieces[20])=p20;
*((v2di*)&(*this).pieces[24])=p24;
*((v2di*)&(*this).pieces[28])=p28;
*((v2di*)&(*this).pieces[32])=p32;
*((v2di*)&(*this).pieces[36])=p36;
}
#else
for(int x=1;x<=9;x++)
for(int y=1;y<=9;y++)
(*this).board[Square(x,y).index()]=src.board[Square(x,y).index()];
(*this).pieces=src.pieces;
#endif
(*this).pawnMask=src.pawnMask;
this->stand_count = src.stand_count;
this->player_to_move=src.player_to_move;
effects.copyFrom(src.effects);
this->pieces_onboard=src.pieces_onboard;
(*this).promoted=src.promoted;
(*this).pin_or_open=src.pin_or_open;
(*this).king_mobility=src.king_mobility;
(*this).king8infos=src.king8infos;
}
void osl::state::NumEffectState::copyFrom(const SimpleState& src)
{
copyFrom(NumEffectState(src));
}
namespace osl
{
// explicit template instantiation
template bool NumEffectState::
hasEffectByWithRemove<BLACK>(Square, Square) const;
template bool NumEffectState::
hasEffectByWithRemove<WHITE>(Square, Square) const;
template void NumEffectState::makeKing8Info<BLACK>();
template void NumEffectState::makeKing8Info<WHITE>();
template void NumEffectState::
prologueSimple(Player2Type<BLACK>, Square, Square, int, Piece&, int&,
PtypeO&, PtypeO&, CArray<PieceMask,2>&, KingMobility&,
PieceMask&, CArray<PieceMask,2>&, CArray<PieceMask,2>&,
CArray<uint64_t,2>&, MobilityTable&);
template void NumEffectState::
prologueSimple(Player2Type<WHITE>, Square, Square, int, Piece&, int&,
PtypeO&, PtypeO&, CArray<PieceMask,2>&, KingMobility&,
PieceMask&, CArray<PieceMask,2>&, CArray<PieceMask,2>&,
CArray<uint64_t,2>&, MobilityTable&);
template void NumEffectState::
prologueCapture(Player2Type<BLACK>, Square, Square, Piece, int, Piece&,
PtypeO&, PtypeO&, PtypeO&, int&, int&, int&, mask_t&,
CArray<PieceMask,2>&, KingMobility&, PieceMask&,
CArray<PieceMask,2>&, CArray<PieceMask,2>&,
CArray<uint64_t,2>&, MobilityTable&);
template void NumEffectState::
prologueCapture(Player2Type<WHITE>, Square, Square, Piece, int, Piece&,
PtypeO&, PtypeO&, PtypeO&, int&, int&, int&, mask_t&,
CArray<PieceMask,2>&, KingMobility&, PieceMask&,
CArray<PieceMask,2>&, CArray<PieceMask,2>&,
CArray<uint64_t,2>&, MobilityTable&);
template void NumEffectState::
prologueDrop(Player2Type<BLACK>, Square, Ptype, Piece&, int&, PtypeO&,
int&, mask_t&, CArray<PieceMask,2>&, KingMobility&,
CArray<PieceMask,2>&, CArray<PieceMask,2>&,
CArray<uint64_t,2>&, MobilityTable&);
template void NumEffectState::
prologueDrop(Player2Type<WHITE>, Square, Ptype, Piece&, int&, PtypeO&,
int&, mask_t&, CArray<PieceMask,2>&, KingMobility&,
CArray<PieceMask,2>&, CArray<PieceMask,2>&,
CArray<uint64_t,2>&, MobilityTable&);
template void NumEffectState::
epilogueCapture(Player2Type<BLACK>, Square, Square, Piece, Piece, PtypeO, PtypeO,
PtypeO, int, int, int, mask_t, const CArray<PieceMask,2>&,
const KingMobility&, const PieceMask&, const CArray<PieceMask,2>&,
const CArray<PieceMask,2>&, const CArray<uint64_t,2>&,
const MobilityTable&);
template void NumEffectState::
epilogueCapture(Player2Type<WHITE>, Square, Square, Piece, Piece, PtypeO, PtypeO,
PtypeO, int, int, int, mask_t, const CArray<PieceMask,2>&,
const KingMobility&, const PieceMask&, const CArray<PieceMask,2>&,
const CArray<PieceMask,2>&, const CArray<uint64_t,2>&,
const MobilityTable&);
template void NumEffectState::
epilogueDrop(Player2Type<BLACK>, Square, Ptype, Piece, int, PtypeO, int, mask_t,
const CArray<PieceMask,2>&, const KingMobility&, const CArray<PieceMask,2>&,
const CArray<PieceMask,2>&, const CArray<uint64_t,2>&, const MobilityTable&);
template void NumEffectState::
epilogueDrop(Player2Type<WHITE>, Square, Ptype, Piece, int, PtypeO, int, mask_t,
const CArray<PieceMask,2>&, const KingMobility&, const CArray<PieceMask,2>&,
const CArray<PieceMask,2>&, const CArray<uint64_t,2>&, const MobilityTable&);
}
/* ------------------------------------------------------------------------- */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|